I have a situation where by the following code is outputing the query rather than actually executing it. Im noob to this so its probably something stupid.. <?PHP $display .= "<table>"; $sql = "SELECT * FROM job_jobcategories"; $sql_res = mysql_query($sql); while ($sql_array = mysql_fetch_array($sql_res)){ $jobcat = $sql_array[jobcategory]; $query = "SELECT jobcategory, COUNT(*) FROM job_post WHERE jobcategory = $jobcat"; $display .= " <tr> <td>$jobcat</td> <td>($query)</td> </tr> "; } $display .= "</table>"; echo $display; ?> PHP: the line that is not working is the $query the first part (not written by me) works ok. I have attached a screenshot of what is output
so something like.. <?PHP $display .= "<table>"; $sql = "SELECT * FROM job_jobcategories"; $sql_res = mysql_query($sql); while ($sql_array = mysql_fetch_array($sql_res)){ $jobcat = $sql_array[jobcategory]; $query = "SELECT jobcategory, COUNT(*) FROM job_post WHERE jobcategory = $jobcat"; $sql_query = mysql_query($query); $display .= " <tr> <td>$jobcat</td> <td>($sql_query)</td> </tr> "; } $display .= "</table>"; echo $display; ?> PHP: