I have written a function to bulid a table of url links stored in MySQL. In my database I have two tables: tblLinkTypes and tblLinks. My Output should look like this:
Link Type1
Link Title2 URL2
Link Type2
Link Title1 URL1
However I get this error when the code gets to the bottom (see //errors here).
Warning: 4 is not a MySQL result index in /home/httpd/inc/dbWhiteWater.inc on line 275
Here is my function:
Function DisplayLinks() {
$q = new DB_WhiteWater;
$sel_q = "SELECT FROM tblLinkTypes ORDER BY SortOrder";
$result = $q->query($sel_q);
if ($myrow = mysql_fetch_array($result)) {
do {
$title = $myrow["TypeName"];
$SearchValue = $myrow["TypeKey"];
$sel_q2 = "SELECT FROM tblLinks WHERE LinkType ";
$sel_q2 .= "LIKE '%" .$SearchValue."%'";
$sel_q2 .= "ORDER BY Title";
$result2 = $q->query($sel_q2);
echo("<H2>".$title."</H2>");
if ($myrow2 = mysql_fetch_array($result2)) {
echo("<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 WIDTH='100%'>\n");
echo("<TR BGCOLOR='#9abcde6'>\n");
echo("<TD WIDTH='30%'><B>Name</B></TD><TD WIDTH='70%'><B>URL</B></TD>\n");
echo("</TR>\n");
do {
$url = $myrow2["LinkURL"];
$name = $myrow2["Title"];
echo("<TR><TD>\n");
echo($name."</TD>\n");
echo("<TD><A HREF='http://".$url."' target=_new>".$url."</A></TD></TR>\n");
} while ($myrow2 = mysql_fetch_array($result2));
mysql_free_result ($result2);
echo("</TABLE>\n");
} else {
echo("No Entries");
}
} while ($myrow = mysql_fetch_array($result)); //errors here
mysql_free_result ($result); //errors here
}
}// end build links