Jump to content

PHP and checkboxes


ianao

Recommended Posts

Hi

 

I want PHP to fetch the data from a mySQL table and display on each line a checkbox. The checkbox should be either ticked or unticked depending on whether the data reads true or false.

 

Here is my code snippet:

 

while($row= mysql_fetch_array($rs) )

{

  $list .= "<tr>";

  $list .= "<td>".$row["id"]."</td>";

  $list .= "<td>".$row["Author"]."</td>";

  $list .= "<td>".$row["Page"]."</td>";

if($row["publish"]==1)

{

$publish="CHECKED";

}

else

{

$publish="";

}

  $list .= "<td><input type=\"checkbox\" .$publish.></td>";

  $list .= "</tr>";

}

$list .= "</table>";

$list .= "</form>";

echo($list);

 

 

The checkboxes that should be ticked do not display as ticked. Any suggstions would be very welcome indeed.

 

Best

Ianao

Link to comment
https://forums.phpfreaks.com/topic/124441-php-and-checkboxes/
Share on other sites

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.