Here is a snippet of code.
for ($g =0; $g++<$idg;) { $ch = mysql_query("SELECT chips FROM reit WHERE id_games='$g' AND id_users='1' ",$db); while ($chg = mysql_fetch_array($ch)) { $chg = $chg['chips']; echo "<td>$chg </td>"; } }
When it is executed, it displays a column of chips (323, 5454, 45345, 43234)
, but, let's say, to do id_games
and id_users
where there are no chips
, it will output the same, only without a column, where there was no data. And how to make it so that when he sees that there is nothing, he changed nothing to 0 in the $chg
variable? If you disassemble the cycle, it turns out like this:
select chips from reit where id_users = '1' and id_games = '1'; 43432 select chips from reit where id_users = '1' and id_games = '2'; пусто select chips from reit where id_users = '1' and id_games = '3'; 434234 select chips from reit where id_users = '1' and id_games = '2'; 987
But he will print 43432 434234 987. At the same time, the entire table collapses. Tried to make conditions, but it doesn't work.
if ($chg == '') { $chg = '0'; }
select coalesce(chip, 0) FROM reit...
- alexlz