您好我有2臺在DBPHP 2查詢表
U_M表: ID username_u nome_u identificaorM
信息表: ID 用戶名 諾姆 sexo idade 糖尿病
我想在u_m表中使用identificarM在info表中搜索:
用戶名= username_u 諾姆= nome_u
,並顯示在表上
$id_M = @$_SESSION['id_M'];
$result = mysql_query("SELECT * FROM u_m WHERE identificadorM= SHA1('$id_M') ");
while($row2 = mysql_fetch_array($result)) {
$query2 = "SELECT * FROM info WHERE username=" . $row2['username_u'] . " and nome=" . $row2['nome_u'] . "";
}
echo "<table border='1' align='center'>
<tr>
<th><font color='white'>Registo</font></th>
<th><font color='white'>Nome do Paciente</font></th>
<th><font color='white'>Sexo</font></th>
<th><font color='white'>Data de Nascimento</font></th>
<th><font color='white'>Diabetes</font></th>
</tr>";
$i=0;
while($row = mysql_fetch_array($query2)) {
echo "<tr>";
echo "<td><font color='white'>" . ++$i . "</font></td>";
echo "<td><a href='validar2.php?username=$login&nome=" . $row['nome'] . "'><font color='white'>" . $row['nome'] . "</font></a></td>";
echo "<td><font color='white'>" . $row['sexo'] . "</font></td>";
echo "<td><font color='white'>" . $row['idade'] . "</font></td>";
echo "<td><font color='white'>" . $row['diabetes'] . "</font></td>";
echo "</tr>";
}
得到這個警告:mysql_fetch_array():提供的參數不是一個有效的MySQL結果資源在/ home/a4490951 /的public_html/principalM.php上線30
在while($row = mysql_fetch_array($query2)) {
爲什麼不結合你的查詢 – Rahul
你沒有執行'$ query2',你也沒有使用單引號的值,這個站點沒有調試服務 –
@Rahul我怎麼把它們組合起來? – user3697305