【发布时间】:2025-12-19 09:05:11
【问题描述】:
我一直在编写网站的一部分。我正在从第一个表中提取您正在使用的帐户的友谊。
然后我创建一个while 以获取我朋友的所有用户名,然后我查询配置文件表以取出其他两个信息,例如性别和出生日期。
我的问题是第一个 if(query) 和 while(friend_username) 工作正常,我可以取出所有数据并打印用户列表,但是当我使用第二个 while(sex,birth_date) 进行第二个查询时,没有任何效果,我不能发现问题是第二天我尝试修复它但我找不到解决方案..
对不起我的英语不好,也对不起我糟糕的编码技巧。
我不知道我做错了什么。
<?php
$query = "SELECT friend_username FROM friends WHERE username = ? AND amicizia = '1' AND ban = '0' ";
if($stmt = $mysqli->prepare($query))
{
// bind parameter
$stmt->bind_param('s', $username );
// execute
$stmt->execute();
// bind result to a variable
$stmt->bind_result($amici);
// iterate through the results
echo "$amici";
while ($stmt->fetch())
{
$queryu = "SELECT sesso , data_nascita FROM profiles WHERE username = ? ";
if($stmtp = $mysqli->prepare($queryu))
{
// bind parameter
$stmtp->bind_param('s', $amici );
// execute
$stmtp->execute();
// bind result to a variable
$stmtp->bind_result($sesso, $data_nascita);
while ($stmtp->fetch())
{
// FARE CICLO WHILE CHE ESTRAPOLA LE INFORMAZIONE DALLA TABELLA PROFILES MA SISTEMARE PRIMA HE AL LOGIN COMPILI I CAMPI SULLA TAB PROFILES
echo "
<tr>
<td>
<div class=\"gallery\" style=\"height: 76px;\">
<a href=\"img/profilo.jpg\"><img class=\"align-left\" src=\"img/amico.png\" width=\"60\" height=\"60\" /></a>
</div>
</td>
<td>
<ul style=\"height:45px;\">
<li style=\"padding: 0;\">$amici</li>
<li style=\"padding: 0;\">$sesso</li>
<li style=\"padding: 0;\">$data_nascita</li>
</ul>
</td>
<td>
<p>Lorem Ipsum è un testo segnaposto utilizzato nel settore della tipografia e della stampa. Lorem Ipsum è considerato il testo segnaposto standard sin dal sedicesimo secolo</p>
</td>
<td>
<a href=\"\"><i class=\"icon-user icon-2x\"></i></a>
<a href=\"\"><i class=\"icon-envelope icon-2x\"></i></a>
<a href=\"\"><i class=\"icon-heart-empty icon-2x\"></i></a>
<a href=\"\"><i class=\"icon-trash icon-2x\"></i></a>
</td>
</tr>
";
}
}
}
}
?>
【问题讨论】: