Trouble with mysql_fetch_array
Posted: Fri Feb 14, 2003 9:17 am
I can print the results of an sql query out to a page, however i then want to use one of these results as a variable. I realise that $row[1] for example does not retain the value once it has been printed. How do i print this out and record it as a variable to be used on the next page. This is what i have so far :
mysql_connect("localhost", "supaper", "supaper5");
mysql_select_db("supaper") or die ("Unable to connect");
$result = mysql_query("select * from GRINDS where (grind_name like richard') AND
(stud_uname is not NULL) order by grind_name ");
while($row=mysql_fetch_array($result, MYSQL_BOTH))
if (!empty($row['grind_name']))
{
echo "<tr>\n";
echo "<td ><p><b>Grind ID:</b></p>$row[0]</td>\n";
echo "<td ><p><b>Grind Name:</b></p> $row[1]</td>\n";
echo "<td ><p><b>Grind Description:</b></p> $row[2]</td>\n";
echo "<td ><p><b>Grind Class:</b></p> $row[3]</td>\n";
echo "<td ><p><b>Grind StartDate:</b></p> $row[4]</td>\n";
echo "<td ><p><b>Grind Price:</b></p> $row[5]</td>\n";
echo "<td ><p><b>Student Name:</b><a href =\"../main/Tutor_DisplayStudent_Page.php\"> $row[7]</a></p></td>\n";
echo "</tr>";
}
else
{
echo "No results found";
}
mysql_connect("localhost", "supaper", "supaper5");
mysql_select_db("supaper") or die ("Unable to connect");
$result = mysql_query("select * from GRINDS where (grind_name like richard') AND
(stud_uname is not NULL) order by grind_name ");
while($row=mysql_fetch_array($result, MYSQL_BOTH))
if (!empty($row['grind_name']))
{
echo "<tr>\n";
echo "<td ><p><b>Grind ID:</b></p>$row[0]</td>\n";
echo "<td ><p><b>Grind Name:</b></p> $row[1]</td>\n";
echo "<td ><p><b>Grind Description:</b></p> $row[2]</td>\n";
echo "<td ><p><b>Grind Class:</b></p> $row[3]</td>\n";
echo "<td ><p><b>Grind StartDate:</b></p> $row[4]</td>\n";
echo "<td ><p><b>Grind Price:</b></p> $row[5]</td>\n";
echo "<td ><p><b>Student Name:</b><a href =\"../main/Tutor_DisplayStudent_Page.php\"> $row[7]</a></p></td>\n";
echo "</tr>";
}
else
{
echo "No results found";
}