下面我展示了用于显示表格行的PHP代码,如果表selected_val
中selected_candidate
为1,如何突出显示行?
下面我展示了我正在使用的查询和if / else循环。我收到以下警告:'警告:mysql_fetch_array():提供的参数不是有效的MySQL结果资源'。
<?php
if(isset($_POST['Submit']))
{
$i=0;
while($data_set = mysql_fetch_array($result_set))
{
$i=0;
echo "<div id=\"Message1[$i]\" class=\"box\">";
echo "Country ={$data_set['ecountry']}<br/>";
echo "State = {$data_set['estate']}<br/>";
echo "</div>";
echo "<tr>";
echo "<td><input id=\"select_candi{$i}\" onclick=\"javascript:func(this.id,{$_SESSION['uid']})\" type=\"checkbox\" name=\"check_candi[]\" value=\"{$data_set['eid']}\"/></td>";
echo "<td>{$data_set['ename']}</td>";
echo "<td>{$data_set['lname']}</td>";
echo "<td>{$data_set['ecell']}</td>";
echo "<td>{$data_set['eposition']}</td>";
echo "<td>{$data_set['eemail']}</td>";
if($data_set['ecity']=='')
{
echo "<td>{$data_set['ecountry']}</td>";
}
else
{
echo "<td onmouseover=\"ShowText('Message1[$i]'); return true;\" onmouseout=\"HideText('Message1[$i]'); return true;\" href=\"javascript:ShowText('Message1')\">{$data_set['ecity']}</td>";
}
// echo "<td>{$data_set['ecountry']},{$data_set['estate']},{$data_set['ecity']}</td>";
echo "<td>{$qua}</td>";
echo "<td>{$data_set['other_work1']} {$data_set['other_work2']}{$data_set['other_work3']}{$data_set['other_work4']} {$data_set['other_work5']} {$data_set['other_work6']} {$data_set['other_work7']} {$data_set['other_work8']} {$data_set['other_work9']} {$data_set['other_work10']}
{$data_set['other_work1e']} {$data_set['other_work2e']} {$data_set['other_work3e']} {$data_set['other_work4e']} {$data_set['other_work5e']} {$data_set['other_work6e']} {$data_set['other_work7e']} {$data_set['other_work8e']} {$data_set['other_work9e']} {$data_set['other_work10e']}
</td>";
echo "<td><a href=\"detailcv.php?id={$data_set['eid']}\" target=\"_blank\"><input style=\" cursor:hand;width:40px\" class=\"button\" name=\"cv\" type=\"button\" value=\"C V\" /></a></td>";
echo "</tr>";
$i++;
}
}
?>
查询:在此我获取了selected_val
$query = "SELECT emp.eid,ename,lname,ecell,eposition,eemail,ecountry,estate,ecity,prefcities,ca,cs,cwa,completed,persuing,other_work1,other_work2,other_work3,other_work4,other_work5,other_work6,other_work7,other_work8,sc.selected_val ";
$query .= "FROM employee emp,selected_candidate sc";
如果循环:
if($data_set['selected_val']=='1')
{
echo "<script>$('#{$rowid}').css(\"background-color\",\"yellow\");</script>";
}
$rowid++;
selected_candidate Table
eid int(30)
rid int(30)
selected_val int(1)
employee table also contains eid int(30)
感谢。
答案 0 :(得分:0)
错误通常意味着您的查询中存在错误。要获得更多详细信息,请将mysql_query($query)
替换为mysql_query($query)or die(mysql_error())
。
可能是语法错误或输入错误的列名。