Jump to content

Dynamic Dropdown Selected


Xtremer360

Recommended Posts

The rest of my coding works however this part does not and I'm trying to figure out why. I'm sure my syntax isn't right so I hope someone can correct my mistake.

 

$contentpageID = $_GET['id'];
    $query = "SELECT  
        contentpages.contentpage, 
        contentpages.shortname,
        contentpages.contentcode,
        contentpages.linebreaks, 
        contentpages.backlink,
        contentpages.showheading,
        contentpages.visible,
        contentpages.template_id
    FROM 
        contentpages
    WHERE 
        contentpages.id = '" . $contentpageID . "'";

<label for="template">Template</label>
                <select class="dropdown" name="template" id="template" title="Template">
                <option value="0">- Select -</option>
                <?php
                $query = 'SELECT * FROM templates';
                $result = mysql_query ( $query );
                while ( $template_row = mysql_fetch_assoc ( $result ) ) {
                        print "<option value=\"".$template_row['id']."\" ";
					if($template_row['id'] == $row['template_id']) {
						     print " SELECTED";
					}
                        print ">".$template_row['templatename']."</option>\r";
                }
                ?>
                </select>

Link to comment
Share on other sites

So what is going wrong on the page? Is it blank?

 

Do you have error reporting turned on? Make sure it is also set to strict.

 

Have you tried to pritn_r your results.

 

Are you meant to execute the first query? because you are overriding it here:

 

$query = 'SELECT * FROM templates';

 

..and I don't see any execution of the first one before that.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.