Selecting a MySQL database table with a PHP document is a quick way to get certain output onto a web page with very little coding or effort. You may want nothing more than a simple printout of the database table or something more complex like a full web application.
Regardless of the scenario, selecting multiple database tables in the same query is a little more tricky. Here is a syntax that worked for me. First connect to your database the way you normally would, then enter your query like this:
$result = mysql_query("SELECT * FROM table1, table2 ");
Replace “table1” and “table2” with the actual names of your tables. Next, you can show rows from both tables, but if any of the rows have the same names in both tables, you will have to specify them specifically in the query.
Finally, display the results however you like:
while($row = mysql_fetch_array($result))
echo "<div id='corn'> ";
echo "</div> <div id='wheat'> ";
echo "</div> ";