If statement in a while loop php sql arghhhhhhhhhhhhhhhhhhhhh

Hi

My data is coming from an sql database. The value of the hide field is No (or null) and shows No in the code below. I want to use this value in an If statement: If No show the word New else Old:-
[php]<?php
while ($row = mysqli_fetch_array($result)) {
$hide2 = $row[“hide”];
echo ‘<a href=pendants.php?crystal="’.urlencode($row[“crystal”]).’" onfocus=“if(this.blur)this.blur();”>’.$row[“crystal”].’ (’.$row[“tot”].’) ‘.$row[“hide”].’ <?php if (($hide2)=="No") { "New"} else { "Old"} ;?>
';}mysqli_close($dbc);?>[/php]

I have tried putting echo in front of the words new and old. I have tried using the [php]$row[“hide”][/php]instead of [php]$hide2[/php]. I have tried various brackets around hide etc. I’m now at my wits end. Having searched through Google lots of examples of the if statement working but not for me! Appreciate any help.

Many thanks

Andrew

Give this a whirl:
[php]<?php
while ($row = mysqli_fetch_array($result)) {
$hide2 = $row[“hide”];
echo ‘<a href=pendants.php?crystal="’ . urlencode($row[“crystal”]) . ‘" onfocus=“if(this.blur) { this.blur(); }”>
’ . $row[“crystal”] . ’ (’ . $row[“tot”] . ') ’ . $row[“hide”] . ‘’;
if($hide2 == “No”) {
echo ‘New’;
}
else {
echo ‘Old’;
}
print ‘
’;
}
mysqli_close($dbc);
?>[/php]

Red :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service