LMPX.COM |
Home | Linux | Mysql | PHP | XML | ||
|
|
|||
From: Vinny Gullotta Date: Tue Jan 27 22:17:51 2004 Subject: pulling from two tables in db to two tables in php question
What I need to do is this, I want to take the information from $i[3] in
table links and put it where $i[4] is in the table users. Basically, I query
the first table for some info, but to make the second table look pretty, I'd
like to use the info from $i[3] in place of the info I get from $i[4]. Does
this make sense? Here is my code:
#query the db
$query = "SELECT * FROM links ORDER BY ID";
$result = mysql_query($query)
or die(mysql_error());
#display column titles
echo "<table border align=center>";
echo "<tr>";
echo "<td><center><small><b>Admin</b></small></td>";
echo "<td><center><small><b>ID</b></small></td>";
echo "<td><center><small><b>LINK</b></small></td>";
echo "<td><center><small><b>CODE</b></small></td>";
echo "</tr>";
#display results
while($i = mysql_fetch_row($result)) {
echo "<tr>";
echo "<td><small><a href=search.php?ID=",$i[0],">edit</a> | ";
echo "<a href=delete.php?ID=",$i[0],">delete</a></small></td>";
echo "<td><small><center>", $i[0], "</small></td>";
echo "<td><small><center><a href=",$i[1],">", $i[3], "</a></small></td>";
echo "<td><small><a href=\"http://www.vjg.cc/mylinks/link.php?un=%n&ln=",
$i[0], "\">", $i[2], "</a></small>";
echo "</tr>";
}
echo "</table><br>";
#query the db
$query = "SELECT * FROM users ORDER BY ID DESC";
$result = mysql_query($query)
or die(mysql_error());
#display column titles
echo "<table border align=center>";
echo "<tr>";
echo "<td><center><small><b>Admin</b></small></td>";
echo "<td><small><center><b>ID</b></small></td>";
echo "<td><small><center><b>USERNAME</b></small></td>";
echo "<td><small><center><b>LINK</b></small></td>";
echo "<td><small><center><b>Date/Time</b></small></td>";
echo "</tr>";
#display results
while($i = mysql_fetch_row($result)) {
echo "<tr>";
echo "<td><small><a
href=deleteuser.php?ID=",$i[0],">delete</a></small></td>";
echo "<td><small><center>", $i[0], "</small></td>";
echo "<td><small><center>", $i[1], "</small></td>";
echo "<td><small><center><a href=\"", $i[2], "\" target=\"_blank\">Link ID
#", $i[4], "</a></small></td>";
echo "<td><small><center>", $i[3], "</small></td>";
echo "</tr>";
}
echo "</table>";
| Navigate in group php.lang at sever news.php.net | |
| Previous | Next |
| © No Copyright You are free to use Anything |
Site Maintained by PHP Developer
Powered By PHP Consultants |