PHP/MySQL Question

PHP/MySQL Question

am 08.08.2006 19:53:49 von mpar612

Hello,

I'm sorry to keep posting and to put my long code at the bottom of my
posts, but I'm under a lot pressure to get this done quickly. I am
trying to add delete/update buttons to my page. I could not figure out
how to do it all in the existing page, so I added a link to my main
page that links to a delete page (code for both pages is below). When
a user clicks on the delete button and screen loads (the delete page
code) with the isbn number for that particular row added to the url
(e.g. delete_record.php?isbn=\'%20.%20987654321%20.%20\'). On the
delete page, I cannot retrieve any of the information from the row that
the user selected delete from on the main page. I have made several
attempts and spent several hours on this and can't seem to get it. I
hope this makes sense.

If I can get this working, I should be able to run a delete query on
the delete page that deletes the record from the database.

Thanks in advance!

My main page:

// Load PEAR DB
require 'DB.php';

// Connect to the database
$db =
DB::connect('mysql://mikepar8_hockey:testing@216.246.48.250/ mikepar8_mikeparkermusiccom');
if (DB::isError($db)) { die ("Can't connect: " . $db->getMessage()); }

// Set up automatic error handling
$db->setErrorHandling(PEAR_ERROR_DIE);

// Set up fetch mode: rows as objects
$db->setFetchMode(DB_FETCHMODE_ASSOC);

// Jump out of PHP mode to make displaying all the HTML tags easier
?>


print "

cellspacing=\"0\" bordercolor=\"#000000\">";

// Send the query to the database program and get all the rows back
$rows = $db->getAll('SELECT isbn, artist_name, album_title,
date_format(release_date, \'%M %d, %Y\') as release_date,
date_format(add_date, \'%M %d, %Y\') as add_date, description, price
FROM lounge');
foreach ($rows as $row) {
print "







";
}

?>


My delete page:

// Load PEAR DB
require 'DB.php';

// Load the form helper functions.
require 'formhelpers.php';

// Connect to the database
$db =
DB::connect('mysql://mikepar8_hockey:testing@216.246.48.250/ mikepar8_mikeparkermusiccom');
if (DB::isError($db)) { die ("Can't connect: " . $db->getMessage()); }

// Set up automatic error handling
$db->setErrorHandling(PEAR_ERROR_DIE);

// Set up fetch mode: rows as objects
$db->setFetchMode(DB_FETCHMODE_ASSOC);

// Jump out of PHP mode to make displaying all the HTML tags easier
?>

// Send the query to the database program and get all the rows back

if ( (isset($_GET['isbn'])) && (is_numeric($_GET['isbn'])) ) {
$isbn = $_GET['isbn'];
} elseif ( (isset($_POST['isbn'])) && (is_numeric($_POST['isbn'])) )
{
$isbn = $_POST['isbn'];
} else {
echo '

This page has been reached in error

';
exit();
}

print "
ISBN:$row[isbn]
Artist Name:$row[artist_name]
Album Title:$row[album_title]
Release Date:$row[release_date]
Add Date:$row[add_date]
Description:$row[description]
Price:$row[price]
\'\">DeleteUpdate

cellspacing=\"0\" bordercolor=\"#000000\">";

$rows = $db->getAll('SELECT isbn, artist_name, album_title,
date_format(release_date, \'%M %d, %Y\') as release_date,
date_format(add_date, \'%M %d, %Y\') as add_date, description, price
FROM lounge WHERE isbn=$isbn');
foreach ($rows as $row) {
print "





";
}

?>

ISBN:$row[isbn]
Artist Name:$row[artist_name]
Album Title:$row[album_title]
Release Date:$row[release_date]
Add Date:$row[add_date]
Description:$row[description]
Price:$row[price]