get mysql results
Posted: Mon Nov 19, 2007 11:23 pm
Let me preface this question by saying that I haven't tried to connect to a db in almost a year and have hardly been doing any php.
With that out of the way, I'm ashamed to admit it, but I can't find my results. I want to dynamically populate a select list. I'd like to know if anyone sees what this bonehead (me) is missing. Here's my code:
The connect is farther up the page (do I have to reconnect/select the db?) and when I run the query through mysql querybrowser, it works perfectly.
Thanks,
b
With that out of the way, I'm ashamed to admit it, but I can't find my results. I want to dynamically populate a select list. I'd like to know if anyone sees what this bonehead (me) is missing. Here's my code:
Code: Select all
<option id="gen_sel_def1" default="true">~ select ~</option>
<?php
$querySG = "SELECT * from genre_name order by genre_name_id";
$results4 = mysql_query($querySG) or die('Query failed: ' . mysql_error());
$numRows = mysql_num_rows($results4);
print("numrows = ".count($numRows));
$resArray = mysql_fetch_array($results4);
if ($numRows <= 0) {
echo "<h1>No rows found, nothing to print so I am exiting</h1>";
exit;
}
else {
print_r($resArray);
foreach($resArray as $option) {
print_r($option);
print("<option value='".$option['0']." name='".$option['1']."'>".$option."</option>\n");
}
print_r($subgenre);
print("<option>count = ".count($subgenre)."</option>");
/*while($subgenre) {
print("<option value='".$subgenre['genre_name_id']." name='".$subgenre['name']."'>".$subgenre['name']."</option>\n");
}*/
}
?>
</select>Thanks,
b