need help coding del function for MySql
Posted: Wed Sep 22, 2010 12:36 pm
OK this is what I have so far
And it does what it needs to do what. I want is to add radio button that is links to the ID field number and when the user selects the ones they want to del they click a del button that I will make. I know is kinda has to be like a form that is either link to the same page or a different page.
I dont know how I would do this. I know I need to define some like $id = the number that select and imputed in to the
something like this:
also is it better to echo or to print?
Code: Select all
<h2>Current News Admin</h2>
<h3><? echo date("F l d Y ") . "Time is " . date("g:i:A" ,time());?></h3>
<table border="1" align="center" cellspacing="1" cellpadding="1">
<tr valign="top">
<td><h2>Add to Current News</h2>
<p>Please enter the following:</p>
Tittle:<br>
<form method="post" action="report.php">
<label for="tittle"></label>
<input type="text" name="tittle"/><br />
Your Current News:<br>
<label for="message"></label>
<textarea rows="8" cols="40" wrap="virtual" name="message"></textarea><br />
Password For site:<br>
<label for="password"></label>
<input type="password" name="password" />
<input type="submit" value="Submit" name="submit" />
</form>
</td>
<tr valign="top">
<td>
<?
include 'dbuser.php';
// Connect to the data base
$dbc = mysqli_connect($server, $user, $pass , $db)
or die('Error connecting to MySQL server.');
// Retrieve data base
//$query = "SELECT * FROM `current` WHERE 1";
//$data = mysqli_query($dbc, $query);
$query = "SELECT * FROM `current` ORDER BY `current`.`id` DESC LIMIT 0, 30 ";
$data = mysqli_query($dbc, $query);
// Loop through the array of payment data
while ($row = mysqli_fetch_array($data)) {
// Display the current news data
echo '<h3>'. $row['tittle'] . '</h3>' ;
echo $row['date'] . '<br />' ;
echo $row['message'] . '<br />';
}
mysqli_close($dbc);
?>
</td>
</table>
I dont know how I would do this. I know I need to define some like $id = the number that select and imputed in to the
something like this:
Code: Select all
mysql_query("DELETE FROM current WHERE id = '$id'");
echo "Comment deleted!";