View Single Post
Old 06-15-2009, 04:06 PM   #1 (permalink)
shoaibmunir
The Wanderer
 
shoaibmunir's Avatar
 
Join Date: Jun 2009
Location: Dubai, UAE
Posts: 23
Thanks: 2
shoaibmunir is on a distinguished road
Default Search query multiple tables? (PHP, MySQL)

I'm working on a php project. i have a create a search product page. its contain multi table and working fine but exact problem is both table have some same column names i can't get the first table column value


Database Structure //I can't change must i've to create a script for getting result


tbl_products:-
rn //i want this value because i'm using as a product id
imagename


tbl_productsdetail

rn //i don't wana this value
pn //value coming from tbl_products rn column
name
description



Code:
$apshmquery="select p.*, pd.* from tbl_products p, tbl_productsdetail pd where p.code like '%" . $apshmreqcode .  "%' or pd.name like '%" . $apshmreqq .  "%' or pd.description like '%" . $apshmreqq .  "%' and p.rn=pd.pn ";


 $apshmsql = mysql_query($apshmquery);

$apshmrows = mysql_num_rows($apshmsql);

while ($apshmrecords = mysql_fetch_array($apshmsql)) {

echo ($apshmrecords["rn"]."</br>");//i want here tbl_products column value

echo ($apshmrecords["name"]."</br>");//its coming from productsdetail working fine

echo ($apshmrecords["description"]."</br>");//its coming from productsdetail working fine

}

have any good solution??

Thank's in advance :)
Send a message via MSN to shoaibmunir
shoaibmunir is offline  
Reply With Quote