Hello. I am still learning php & mysql. I am trying to pull data from a table for a sub shop. The table is called "subs". Each row in the table has a "name"(of a sub). I know how to use a loop and print out all of the rows, but would rather (gets complicated) like to pull each row, and save it as an array, pull the next row, save it as an array .. and so on, so I can refer to them later. I don't care what the names of the row arrays will be, but do not want to keep having to repeat the code that I have provided. I would greatly appreciate any advice. Thank you in advance, Buffmin.
PHP Code:
<?php
// get results from database
$result = mysql_query("SELECT * FROM subs Where NAME='Ham'")
or die(mysql_error());
$Ham = mysql_fetch_row($result);
echo $Ham[0];
echo $Ham[1];
echo $Ham[2];
echo $Ham[3];
$result = mysql_query("SELECT * FROM subs Where NAME='Turkey'")
or die(mysql_error());
$Turkey = mysql_fetch_row($result);
echo $Turkey[0];
echo $Turkey[1];
echo $Turkey[2];
echo $Turkey[3];
?>
Comment