select data from 2 table
$sql="SELEC开发者_StackOverflow中文版T *
FROM jobs
INNER JOIN job_resp ON jobs.job_id = job_resp.job_id
WHERE jobs.job_id = $job_id";
Is this query is correct?
mysql_query() will return FALSE on error. check out http://php.net/manual/en/function.mysql-query.php
I think in your case, no result returned is not necessarily to be an error. Therefore you can see no data showing plus the "successful" notice.
First of all your code is vulnerable to sql injection
$job_id=$_GET['job_id'];
// should be
$job_id=(int)$_GET['job_id'];
// or
$job_id=mysql_real_escape_string($_GET['job_id']);
depending on the data type of jobid.
Also you are echoing rows before you declared it, so it wont work. it seems like it should be inside the while loop
<?php
echo "<ul>";
while($rows=mysql_fetch_array($result))
{
echo "<li>".$rows['job_res']."</li>";
}
echo "</ul>";
try to use below query:
$sql="SELECT j.*, jr.*
FROM jobs as j
INNER JOIN job_resp as jr ON j.job_id = jr.job_id
WHERE j.job_id ='".$job_id."'";
But you should avoid *, try to use field name as j.id, j.job_titel etc.
精彩评论