newbie: ye ol' nemesis using mysql_fetch_array to load data
| From: | Nicole Lallande | Date: | Thu, 08 Mar 2001 23:37:58 +0000 |
| Subject: | newbie: ye ol' nemesis using mysql_fetch_array to load data | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-43087@lists.php.net to get a copy of this message | ||
Hello all,
I have an order form where I am trying to load an option button with a
field column from a database file:
This part works fine (actually Professional PHP has an example using the
do...while statement - I wonder which is better?):
$len = mysql_num_rows($result);
for ($i=0; $i<=$len; $i++) {
echo "<option value=\"$catid[$i]\">$catid</option>";
}
The problem I have is loading the array - either I get the first or last
element of the array as a scalar variable or I get arrays of the word
'Array':
while ($row = mysql_fetch_array($result)) {
$rowid[] = $row["dnaProd_ID"];
$catid[] = $row["Cat_ID"];
$desc[] = $row["Description"];
$size[] = $row["Pkg_size"];
$price[] = $row["Price"];
}
and I have tried it without the [] - neither works. I also tried this
with a for loop - replacing the while statement with
for($j=0; $j<=$len; $j++) {
$row = mysql_fetch_array($result);
$rowid[$j] = $row["dnaProd_ID"];
$catid[$j] = $row["Cat_ID"]; etc, etc....
nope ;{ <sigh> - checked the archives, books - saw a similar question
but I tried what they did and it did not work. This is one of those
instances where the solution is so simple I can't find it.
TIA for your help,
Nicole
--
########################
Nicole Lallande
nicole@nmlconsulting.com
760.753.6766
########################