出于某种原因,这给了我一个错误?
$result = mysql_query("SELECT wpjb_job.*,
wpjb_category.*
FROM wpjb_job ,
wpjb_category
WHERE (is_filled='0' AND is_active='1')
AND wpjb_job.job_category = wpjb_category.id
AND job_country={$countryid}
ORDER BY wpjb_job.job_title") or die(mysql_error());
这是错误:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 6 行的“ORDER BY wpjb_job.job_title”附近使用正确的语法
据我所知,我在服务器上有 mySQL 5.1。该代码仍然有效,但在表格之后给出了错误。
我将其更改为以下只是为了测试。 现在它运行良好,但是它会两次打印表格的标题,一次在开头,然后在结尾。更改在 $countryid 上,我现在将其设置为 '$countryid' 这没有错误
下面的代码与表格的打印
$joburl = "http://www.x.com/job/view/";
$result = mysql_query("SELECT wpjb_job.*,wpjb_category.*
FROM wpjb_job , wpjb_category
WHERE (is_filled='0' AND is_active='1')
AND wpjb_job.job_category = wpjb_category.id
AND job_country='$countryid'
ORDER BY job_title")
or die(mysql_error());
echo "<table border='1'>";
echo "<tr> <th>Job</th> <th>Company</th> <th>Industry</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo '<a href ="http://www.x.com/job/view/'.$row['job_slug'].'"> '.$row['job_title'].' </a>';
echo "</td><td>";
echo $row['company_name'];
echo "</td><td>";
echo $row['title'];
echo "</td></tr>";
}
echo "</table>";
}