Forum Moderators: open
$query = "SELECT * FROM images WHERE ref ='xyz' order by 'display_order'";
$result = mysql_query($query) or die("Couldnt' execute query.");
$num = mysql_num_rows($result);#finds 7 rows
$i=1; while ($i<$num +1) { #$num = 7 will run 7 times as theres 7 images
echo "<select name=\"image$i\">"; #starts the loop of 7 select boxes
while ($newArray = mysql_fetch_array($result)){
$image = $newArray['image'];
$display_order = $newArray['display_order'];
print "<option value=".$image."$selected>$image, $display_order</option>";
}
echo "</select><br>";
$i++;
}
What I want exactly is seven selct boxes each holding the 7 image names and display order so the display order can be changed from an admin cp, the select boxes get dynamically assigned their numbers, I need to set the current display order as "selected" then list the rest of the 7 iamges then move on to the next select box.
Currently it works fine for the first select only and just gives blank boxes for the rest.
I am still learning php/mysql and have battled with this for 2 days, am I on the correct route to what I want, whats missing? I dont want the code written but a map of the path I should follow will help.
Thanks in advance
$query = "SELECT * FROM images WHERE ref ='xyz' order by 'display_order'";
$result = mysql_query($query) or die("Couldnt' execute query.");
echo "<select name=\"image\">";
while ($newArray = mysql_fetch_array($result)) {
$image = $newArray['image'];
$display_order = $newArray['display_order'];
print "<option value='".$image."'>".$image.", ".$display_order."</option>";
}
That should do the trick ;)