I have use joins to retrieve the data from various tables and I am successful in it but when I want to retrieve it the query only show me the result of last row even though I have use while loop on it but its not working properly give me the one result only which belongs to last row . Here is my php scrip.
include("connections/conn.php");
$sql = mysql_query("SELECT * FROM `tbl_cart` as c join " .
"`tbl_product` as p join " .
"`tbl_catagory` as ca join " .
"`tbl_compony` as co join " .
"`tbl_images` as i " .
"on c.pid=p.pro_id " .
"and p.compony=co.com_id " .
"and p.catagory=ca.cat_id " .
"and p.pro_id=i.p_id");
$row = mysql_fetch_array($sql);
while($row1 = mysql_fetch_array($sql)) {
$product_ids[]=$row1['pro_id'];
foreach($product_ids as $pro) {
echo $pro;
}
}
but the array contains this data. which have more result of from similar columns.
111Array ( [0] => 33 [cart_id] => 33 [1] => 110 [pid] => 110 [2] => 20 [quantity] => 20 [3] => 65,000 [price] => 65,000 [4] => 9 [userid] => 9 [5] => 2014-08-14 [dated] => 2013-08-24 [6] => 110 [pro_id] => 110 [7] => Aspire S3-391 [title] => Aspire S3-391 [8] => 10.68 lbs [weight] => 10.68 lbs [9] => 15.90 inch [width] => 15.90 inch [10] => 2.31 cm [height] => 2.31 cm [11] => Black [color] => Black [12] => 65,000 [13] => $1499 [USD] => $1499 [14] => [waranty] => [15] => Make work a touch easier.Get in touch with your productive side. Tap and scroll your way through the workday with an intuitive touch screen (select models) that helps you work so much smarter. Count on durability inside and out from built in security to the spill resistant keyboard and a thin light design thats packed with style. [description] => Make work a touch easier.Get in touch with your productive side. Tap and scroll your way through the workday with an intuitive touch screen (select models) that helps you work so much smarter. Count on durability inside and out from built in security to the spill resistant keyboard and a thin light design thats packed with style. [16] => 1 [catagory] => 1 [17] => 4 [compony] => 4 [18] => Intel® Core™ i5 [l_ptype] => Intel® Core™ i5 [19] => 2.8 GHZ [l_pspeed] => 2.8 GHZ [20] => 700 GB [l_harddisk] => 700 GB [21] => 4GB DDR3 [l_RAM] => 4GB DDR3 [22] => Windows 8 [l_op] => Windows 8 [23] => [l_battery] => [24] => [lcd_brightness] => [25] => [lcd_contrast] => [26] => [lcd_imagesize] => [27] => [lcd_pixelsize] => [28] => [lcd_resolution] => [29] => [lcd_backlight] => [30] => [lcd_depth] => [31] => [p_pspeed] => [32] => [p_resolution] => [33] => [p_pconsumption] => [34] => [p_memorycapacity] => [35] => [p_storagecapacity] => [36] => [p_interface] => [37] => [p_processorspeed] => [38] => [pro_p_consumption] => [39] => [pro_brightness] => [40] => [pro_resolution] => [41] => [pro_imagesize] => [42] => [pro_ptype] => [43] => [pro_imagesignal] => [44] => [pro_contrast] => [45] => [sca_capacity] => [46] => [sca_speed] => [47] => [sca_colordepth] => [48] => [sca_usb] => [49] => [sca_documentsize] => [50] => [sca_resolution] => [51] => 2013-08-24 [52] => 1 [cat_id] => 1 [53] => Laptop [cat_title] => Laptop [54] => 4 [com_id] => 4 [55] => Acer [com_title] => Acer [56] => 120 [img_id] => 120 [57] => Aspire S3-391_main.jpg [main_image] => Aspire S3-391_main.jpg [58] => Aspire S3-391_left.jpg [left_image] => Aspire S3-391_left.jpg [59] => Aspire S3-391_right.jpg [right_image] => Aspire S3-391_right.jpg [60] => Aspire S3-391_top.jpg [top_image] => Aspire S3-391_top.jpg [61] => Aspire S3-391_other.jpg [other_image] => Aspire S3-391_other.jpg [62] => 110 [p_id] => 110 )
And when I run this query in sql it returns me two rows so how can I retrieve the data accordingly in my php script I am really confuse in it please help me out . Now for further understanding i am adding this picture. And you people can see that this query is returning me two rows so how will fetch the two rows separately in my php script and show them on my page.