•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 363,433 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,133 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 264 | Replies: 2
![]() |
•
•
Join Date: Dec 2007
Posts: 14
Reputation:
Rep Power: 1
Solved Threads: 1
I need to get information from 2 tables in the same mysql database
The name and ebay fields are in the customer table and the rest are in the notes table. The code above doesnt produce any error just no rows are displayed
php Syntax (Toggle Plain Text)
$sql = mysql_query("SELECT * FROM notes, customers WHERE `to`='next' LIMIT 5"); while($a = mysql_fetch_array($sql)){ $row_color = ($row_count % 2) ? "#EFEFEF" : "#FFFFFF"; echo("<tr bgcolor=\"$row_color\"> <td height=\"25\">" . $a['custid'] . "</td> <td height=\"25\">" . $a['name'] . "</td> <td>" . $a['ebay'] . "</td> <td>" . $a['title'] . "</td> <td>" . $a['type'] . "</td> </tr>"); $row_count++; }
The name and ebay fields are in the customer table and the rest are in the notes table. The code above doesnt produce any error just no rows are displayed
•
•
Join Date: Feb 2007
Location: St. Vincent and the Grenadines, Caribbean
Posts: 903
Reputation:
Rep Power: 3
Solved Threads: 38
•
•
Join Date: Apr 2008
Posts: 12
Reputation:
Rep Power: 1
Solved Threads: 0
is the talbes realted to each othere and the primary key of one table should be the foreign of the other tbale that u are trying to get datafrom
if soo
then you can use join
select from note, coustomers where note.id =costomer.id and to = 'next';
u can get more information on this from
http://www.tizag.com/mysqlTutorial/mysqljoins.php
if soo
then you can use join
select from note, coustomers where note.id =costomer.id and to = 'next';
u can get more information on this from
http://www.tizag.com/mysqlTutorial/mysqljoins.php
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Similar Threads
- Searching Multiple tables... Please help me!!!!! (PHP)
- Selecting info from multiple mysql tables and display (PHP)
- chat project (PHP)
- php drop down menu to search multiple sql tables (PHP)
- Query multiple tables with duplicate data (MySQL)
- hello and plz help (PHP)
- updating 2 HTML tables on one PHP page (PHP)
Other Threads in the PHP Forum
- Previous Thread: SMTP mail without php.ini
- Next Thread: Request for information


Linear Mode