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
https://forums.phpfreaks.com/topic/224327-dynamic-dropdown-selected/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.