I'm stuck coding a part of a website. I'm extracting from the first table the friendship for the account you are using.
Then I make a while
to get all usernames of my friends then I query the profiles table to take out other two information like sex and birth date.
My problem is that the first if(query)
and while(friend_username)
works fine and I can take out all the data and print the list of users but when I do the second query with the second while(sex,birth_date)
nothing works and I cant find the problem it's the second day I try to fix it but I can't find a solution..
Sorry for my bad English and also sorry for my bad coding skills.
I don't know what I'm doing wrong.
<?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>
";
}
}
}
}
?>