mysql - Echo variable which has same name in php join -


i have mysql join pulling 2 tables name product & cart , they're both being pulled variable $row_checkout

if have echo field, can go $row_checkout['cartid'] , works fine.

however, have coloumn in each table called same 'status'.

how echo 1 of tables? thought $row_checkout['cart.status'] might work doesnt appear to?

my database code follows:

$colname_checkout = "-1"; if (isset($row_booking['sessionid'])) {   $colname_checkout = (get_magic_quotes_gpc()) ? $row_booking['sessionid'] : addslashes($row_booking['sessionid']); } mysql_select_db($database_main, $main); $query_checkout = sprintf("select * cart, productdatabase cart.productid = productdatabase.productid , cart.status != 1 , cart.status != 0 , cart.sessionid = '%s' order `name` asc", $colname_checkout); $checkout = mysql_query($query_checkout, $main) or die(mysql_error()); $row_checkout = mysql_fetch_assoc($checkout); $totalrows_checkout = mysql_num_rows($checkout); 

you can use alias change tables field name, name want.

the cart.status filter, make simpler, simpler asking > 1

select c.status car_status, pro.status pro_status  cart c, productdatabase pro c.productid = pro.productid , c.status >1 , c.sessionid = '%s'  order `name` asc", $colname_checkout 

seeing get, display associative array names , values, can use address data

while ($row_checkout = mysql_fetch_assoc($checkout)) {     print_r($row_checkout); } 

or specific fields:

while ($row_checkout = mysql_fetch_assoc($checkout)) {     echo $row_checkout["car_status"];     echo $row_checkout["pro_status"]; } 

another comment, mysql function not recommended anymore. use mysqli or pdo_mysql. both object oriented , may need little more time learn.


Comments