incubo
04-23-2004, 05:05 PM
For some reason my loop won't work. I'm new to php and am following a developers guide but my loop only seems to pull up the last record unless I specify an id in my sql. I've been searching the posts and this seems like a rudimentary problem but I keep getting the error - 'Call to a member function on a non-object' on the line containing the MoveNext() function. I have tried using the PHPLIB to extend the MySQL db class as well but still only get the last or specified record.
Please, I need help, and thank you in advance.
<?php
$aDBLink = mysql_connect("localhost", "robin", "******");
if (!empty( $aDBLink))
{
if (mysql_select_db("artsdb", $aDBLink) == True)
{
$aSQL = "select * from tblartist";
$aQResult = mysql_query($aSQL, $aDBLink);
if ($aQResult == True)
{
while( $aRow = mysql_fetch_array($aQResult))
{
$aID = $aRow["artist_id"];
$aFname = $aRow["fname"];
$aLname = $aRow["lname"];
$aPhone = $aRow["phone"];
$aEmail = $aRow["email"];
$aMusic = $aRow["music"];
$aGdesign = $aRow["gdesign"];
$aLit = $aRow["lit"];
$aPhoto = $aRow["photo"];
}
mysql_free_result($aQResult);
}
else
{print("query failed");}
}
else
{print("unable to select DB");}
}
else
{print("unable to connect to DB");}
?>
<body>
<div id="title">
<h1><span>For Art Sake</span></h1>
</div>
<table align="center">
<th colspan="2"><u>Artist</u></th>
<th></th>
<th colspan="7"><u>Category</u></th>
<?php while (!$aQResult->EOF) {
print ("<tr>");
print ("<td>$aFname</td>");
print ("<td>$aLname</td>");
print ("<td width=\"100\"></td>");
print ("<td>");
if ($aMusic == "1")
print("<a href=\"music.php?artist_id=$aID\">Music</a>");
else
print("n\a");
print ("</td>");
print ("<td width=\"75\"></td>");
print ("<td>");
if ($aGdesign == "1")
print("<a href=\"gdesign.php?artist_id=$aID\">Graphic Design</a>");
else
print("n\a");
print ("</td>");
print ("<td width=\"75\"></td>");
print ("<td>");
if ($aLit == "1")
print("<a href=\"lit.php?artist_id=$aID\">Literature</a>");
else
print("n\a");
print ("</td>");
print ("<td width=\"75\"></td>");
print ("<td>");
if ($aPhoto == "1")
print("<a href=\"photo.php?artist_id=$aID\">Photography</a>");
else
print("n\a");
print ("</td>");
print ("</tr>");
$aQResult->MoveNext();
}
$aQResult->Close();
?>
Please, I need help, and thank you in advance.
<?php
$aDBLink = mysql_connect("localhost", "robin", "******");
if (!empty( $aDBLink))
{
if (mysql_select_db("artsdb", $aDBLink) == True)
{
$aSQL = "select * from tblartist";
$aQResult = mysql_query($aSQL, $aDBLink);
if ($aQResult == True)
{
while( $aRow = mysql_fetch_array($aQResult))
{
$aID = $aRow["artist_id"];
$aFname = $aRow["fname"];
$aLname = $aRow["lname"];
$aPhone = $aRow["phone"];
$aEmail = $aRow["email"];
$aMusic = $aRow["music"];
$aGdesign = $aRow["gdesign"];
$aLit = $aRow["lit"];
$aPhoto = $aRow["photo"];
}
mysql_free_result($aQResult);
}
else
{print("query failed");}
}
else
{print("unable to select DB");}
}
else
{print("unable to connect to DB");}
?>
<body>
<div id="title">
<h1><span>For Art Sake</span></h1>
</div>
<table align="center">
<th colspan="2"><u>Artist</u></th>
<th></th>
<th colspan="7"><u>Category</u></th>
<?php while (!$aQResult->EOF) {
print ("<tr>");
print ("<td>$aFname</td>");
print ("<td>$aLname</td>");
print ("<td width=\"100\"></td>");
print ("<td>");
if ($aMusic == "1")
print("<a href=\"music.php?artist_id=$aID\">Music</a>");
else
print("n\a");
print ("</td>");
print ("<td width=\"75\"></td>");
print ("<td>");
if ($aGdesign == "1")
print("<a href=\"gdesign.php?artist_id=$aID\">Graphic Design</a>");
else
print("n\a");
print ("</td>");
print ("<td width=\"75\"></td>");
print ("<td>");
if ($aLit == "1")
print("<a href=\"lit.php?artist_id=$aID\">Literature</a>");
else
print("n\a");
print ("</td>");
print ("<td width=\"75\"></td>");
print ("<td>");
if ($aPhoto == "1")
print("<a href=\"photo.php?artist_id=$aID\">Photography</a>");
else
print("n\a");
print ("</td>");
print ("</tr>");
$aQResult->MoveNext();
}
$aQResult->Close();
?>