Jump to content

check box1


ctcp

Recommended Posts

<?php
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$sql="SELECT * FROM $tbl_name ORDER BY date DESC LIMIT 0, 10";
$result=mysql_query($sql);

// Count table rows
$count=mysql_num_rows($result);
?>
<table width="500" border="0" cellspacing="1" cellpadding="0">
<form name="form1" method="post" action="">
<tr>
<td>
<table width="500" border="0" cellspacing="1" cellpadding="0">


<tr>
<td align="center"><strong>Id</strong></td>
<td align="center"><strong>Name</strong></td>
<td align="center"><strong>Lastname</strong></td>
<td align="center"><strong>Option</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td align="center"><? $id[]=$rows['id']; ?><? echo $rows['id']; ?></td>
<td align="center"><input name="topic[]" type="text" id="topic" value="<? echo $rows['topic']; ?>" size="100"></td>
<td align="center"><input name="url[]" type="text" id="url" value="<? echo $rows['url']; ?>" size="100"></td>
<td align="center"><? echo $rows['options']; ?><input name="options[]" type="checkbox" id="options" value="Yes" <?php if (!(strcmp($rows['options'],"Yes"))) {echo "checked=\"checked\"";} ?> />  <label for="options"></label></td>
</tr>
<?php
}
?>
<tr>
<td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
<?php
// Check if button name "Submit" is active, do this
if($Submit){
for($i=0;$i<$count;$i++){
$sql1="UPDATE $tbl_name SET topic='$topic[$i]', url='$url[$i]', options='$options[$i]', type='$type[$i]' WHERE id='$id[$i]'";
$result1=mysql_query($sql1);
}
}

if($result1){
header("Location: " . $_SERVER['php_SELF']); }

mysql_close();
?>

 

i view 10 result per page how to make one chek box to check all records not one by one ...

 

Link to comment
https://forums.phpfreaks.com/topic/165729-check-box1/
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.