Hi Guys,
I've done as you have said, but still no solution.
I think what the problem may be is that my checkboxes that are dynamically created all have the same values ie d0, when I want them to be d1, d2, d3 etc...
Any ideas as to why they are not doing this. Is it a problem with the hidden field I have created:
<?php
// Start the connection to the database
include('**********************');
$can_i_connect = db_connect(); // by db_connect function is in my include file
if(!$can_i_connect)
{
$msg = "Could not connect to the database";
}
// End the connection to the database
?>
<FORM NAME="form1" METHOD="post" ACTION="">
<?php
$sql = "SELECT *, DATE_FORMAT(published_web_date, '%d-%m-%Y') as formatted_date FROM cms_stories ORDER BY story_id DESC LIMIT 0,60";
$res = mysql_query($sql) or die(mysql_error());
$n = 0;
$total_results = mysql_num_rows($res);
// here
if(isset($_POST['Submit']))
{
$total = $_POST['total'];
$td = 0;
$i = 0;
for($i = 1; $i <= $total; $i++)
{
if(isset($_POST["d$i"]))
{
$sql2 = "DELETE FROM cms_stories WHERE story_id=".$_POST["d$i"];
$res2 = mysql_query($mysql_query) or die(mysql_error());
$td++;
}
}
//exit;
}
if($total_results <= 0)
{
echo "<table width='100%' border='0' cellpadding='1' cellspacing='1' bgcolor='#666666'>";
echo "<tr bgcolor='#0033FF'>";
echo "<td bgcolor='#0033FF'><font color='#FFFFFF'><strong><font color='#FFFF00'>>></font>";
echo " No Results Found...</strong></font></td>";
echo "</tr>";
echo "<tr>";
echo "<td bgcolor='#eeeeee'><div align='center'><strong><font color='#0033FF'>Sorry,
we found no results that match your search term.</font></strong><br>
Please either <a href='search.php'>modify</a> your search term, or visit
our <a href='edit_list.php'>recent stories</a> to find what you are looking
for</div></td>";
echo "</tr>";
echo "</table>";
}
else
{
echo "<b><font color='#0066CC'>>></font></b> Here are the <strong>".$total_results."</strong> most recent stories added to the database <br /><br />Here are those results, listed in ascendng order. <br /><br />";
echo "<table width='100%' border='0' cellpadding='1' cellspacing='1' bgcolor='#666666'>";
echo "<tr>";
echo "<td height='20' colspan='6' bgcolor='#0066CC'><font color='#FFFFFF'><strong><span class='story_listing'>:: Please the latest stories added to the site below...</span></strong></font></td>";
echo "</tr>";
echo "<tr bgcolor='#FFFFCC'>";
echo "<td width='10%'><strong><font color='#666666'><div align='center'><span class='story_listing'>#</span></strong></div></font></td>";
echo "<td width='20%'><strong><font color='#666666'><div align='center'><span class='story_listing'>Publish Date</span></strong></div></font></td>";
echo "<td width='40%'><strong><font color='#666666'><span class='story_listing'>Headline</span></strong></font></td>";
echo "<td width='10%'><strong><font color='#666666'><div align='center'><span class='story_listing'>Picture</span></strong></div></font></td>";
echo "<td width='10%'><strong><font color='#666666'><div align='center'><span class='story_listing'>Video</span></strong></div></font></td>";
echo "<td width='10%'><strong><font color='#666666'><div align='center'><span class='story_listing'>Sound</span></strong></div></font></td>";
echo "</tr>";
}
$res = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_object($res)) {
echo "<tr>";
echo "<td width='10%' bgcolor='#EEEEEE'><input type='checkbox' name='d$n' value='". $row->story_id."'></td>";
echo "<td width='20%' bgcolor='#EEEEEE'><span class='story_listing'><div align='center'>$row->formatted_date</div></span></td>";
echo "<td width='40%' bgcolor='#FFFFFF'><span class='story_listing'><a href='../stories/edit.php?story_id=". $row->story_id."'>". stripslashes($row->headline) ."</a></span></td>";
echo "<td width='10%' bgcolor='#FFFFFF'><span class='story_listing'><a href='../stories/edit_picture.php?story_id=". $row->story_id."'><img src='../../images/add-image.png' width='80' height='15' class='no_border'></a></span></td>";
echo "<td width='10%' bgcolor='#FFFFFF'><span class='story_listing'><a href='../stories/edit_video.php?story_id=". $row->story_id."'><img src='../../images/add-video.png' width='80' height='15' class='no_border'></a></span></td>";
echo "<td width='10%' bgcolor='#FFFFFF'><span class='story_listing'><a href='../stories/edit_sound.php?story_id=". $row->story_id."'><img src='../../images/add-sound.png' width='80' height='15' class='no_border'></a></span></td>";
echo "</tr>";
}
echo "</table>";
?>
<INPUT TYPE="submit" NAME="Submit" VALUE="Submit" CLASS="button">
<INPUT NAME="total" TYPE="hidden" ID="total" VALUE="echo $n">
</form><p> </p>