Jump to content

How do i loop checkbox?


dam89

Recommended Posts

Hello people,

 

I current have 1 table with 3 columns. How do i loop the first column with checkbox base on the number on the number of rows that are going to appear on the second column. Hope you guys can help me out.

Thank You =)

 

Current code:

 

<?php

include 'database.php';

$i=1;

$conn=dbConnect();

if (!$conn)

die("Couldn't connect to MySQL");

$query="select username, password from admin_login";

$result=mysql_query($query, $conn);

while ($row=mysql_fetch_assoc($result))

{

?>

<form name="form1" method="post" action="">

<table width="433" border="1" align="center">

<tr>

<td width="209">CHECKBOX?</td>

<td width="209"><?=$row['username']?></td>

<td width="208"><?=$row['password']?></td>

</tr>

</table>

 

<?php

$i++;

}

 

dbDisconnect($conn);

?>

Link to comment
https://forums.phpfreaks.com/topic/141321-how-do-i-loop-checkbox/
Share on other sites

Do you mean that you want to place 1 checkbox in the first column for each row that your creating?

 

If so, then just add the code for a checkbox like you would using normal HTML.

 

 

As a tip, You should use <?php echo instead of <?= .... I just had some experience with moving from PHP4, to PHP5 and by default, short-open tags are turned off. A site I was running on it broke and it took me a little while of going through the code to fix it. Pain in the arse... could have been avoided in the first place.

 

 

Nate

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.