Reading 0 and 1 from a database and retrieving in a checkbox

i am trying to create a members table, using a PHPmyadmin database, and in the database, there is a 0 & 1 field, and i want to transform the 0 and 1 in a checkbox, for each member. Is an editable table, so the table might be in a form. Here is what i did:


$result2 = mysql_query("SELECT * FROM acars_users");

echo "<table border='1'>
<th>Dados Pessoais</th>
<th>Dados de Redes</th>
<th width='220px'>Base</th>
<th>&Eacute; Ativo?</th>

while($row = mysql_fetch_array($result2)) 

  echo "<tr>";
  echo "<td>" . $row['id'] . "</td>";

  echo "<td width='300px'>" . "<form action=editar.php method=POST><input name=username size=7 type=text value=".$row['username']." /></br><input name=nome size=10 type=text value=".$row['nome']." /><input name=sobrenome size=20 type=text value=".$row['sobrenome']." /></br><input name=email size=25 type=text value=".$row['email']." />" . "</td>";

  echo "<td>" . "<input name=datanascimento size=10 type=text value=".$row['datanascimento']." /></br><input name=pais size=10 type=text value=".$row['pais']." /></br><input name=cidade size=30 type=text value=".$row['cidade']." />" . "</td>";

  echo "<td>" . "IVAO:&nbsp;<input name=idivao size=8 type=text value=".$row['idivao']." /></br>VATSIM:&nbsp;<input name=idvatsim size=8 type=text value=".$row['idvatsim']." />" . "</td>";

  echo "<td>" . "<input name=base size=8 type=text value=".$row['base']." />" . "</td>";
  echo "<td>" . "<input name=rank size=10 type=text value=".$row['rank']." /></br>Admin &nbsp;<input name=admin size=1 type=checkbox value=".$row['admin']." /></br>DOV &nbsp; <input name=dov size=1 type=checkbox value=".$row['dov']." /></br>Checador &nbsp; <input name=checador size=1 type=checkbox value=".$row['checador']." />" . "</td>";
  echo "<td>" . "<input name=horas size=6 type=text value=".$row['horas']." />" . "</td>";
  echo "<td>" . "<input type=checkbox name='isactive[]' value=".$row['isactive']." />" . "</td>";
  echo "<td>" . "<input name=dinheiro size=10 type=text value=".$row['dinheiro']." />" . "</td>";
  echo "<td>" . "<input name=password size=10 type=password value=".$row['password']." />" . "</td>";
  echo "<td>" . "<input name=edit_id value=".$row['id']." type=hidden><input type=submit value=Editar ></form><form action=deletarexist.php method=POST><input name=delete_id value=".$row['id']." type=hidden><input type=submit value=Demitir></form>" . "</td>";

  echo "</tr>";

echo "</table>";



$chkd=$row['isactive']?'checked="checked"':''; // 0: false; 1: true
echo "<td><input type='checkbox' name='isactive[]' value='{$row['isactive']}' $chkd></td>";

(Although, you should look into using a templatingg system (such as smarty) rather than echoing html fragments. It seems at bit weird in the start, but as soon as you get used to it, you'll never look back-)

Need Your Help

Why dose mx.controls.Image appear as broken?

actionscript-3 flash flex flex4

In my KPage class that extends Sprite, I am trying to generate a thumbnail out of it

Are there any StatusNet toolkits for .NET?

.net twitter statusnet

There are plenty of projects out there that assist developers in posting things to Twitter; the one I can think of off the top of my head is Twitterizer.