How to fix a piece of code PHP, JS?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
9 views
Good day! Please help to understand:
In the following piece of code:
<?php$gateways = $db->query("SELECT * FROM bit_gateways WHERE allow_receive='1' and status='1' ORDER BY id"); if($gateways->num_rows>0) { while($g = $gateways->fetch_assoc()) { if($g['default_receive'] == "1") { $sel = 'selected'; } else { $sel = "; } echo ''.$g[name].' '.$g[currency].''; } } else { echo ''.$lang[no_have_gateways].''; } ?>


The crux of the matter:
Our database has several data ID (for example 10)
They all unloaded in one command (As I understand it) is
"echo ''.$g[name].' '.$g[currency].'';"


We need to make sure that I could of the DM list, for example ID 5 to put the value "style="color:red"

As I see it -
"''.$g[name].' '.$g[currency].'';"

But this is not correct, or I don't know how to add the line that would display all 10 items but the position which is in database ID 5 was red
by | 9 views

2 Answers

0 like 0 dislike
They all unloaded in one command (As I understand it) is

no. This line displays the data from the variables. The database is irrelevant.

Your decision:
$style = "color: green;"; //put in a variable what we need if($g[id] == 5){ $style = "color: red;"; //put in a variable what we want, but only if $g[id] == 5 } echo ''.$g[name].' '.$g[currency].''; //substitute a variable in there wherever you want
by
0 like 0 dislike
do similarly default_receive:
if($g['default_receive'] == "1") { $sel = 'selected'; } else { $sel = "; } if($g['id'] == "5") { $color = 'color:red'; } else { $color = "; }
by

Related questions

110,608 questions
257,186 answers
0 comments
35,431 users