php - MySQL returns one row -


i have php code

if ($settings['ht_showlastwinners'] == 'yes') {     $query = $db->query('select * ht_history ');       if ($row = $db->fetch_array( $query )) {         $row['username'] = $db->fetchone('select username members id=' . $row['user_id'] );         $htwinners[] = $row;     }      $smarty->assign( 'htwinners', $htwinners ); } 

when on .tpl file use

  {section name=w loop=$htwinners}             <tr>                 <td>{$htwinners[w].username}</td>                 <td>{$htwinners[w].bet}</td>                 <td>${$htwinners[w].win}</td>             </tr>             {/section} 

it gives me 1 row. tried print value of htwinners in php page , gives me 1 row, suppose problem code, when "copies" data $ht_history in new $htwinners associating/replacing user id username, fetches 1 row.

thanks in advance answers, i'm pratical (not lot) on php, tried similar code-problems, didn't find , code have looks me without error restricted knowledge, i'm wrong.

  1. change "if" "while"
  2. you need change "$db" "$query"
  3. check parameter type fetch_array. expects result type constant integer

while ($row = $query->fetch_array( mysqli_assoc )) {


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -