Following code will help you understand how to get values from 2 mysql tables where there are same field names in each table.
This problem usually occurs when you join two tables together.
Example: lets take two tables
Table1
id
s_name
age
Table2
id
p_name
age
In above two tables there is a id field in both.
$query = "select * from Table1, Table2"
The thing in here is not to use mysql_fetch_assoc(), use mysql_fetch_array()
$result = mysql_query($query);
while($data = mysql_fetch_array($result))
{
when you loop through to get the values just remember it will be formatted like following.
}
Table1 id => $data[0]
Table1 s_name = > $data[1]
Table1 age => $data[2]
Table2 id = > $data[3]
Table2 p_name => $data[4]
Table2 age = > $data[5]
Get Free Sinhala IT Learning Videos Kuppiya.com
No comments:
Post a Comment