php/mysql syntax help



Hi,
This is a newbie question. I am using a text for learning php/mysql.
I am using PHP 5.2.x and mysql 5.
The example is that of a mysql
database of jokes. Before we get to joins there is a
simple table with 3 fields, ID field (primary key, integer),
JokeText, and JokeDate. In the program for some
reason the code is not retrieving the ID for each
row from the db. It gets the JokeText field just fine.
Let me include the snippets below.

This is where each row (each joke) is to be displayed.
Note that the ID is used to give the option of deleting a
joke from the db. The link tag is supposed to get that
ID passed to the link but that isn't happening. Please help.

// Display the text of each joke in the paragraph
while ( $row = mysql_fetch_array($result)) {
$jokeid = $row["ID"];
echo ($row["ID"]);
$deletejoke=$jokeid;
$joketext = $row["JokeText"];
$thispage = $_SERVER["PHP_SELF"];
echo("<p>$joketext " .
"<A HREF='$thispage?deletejoke=$jokeid'>" .
"Delete this Joke</a></p>");
}

Then the code to delete the joke ( the row from the
db) is as follows:
// If a joke has been deleted,
// remove it from the database
if (isset($_GET['deletejoke'])) {
$deletejoke=$_GET['deletejoke'];
echo("<p>The joke to delete is number $deletejoke");
$sql = "DELETE FROM jokes " .
"WHERE ID=$deletejoke";
if (mysql_query($sql)) {
echo("<p>The joke has been deleted.</p>");
} else {
echo("<p>Error deleting joke: " .
mysql_error() . "</p>");
}
}

Thanks in advance for any help,
Bruce


.



Relevant Pages

  • Re: php/mysql syntax help
    ... | I am using PHP 5.2.x and mysql 5. ... | This is where each row (each joke) is to be displayed. ... The link tag is supposed to get that ... spewing the variable to the browser will help pinpoint issues like that. ...
    (alt.php)
  • php/mysql syntax help
    ... I am using PHP 5.2.x and mysql 5. ... This is where each row (each joke) is to be displayed. ... The link tag is supposed to get that ... // Display the text of each joke in the paragraph ...
    (comp.lang.php)
  • php/mysql syntax help
    ... I am using PHP 5.2.x and mysql 5. ... This is where each row (each joke) is to be displayed. ... The link tag is supposed to get that ... // Display the text of each joke in the paragraph ...
    (php.general)
  • Checking to see if a call to the DB worked
    ... I'm writing a perl script to send out a joke of the day for my website. ... It is accessing a mysql db (I use php for the rest of the site. ...
    (comp.lang.perl)
  • Re: Problems with JTabbedPane
    ... a number of JPanels placed on a JPanel in a JFrame, but the entire display is just empty. ... If it is a bad joke then it follows from a bad troubleshooting query. ... No useful troubleshooting information in the OP. ...
    (comp.lang.java.gui)