hi,
i tried some code.the following code is used to display records from mysql table and dynamically creates a checkbox for every record.
when i click checkbox and press submit button,that particular record will be hided(unpublished),here the field 'published' value will be set to '0' means unpublished and '1' for published.upto this ok.
but what i want to do is when i want publish the same record again,how to code.if i create another button,how to make it in action.i want to code like this.
if published value='0' then if i click checkbox and press submit button,the published value='1'.if published value='1' then if i click checkbox and press submit button,the published value='0'.any of your help will be surely appreciated.
thanks
mrjameer
<?php
mysql_connect("localhost", "", "")or die("cannot connect");
mysql_select_db("mrj")or die("cannot select DB");
$sql="SELECT * FROM ahost";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
?>
<center><table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><font color="navy"><form name="form1" method="post" action=""><br><center><b>
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td bgcolor="lightgreen" align="center"><font color="navy">#</font></td>
<td bgcolor="lightgreen" align="center"><font color="navy"><strong>Id</strong></font></td>
<td bgcolor="lightgreen" align="center"><font color="navy"><strong>details</strong></font></td>
<td bgcolor="lightgreen" align="center"><font color="navy"><strong>bandwidth</strong></font></td>
<td bgcolor="lightgreen" align="center"><font color="navy"><strong>email_accounts</strong></font></td>
<td bgcolor="lightgreen" align="center"><font color="navy"><strong>published</strong></font></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<font color="navy">
<tr class="odd" onmouseover="over(this);" onmouseout="out(this);">
<td align="center"><font color="navy"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></font></td>
<td><font color="navy"><? echo $rows['id']; ?></font></td>
<td><font color="navy"><? echo $rows['details']; ?></font></td>
<td><font color="navy"><? echo $rows['bandwidth']; ?></font></td>
<td><font color="navy"><? echo $rows['email_accounts']; ?></font></td>
<td><font color="navy"><? echo $rows['published']; ?></font></td>
</tr></font>
<?php
}
?>
<tr>
<td colspan="5" align="center" ><input name="delete" type="submit" id="delete" value="unpublish">
</font></td>
</tr></table></center>
<?php
if($delete)
{
for($i=0;$i<$count;$i++){
$del_id = $checkbox[$i];
$sql = "UPDATE ahost SET published='0' WHERE id='$del_id'";
$result = mysql_query($sql);
}
if($result){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=viewfiles1.php\">";
}
}
mysql_close();
?>
</table>
</form>
</font></td>
</tr>
</table></center>