Is this correct, or what am i doing wrong? <?php $req = "SELECT *,' . $table . '.id as id_res from $table, $table1 where ' . $table . '.player_id = ' . $table1 . '.id AND ' . $table . '.tour_id = ' . $q . '"; ?> PHP:
You have variables all over the place. How about you attempt to execute the query, and see if it returns any errors.
use this one <?php $req = "SELECT * ". $table .".id as id_res from ".$table.", ".$table1." where '". $table ."'.player_id = '". $table1 ."'.id AND '". $table ."'.tour_id = '". $q; ?> PHP:
<?php $req = "SELECT *" . $table .".id as id_res from ".$table.", $table1 where " . $table . ".player_id = " . $table1 . ".id AND " . $table . ".tour_id = " . $q; ?> try above query. in php two string can be concatenated using ". "no coma is required. Sheetal
the query is correct but you may want to use table name aliases for better reading of the query.. <?php $req = "SELECT *,a.id as id_res from $table AS a, $table1 AS b where a.player_id = b.id AND a.tour_id = ' . $q . '"; ?> PHP:
' and " aren't the same in PHP. Assuming $table = "mytable", "SELECT *$table.id" will give you "SELECT *mytable.id" (which is bad SQL syntax, but has nothing to do with your confusing the 2 quotation methods). 'SELECT *$table.id' will give you 'SELECT *$table.id' - $table won't be parsed, it'll be the literal string of a dollar sign in front of the letters 'table'. If you confuse them you won't get the results you want.