I would like to retrieve data (the name in this case) from two tables and display them into a table. The columns are the same in both of the tables.
Can I do something like this:
$result=mysql_query("select table1.name, table2.name
from table1, table2 where id='$pid'");
Try this:
Also, note that if the value of
$pidis coming from an outside source, you should really prepare the data before you query it against the server. You can create your own filter function or you can utilize the mysqli::prepare function that does the work for you through data binding.