php - trouble with SQL Join statement and Referencing the items in my sql statement -


first thing think there errors in sql join statement (syntax or other). using 2 tables in statement, 1 called artists, other called prints. next, further down in php script reference items in sql statement mysqli_assoc fetch array. think there problems in there too.

here sql statement:

    $sql = "select concat(a.first_name, a.middle_name, a.last_name) name p.print_name, p.price, p.size, p.description, p.what_genre, p.quantity_on_hand artists left join prints p using (artist_id) order $order_by $limit"; 

here second part:

    while ($row = mysqli_fetch_array($query, mysqli_assoc)){             $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee');             $list .= '<tr bgcolor="' . $bg . '">';             $list .= '<td>' . $row['name'] . '</td><td>' . $row['print_name'] . '</td><td>' . $row['price'] . '</td><td>' . $row['size'] . '</td><td>' . $row['description'] . '</td><td>' . $row['what_genre'] . '</td><td>' . $row['quantity_on_hand'] . '</td></tr>';         }  

here error messages got:

notice: query:select concat(a.first_name, a.middle_name, a.last_name) name p.print_name, p.price, p.size, p.description, p.what_genre, p.quantity_on_hand artists left join prints p using (artist_id) order price desc limit 0,5you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'p.print_name, p.price, p.size, p.description, p.what_genre, p.quantity_on_hand f' @ line 1

in d:\xampp\htdocs\larry\chapter192\view_users2.php on line 68  warning: mysqli_fetch_array() expects parameter 1 mysqli_result, boolean given in d:\xampp\htdocs\larry\chapter192\view_users2.php on line 110 

you're missing comma between as name , p.print_name:

select concat(a.first_name, a.middle_name, a.last_name) name, p.print_name 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -