Xtremer360 Posted January 13, 2011 Share Posted January 13, 2011 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 More sharing options...
Anti-Moronic Posted January 13, 2011 Share Posted January 13, 2011 Your sql is over complicated. It can simply be: "SELECT * from contentpages where id = '" . $contentpageID . "'"; We also need an error or something instead of "it doesn't work". How? What is not working, specifically? Link to comment https://forums.phpfreaks.com/topic/224327-dynamic-dropdown-selected/#findComment-1158963 Share on other sites More sharing options...
Xtremer360 Posted January 13, 2011 Author Share Posted January 13, 2011 That's the thing its not spilling out an error. Link to comment https://forums.phpfreaks.com/topic/224327-dynamic-dropdown-selected/#findComment-1158965 Share on other sites More sharing options...
Anti-Moronic Posted January 13, 2011 Share Posted January 13, 2011 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 https://forums.phpfreaks.com/topic/224327-dynamic-dropdown-selected/#findComment-1158966 Share on other sites More sharing options...
Xtremer360 Posted January 13, 2011 Author Share Posted January 13, 2011 Its not even filling the dropdown with any of the templates from the database. Link to comment https://forums.phpfreaks.com/topic/224327-dynamic-dropdown-selected/#findComment-1158968 Share on other sites More sharing options...
snowman15 Posted January 13, 2011 Share Posted January 13, 2011 you should repost the most current code Link to comment https://forums.phpfreaks.com/topic/224327-dynamic-dropdown-selected/#findComment-1158970 Share on other sites More sharing options...
Xtremer360 Posted January 13, 2011 Author Share Posted January 13, 2011 I got it to work. I'm betting the issue was that I didn't rename the query variable so it wouldn't have the first one get over-written. Link to comment https://forums.phpfreaks.com/topic/224327-dynamic-dropdown-selected/#findComment-1158971 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.