0

If anyone has ideas pleas help!!

Ok, i have a drop down box generated from my database, the user can pick a option and then delete it from the database althoguh i doesnt seem to reogise it if it has a space in the word. How can i prevent this?

Below is my code

// code to generate drop down box
		$query="SELECT title FROM content ORDER BY title ASC";
		$result = mysql_query ($query);
		echo "<select name=title value=''>Title</option>";

		while($nt=mysql_fetch_array($result)){
		echo "<option value=$nt[title]>$nt[title]</option>";
		}
		echo "</select>";
				
//on the next page where its deleted the code is...
// we have something to delete
   	$SQLcmd = "DELETE FROM content WHERE title = '$title'";
 	mysql_query($SQLcmd, $con);
   
	// but did we delete anything....
   	if (mysql_affected_rows() == 0) {
      	echo "<p><font color=#C11B17>You were unsuccessful in deleting the information you requested! Please try again...</font></p>";
   		}
   		else 	{
      		echo "<p>**The information has been successfully deleted**</p>";
	}
2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by leeZA1
0

Try this:

// code to generate drop down box
		$query="SELECT title FROM content ORDER BY title ASC";
		$result = mysql_query ($query);
		echo "<select name=title value=''>Title</option>";

		while($nt=mysql_fetch_array($result)){
		echo "<option value=\"$nt[title]\">$nt[title]</option>";
		}
		echo "</select>";
				
//on the next page where its deleted the code is...
// we have something to delete
   	$SQLcmd = "DELETE FROM content WHERE title = '$title'";
 	mysql_query($SQLcmd, $con);
   
	// but did we delete anything....
   	if (mysql_affected_rows() == 0) {
      	echo "<p><font color=#C11B17>You were unsuccessful in deleting the information you requested! Please try again...</font></p>";
   		}
   		else 	{
      		echo "<p>**The information has been successfully deleted**</p>";
	}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.