Jump to content

[SOLVED] Transform value 0 in no and 1 in yes help needed


dsp77

Recommended Posts

Hello,

I have this in the table: "value" type int 0 to represent false and 1 to represent true. everything works great in display to the user end it sees 0 or 1 i want to replace the 0 to display No and 1 to display Yes or a picture. please advise me how can i make this work.

well this is my code:

<?php
require_once('config.php');
$result=mysql_query("select * from table order by id asc");
?>
<?php
while($row=mysql_fetch_assoc($result)){
?>

<table class="table_i" cellpadding="1" cellspacing="1" id="resultTable">
  <thead>
    <tr>
      <th bgcolor="orange"><strong>ID</strong></th>
      <th bgcolor="orange"><strong>Name</strong></th>
      <th bgcolor="orange"><strong>Value</strong></th>
    </tr>
  </thead>
</table>
<?php
while($row=mysql_fetch_assoc($result)){
?>
<tr>
  <td><?php echo $row['id']; ?></td>
  <td><?php echo $row['name']; ?></td>
  <td><?php echo $row['value']; ?></td>
</tr>
<?php } ?>

if i use

$x = (row['somerow'] == 0) ? "No": "Yes";
echo $x;

i get Parse error: syntax error, unexpected '['

and if i use the query i get a boolean error

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.