Answer the question
In order to leave comments, you need to log in
I can't figure out how to extract data from the database. Only one line is displayed, why?
Good time!
Here is the code:
<?php
$db->Query("SELECT * FROM fanswer WHERE question_id = '$id' ORDER BY a_id DESC");
if($db->NumRows() > 0){
while($ans = $db->FetchArray()){
$logina =$ans["a_name"];
$db->Query("SELECT * FROM db_users WHERE user = '$logina'");
$ua = $db->FetchArray();
$ua1 = $ua["ava"];
?>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td width="25%" bgcolor="#F8F7F1"><strong><center>
<?
if(empty($ua1)) {
echo '<center><img src="/noava.png"></center>';
}else{
echo '<center><img src="/'.$ua['ava'].'"></center>';
}
?>
<?php echo $ans["a_name"]; ?></center></strong></td>
<td width="75%" bgcolor="#F8F7F1"><?php echo $ans["a_answer"]; ?></td>
</tr>
<tr>
<td bgcolor="#F8F7F1"></td>
<td bgcolor="#F8F7F1" style="text-align:right;"><?php echo 'Добавлено '.$ans["a_datetime"].'' ?></td>
</tr>
</table></td>
</tr>
</table><br><? } } ?>
$logina =$ans["a_name"];
$db->Query("SELECT * FROM db_users WHERE user = '$logina'");
$ua = $db->FetchArray();
$ua1 = $ua["ava"];
Answer the question
In order to leave comments, you need to log in
You are using $db for two tasks at once - it is natural that the second query causes its result to overwrite the result of the first query.
What to do? There are three options - two stupid ones, and one correct one:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question