View Single Post
Old 10-09-2012, 07:08 PM   PM User | #1
Wilhelmina
New to the CF scene

 
Join Date: Oct 2012
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Wilhelmina is an unknown quantity at this point
Question Allow user to edit and delete row

I've created a table with movies and a webpage where you can add more and view all of them. Now I'm trying to add if statements for if the edit or delete link has been clicked. Here is the code so far:

PHP Code:
<?php // movielibrary.php
require_once 'login.php';
$query "SELECT * FROM library";

$result mysql_query($query);
if (!
$result) die ("Database access failed: " mysql_error());
$rows mysql_num_rows($result);

echo 
"<table border='1'><tr> <th>Title</th>
        <th>Director</th>
    <th>Year</th><th>Category</th>
        <th>Update</th><th>Delete</th></tr>"
;

for (
$j $j $rows ; ++$j)
{
    
$row mysql_fetch_row($result);
    echo 
"<tr><td>$row[1]</td><td>$row[2]</td> 
        <td>$row[3]</td><td>$row[4]</td>
    <td><a href='movielibrary.php?edit=$row[0]'>Edit</a</td>
        <td><a href='movielibrary.php?delete=$row[0]'>Delete</a></td></tr>"
;
}

echo 
"</table>";

mysql_close($db_server);
?>
So my question is: how could I test the condition of if one of the links has been clicked? Thanks beforehand!
Wilhelmina is offline   Reply With Quote