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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.