1

Topic: Help to understand please with data output from basis

Kind time!
Here such 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 = "https://bandito.host/wp-content/uploads/2018/08/gpc20140102.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 ' It is added '. $ ans ["a_datetime"]. "?> </td>
</tr>
</table> </td>
</tr>
</table> <br> <?}}?>

Deduces all the one first line, but dataful from the table users (avatar) but if to remove a line:

$logina = $ans ["a_name"];
$db-> Query ("SELECT * FROM db_users WHERE user = ' $logina '");
$ua = $db-> FetchArray ();
$ua1 = $ua ["ava"];

That deduces everything, but it is natural without avatars which are registered in db_users
Help  council, what not so I do...

2

Re: Help to understand please with data output from basis

If to throw out superfluous, it turns out so approximately.

$db-> Query ("SELECT * FROM fanswer WHERE question_id = ' $id ' ORDER BY a_id DESC");//through object $db made any request
while ($ans = $db-> FetchArray ()) {//received from it a maximum single line of the data
$db-> Query ("SELECT * FROM db_users WHERE user = ' $logina '");//forgot former and made new request through the same $db
}