Xtremer360 Posted April 19, 2011 Share Posted April 19, 2011 This code works when theres no predefined value however I'm trying to modify it in case there IS a value from the DB which is from the " . $row2['content'] . " data. echo "<select name=" . $row2['ID'] . " id=" . $row2['ID'] . " class=dropdown biofield title=" . $row2['fullName'] . " >"; echo "<option value= >None</option>"; if ($styleID == 1 || $styleID == 2 || $styleID == 6) { $charactersQuery = " SELECT characters.ID, characters.characterName FROM characters WHERE characters.styleID = 3 ORDER BY characters.characterName"; } else { $charactersQuery = " SELECT characters.ID, characters.characterName FROM characters WHERE characters.styleID IN (1,2,6) ORDER BY characters.characterName"; } $charactersResult = mysqli_query ( $dbc, $charactersQuery ); // Run The Query while ( $row3 = mysqli_fetch_array ($charactersResult, MYSQLI_ASSOC)) { echo "<option value=" . $row3['ID'] . ">" . $row3['characterName'] . "</option>\r"; } echo "</select>"; I normally use something like this but with the other code not sure how to modify it to work the same way. while ( $champion_row = mysqli_fetch_array ( $charactersResult, MYSQL_ASSOC ) ) { print "<option value=\"".$champion_row['ID']."\" "; if($champion_row['ID'] == $row['champID']) { print " SELECTED"; } print ">".$champion_row['characterName']."</option>\r"; } Link to comment https://forums.phpfreaks.com/topic/234119-modification/ Share on other sites More sharing options...
Xtremer360 Posted April 19, 2011 Author Share Posted April 19, 2011 Any suggestions? Link to comment https://forums.phpfreaks.com/topic/234119-modification/#findComment-1203498 Share on other sites More sharing options...
spiderwell Posted April 20, 2011 Share Posted April 20, 2011 i cant even see " . $row2['content'] . " in your code, what exactly are you trying to do, preselect an option if it is matching in $row2['content'] ? Link to comment https://forums.phpfreaks.com/topic/234119-modification/#findComment-1203781 Share on other sites More sharing options...
Xtremer360 Posted April 20, 2011 Author Share Posted April 20, 2011 Yes Link to comment https://forums.phpfreaks.com/topic/234119-modification/#findComment-1203783 Share on other sites More sharing options...
spiderwell Posted April 20, 2011 Share Posted April 20, 2011 i cant even see " . $row2['content'] . " in your code, its very hard to second guess your code if we can't see it. I am guessing its within the $row3 loop that you want 'selected' echoed into the <option>, but you haven't given us anything to work with Link to comment https://forums.phpfreaks.com/topic/234119-modification/#findComment-1203787 Share on other sites More sharing options...
Xtremer360 Posted April 20, 2011 Author Share Posted April 20, 2011 That's all the involved code. Link to comment https://forums.phpfreaks.com/topic/234119-modification/#findComment-1203791 Share on other sites More sharing options...
Xtremer360 Posted April 20, 2011 Author Share Posted April 20, 2011 Fixed. Link to comment https://forums.phpfreaks.com/topic/234119-modification/#findComment-1203793 Share on other sites More sharing options...
spiderwell Posted April 20, 2011 Share Posted April 20, 2011 it can't be because you ask this This code works when theres no predefined value however I'm trying to modify it in case there IS a value from the DB which is from the " . $row2['content'] . " data. but it doesn't appear in any of the code you have posted!?! EDIT:: glad you fixed it , as I had no clue Link to comment https://forums.phpfreaks.com/topic/234119-modification/#findComment-1203794 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.