[eluser]Unknown[/eluser]
I’m working on some cms tool to make posts on site I used a lot of cms like Joomla, WordPress and Textpattern. Now I want to make something like that, of course not even similar to that but just for my personal use and fun.
2 things to do:
1. Option to select all checkboxes. I like something like in joomla in top there is checkbox with titles when u select it all checkbox are selected and if u uncheck it all is unchecked
2. When I press delete button all checkboxes that I select are deleted from database or moved to some other category like trash which is nice because u can in that way return some posts that u delete by mistake or some other reason
Here is my code that bothers me becouse checkboxes don't work
Help with Code Tags
php Syntax (Toggle Plain Text)
1.
<?php
2.
include ('conf/config.php');
3.
include('conf/opendb.php');
4.
$sql="SELECT id, title, author, DATE_FORMAT(date, '%M %d, %Y') as sd FROM $tbl_name";
5.
$result=mysql_query($sql);
6.
7.
$count=mysql_num_rows($result);
8.
9.
?>
10.
<table border="0" cellspacing="0" cellpadding="0">
11.
<tr>
12.
<td><form name="form1" method="post" action="">
13.
<table border="0" cellpadding="0" cellspacing="0" class="adminlist">
14.
<tr id="top">
15.
<th width="5" align="center">Id</th>
16.
<th width="5" align="center">#</th>
17.
<th>Title</th>
18.
<th width="200" align="center">Author</th>
19.
<th width="100" align="center">Date</th>
20.
<th width="80" align="center">Delete</th>
21.
<th width="20" align="center">Edit</th>
22.
</tr>
23.
<?php
24.
while($rows = mysql_fetch_array($result)){
25.
?>
26.
<tr>
27.
<td width="5" align="center"><? echo $rows['id']; ?></td>
28.
<td width="5" align="center"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td>
29.
<td><? echo $rows['title']; ?></td>
30.
<td width="200" align="center"><? echo $rows['author']; ?></td>
31.
<td width="100" align="center"><? echo $rows['sd']; ?></td>
32.
<td width="80" align="center" id="trash"><a href="delete_news.php?id=<? echo $rows['id']; ?>">Delete</a></td>
33.
<td width="20" align="center" id="edit"><a href="edit_news.php?id=<? echo $rows['id']; ?>">Edit</a></td>
34.
<?php
35.
}
36.
?>
37.
<tr>
38.
<td colspan="7" align="center"><input name="delete" type="submit" id="delete" value="Delete"></td>
39.
</tr>
40.
<?
41.
// Check if delete button active, start this
42.
if($delete){
43.
for($i=0;$i<$count;$i++){
44.
$del_id = $checkbox[$i];
45.
$sql = "DELETE FROM $tbl_name WHERE id='$del_id'";
46.
$result = mysql_query($sql);
47.
}
48.
49.
// if successful redirect to delete_multiple.php
50.
if($result){
51.
echo "<meta http-equiv=\"refresh\" content=\"0;URL=post_manage.php\">";
52.
}
53.
}
54.
mysql_close();
55.
?>
56.
</table>
57.
</form>
58.
</td>
59.
</tr>
60.
</table>