need help with code
Posted: Mon Mar 05, 2012 2:54 pm
I'm making a forum and I want to be able to delete a topic from a category but the code I wrote is getting errors and I'm not sure how to fix them
I'm getting an error with this line: and if i click the delete button i get an error with this line:
so I'm having trouble display the list of topics and since I can select a topic thats probably why I'm getting an error with the delete button
Hope someone can help
Code: Select all
//Deleting part
if (isset($_POST['submitButton']))
{
$topic_to_delete = $_POST['topicCategory'];
$sql = "DELETE FROM topics WHERE topicID = '$topic_to_delete' ";
mysql_query($sql);
}
//Displaying part
$sql = "SELECT
topicID
topicSubject,
topicDate,
topicCategory,
topicByUser
FROM
topics";
$result = mysql_query($sql);
echo '<form method="post" action="">
Topic:';
echo '<select name="topicCategory">';
while($row = mysql_fetch_assoc($result))
{
echo '<option value="' . $row['topicID'] . '">' . $row['topicCategory'] . '</option>';
}
echo '</select><br />';
echo ' <input type="submit" value="Delete topic" name="submitButton" />
</form>';
Code: Select all
echo '<option value="' . $row['topicID'] . '">' . $row['topicCategory'] . '</option>';Code: Select all
$topic_to_delete = $_POST['topicCategory'];Hope someone can help