RE: [PHP] Please help me with a query
| From: | Jef Sullivan | Date: | Tue, 13 Jun 2006 14:18:17 +0000 |
| Subject: | RE: [PHP] Please help me with a query | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-237892@lists.php.net to get a copy of this message | ||
Your query is wrong. You are selecting only one result yet you are
referencing three. I suggest...
SELECT * FROM centers ORDER BY idc asc
Jef
-----Original Message-----
From: Jesús Alain Rodríguez Santos [mailto:wmaster@cfg.jovenclub.cu]
Sent: Tuesday, June 13, 2006 8:49 AM
To: php-general@lists.php.net
Subject: [PHP] Please help me with a query
First of all I'm sorry for my english I don't know speak very well, I will
try to explain it, I hope you understain what I need.
I have two tables: centers and peoples, in table centers I have the centers
values and in table peoples I have the peoples values and in table columns
center the id corresponding the center.
db:
centers
id namec correoc telc
1 Cienfuegos safd@como.com 4534345
2 Havana wdq@como.com 4643765
3 Santiago dsdf@como.com 3453453
peoples
id named center correod
cargod
1 Albert 1 dfsasd@como.com
sfgsdfgsdfgsdfg
2 Julio 1 wdfsdf@como.com
sadfsgfdsfgfdsg
3 Sussan 2 efgedfg@como.com
gjfhjfhjfhjfg
4 Peter 2 fgdfdfg@como.com
fgjhfgjgfjhjjghj
And the query and script to generate the tables for each centers list is:
$centers = mysql_query("SELECT namec FROM centers ORDER BY idc asc",
$connect);
while ($centerss = mysql_fetch_array($centers, MYSQL_ASSOC)) {
echo "<table border=1>";
echo "<tr>";
echo "<td width=265 height=20 align=center
valign=middle>".$centerss['namec']."</td>";
echo "<td width=265 height=20 align=center valign=middle><a
href=mailto:".$centerss['correoc'].">".$centerss['correoc']."</a></td>";
echo "<td width=265 height=20 align=center
valign=middle>".$centerss['telc']."</td>";
echo "</tr>";
echo "</table><p></p>";
}
mysql_free_result($centers);
That's generate one table with one row and three columns for each center,
but, I would like to generate more rows and 3 columns in each table with the
named, correod and cargod of peoples corresponding the center, I mean, print
the centers values with the peoples corresponding this center, in one table
each one.
I hope you understaind what I need, if not polease let me know.
regards Alain
--
Este mensaje ha sido analizado por MailScanner
en busca de virus y otros contenidos peligrosos,
y se considera que está limpio.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php