Answer the question
In order to leave comments, you need to log in
How to fix a piece of PHP, JS code?
Good day! Please help me understand:
In a 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 '<option value="'.$g[id].'" '.$sel.'>'.$g[name].' '.$g[currency].'</option>';
}
} else {
echo '<option>'.$lang[no_have_gateways].'</option>';
}
?>
"echo '<option value="'.$g[id].'" '.$sel.'>'.$g[name].' '.$g[currency].'</option>';"
"style="color:red""
"'<option value="'.$g[5].'" '.$sel.' style="color:red">'.$g[name].' '.$g[currency].'</option>';"
Answer the question
In order to leave comments, you need to log in
They are all unloaded with one command (As I understand it) this
$style = "color: green;"; //загоняем в переменную то что нам надо
if($g[id] == 5){
$style = "color: red;"; //загоняем в переменную то что нам надо, но только если $g[id] == 5
}
echo '<option value="'.$g[id].'" '.$sel.' style="'.$style.'">'.$g[name].' '.$g[currency].'</option>'; //подставляем переменную туда куда заблагорассудится
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question