I am learning mySQL and PHP right now, and I have run into the following problem with a code I am working on. Here are the two databases:
CARTICLES ' fields
id
category
title
content
dateid
imgurl
authid
count id
CAUTHORS
id
fname
lname
atitle
email
address
siteurl
phone
adesc
so far I have gotten the following code to list each article with its author:
<?
$SQL = " SELECT * FROM $table LEFT JOIN $table2 ON authid = cauthors.id";
$retid = mysql_db_query($DBName, $SQL, $cid);
if (!$retid) { echo( mysql_error()); }
else {
echo ("<P><TABLE CELLPADDING=4>\n");
while ($row = mysql_fetch_array($retid)) {
$title = $row["title"];
$fname = $row["fname"];
$lname = $row["lname"];
$atitle = $row["atitle"];
$id = $row["id"];
echo ("<TD><FONT SIZE=\"2\" COLOR=\"#000000\" FACE=\"Verdana, Helvetica, Times New Roman, New Times Roman\"><b>$title</b> by $atitle $fname $lname</FONT></TD></TR>\n");
echo ("<TR>");
echo ("<TD><FONT SIZE=\"2\" COLOR=\"#000000\" FACE=\"Verdana, Helvetica, Times New Roman, New Times Roman\"><A HREF=http://www.phpbuilder.com/board/archive/index.php/\"edit.php?id=$id\">Edit</A> | </FONT>");
echo ("<FONT SIZE=\"2\" COLOR=\"#000000\" FACE=\"Verdana, Helvetica, Times New Roman, New Times Roman\"><A HREF=\"manage.php?id=$id&task=del\">Delete</A></FONT></TD>");
echo ("<TR>");
}
echo ("</TABLE>");
}
?>
The problem I am having is to get $id to equal the id field in the CARTICLES database. Could someone please show me a way to do this?
Thanks!
CARTICLES ' fields
id
category
title
content
dateid
imgurl
authid
count id
CAUTHORS
id
fname
lname
atitle
address
siteurl
phone
adesc
so far I have gotten the following code to list each article with its author:
<?
$SQL = " SELECT * FROM $table LEFT JOIN $table2 ON authid = cauthors.id";
$retid = mysql_db_query($DBName, $SQL, $cid);
if (!$retid) { echo( mysql_error()); }
else {
echo ("<P><TABLE CELLPADDING=4>\n");
while ($row = mysql_fetch_array($retid)) {
$title = $row["title"];
$fname = $row["fname"];
$lname = $row["lname"];
$atitle = $row["atitle"];
$id = $row["id"];
echo ("<TD><FONT SIZE=\"2\" COLOR=\"#000000\" FACE=\"Verdana, Helvetica, Times New Roman, New Times Roman\"><b>$title</b> by $atitle $fname $lname</FONT></TD></TR>\n");
echo ("<TR>");
echo ("<TD><FONT SIZE=\"2\" COLOR=\"#000000\" FACE=\"Verdana, Helvetica, Times New Roman, New Times Roman\"><A HREF=http://www.phpbuilder.com/board/archive/index.php/\"edit.php?id=$id\">Edit</A> | </FONT>");
echo ("<FONT SIZE=\"2\" COLOR=\"#000000\" FACE=\"Verdana, Helvetica, Times New Roman, New Times Roman\"><A HREF=\"manage.php?id=$id&task=del\">Delete</A></FONT></TD>");
echo ("<TR>");
}
echo ("</TABLE>");
}
?>
The problem I am having is to get $id to equal the id field in the CARTICLES database. Could someone please show me a way to do this?
Thanks!