I AM WORKING OVER NEWS SECTION OF MY WEBSITE... I WANT TO RETRIEVE THE NEWS PRESENT IN THE DATABASE AND SHOW THEM AND ALLOW CHECK BOX TO SELECT THE NEWS TO DELETE THEM...
I am able to create the news section that retrieve the data from mysql database and also provide the check box facility.... But how can i tell my php script that how many check boxes are selected ....

<form action="check.php" method="POST">
<?php
database connection
selecting database
retrieving record and attach check box with each
close database
?>
</form>

now in check.php , how can i retrieve the records , when i dont know how much news are selected... Thanx

Member Avatar for diafol
<?php
if(isset($_POST['chk'])){
	print_r($_POST['chk']);
}

...db details and query...
$output = "";
while($d = mysql_fetch_assoc($result)){
  $output .= "<input type=\"checkbox\" id=\"chk_{$d['id']}\" name=\"chk[]\" value=\"{$d['id']}\" /> <label for=\"chk_{$d['id']}\">{$d['label']}</label>";
}
?>
<form method="post">
<?php echo $output;?>
<input type="submit" value="go" />
</form>

Something like that?

I have also same problem :(

I saw now ur logical problem. I imagined the same way as it does in web based emails. where int the role of those checkboxes will if it will do something on that file or information or what so ever. Try to put your news items in an array. Simplest way is in Last In First Out type of Array... where in the date of the news item is involved and it may seem somehow successful... And now, for those checkboxes... You'll have to put the news items in An array that will check all the data elements that is checked and those data elements that are validated checked will delete that by method of popping (Stack and Pop method of Array is what you have to do)... Now that you know that it's possible to solve ur problem using 1st Dimension Array.... the problem is you should construct your Java script or AJAX or JQuery in those checkboxes... another problem was this... if your news item shows all that is stored on your database on one page, then... you'll have to set a limit of how many news items will be showed up or else the check boxes will in default quantity... and that will make a bug error and will occur infinite proccess...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.