chrispulliam Posted July 16, 2012 Share Posted July 16, 2012 I Have the following 2 statements that I need help with to try to combine <? $query="SELECT * FROM programs"; /* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */ $result = mysql_query ($query); echo "<select name=program_name value=''></option>"; // printing the list box select command while($nt=mysql_fetch_array($result)){//Array or records stored in $nt echo "<option value=$nt[Title]>$nt[Title]</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?> <option value="<?php echo $row_processing['eng_review']; ?>" selected="selected"><?php echo $row_processing['eng_review']; ?></option> What I am needing to do is on my form pull in information from a database entry as well as pulling in a predefined list from a separate table. Link to comment https://forums.phpfreaks.com/topic/265767-combining-2-statements/ Share on other sites More sharing options...
scootstah Posted July 17, 2012 Share Posted July 17, 2012 Can you explain the question more clearly please? Link to comment https://forums.phpfreaks.com/topic/265767-combining-2-statements/#findComment-1362025 Share on other sites More sharing options...
Donald. Posted July 17, 2012 Share Posted July 17, 2012 I'll try to answer this with the information I think I've understood so far. You've got a pre-determined select option that you want to enter as well as some that you're pulling out of a database. If you want to combine those two code you can just add the second line just before the while command so it doesn't get repeated in the loop. <?php $query="SELECT * FROM programs"; /* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */ $result = mysql_query ($query); echo "<select name=program_name value=''></option>"; // printing the list box select command echo "<option value=\"" . $row_processing['eng_review'] . "\" selected=\"selected\">" . $row_processing['eng_review'] . "</option>"; //Where are you getting this array from? while($nt=mysql_fetch_array($result)){//Array or records stored in $nt echo "<option value=$nt[Title]>$nt[Title]</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?> But I don't see where $row_processing[] array is defined so I don't know if this is what you wanted. Link to comment https://forums.phpfreaks.com/topic/265767-combining-2-statements/#findComment-1362036 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.