By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,521 Members | 1,420 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,521 IT Pros & Developers. It's quick & easy.

********Caution Newbie********editing and deleting from mysqldatabase

P: n/a
Show.php--This is for showing movie names available in database

<?php
include "auth.php";
$query="SELECT movie_id,movie_name FROM moviesite";
$result=mysql_query($query,$link) or die("Can't execute
query" .mysql_error());
while($row=mysql_fetch_array($result))
{
$movie_id=$row['movie_id'];
$movie_name=$row['movie_name'];
echo $movie_id;
echo $movie_name;
?>
<a href="update.php?action=edit&id=<?php echo $movie_id; ?>
">[UPDATE]</a ---I am not sure... What can i do to update and
delete record's from database -- User chooses which record to update
and delete
<a href="delete.php?action=delete&id=<?php echo $movie_id; ?>
">[DELETE]</a>
<?php
echo " <br/" ;
}

?>
<a href="add.php">[ADD]</a>
Add.php ---This is for adding movie names
<?php
include "auth.php";

$id=$_POST['movie_id'];
$movie_name=$_POST['movie_name'];
$query="INSERT INTO moviesite (movie_id , movie_name) VALUES (' $id
' , ' $movie_name' ) " ;
$sql=mysql_query($query);
if (!$sql)
{
die("Can not execute querey" .mysql_error());
}

echo "Added to the database";
mysql_close($link);
?>
<a href="show.php">Index</a>

Now this is the script which i am struggling with delete and update.
Now as far as i can understand i have to pass Movie_id to the
delete.php page and then use this variable to delete it..
But with this script when i execute it my entire list get's deleted.

<?php
include "auth.php";

if($_REQUEST['action']==delete)
{
$query="DELETE FROM moviesite where movie_id=' $movie_id ' LIMIT 1";
$sql=mysql_query($query) or die("Can not delete" .mysql_error());
}
?>
<a href="show.php">Movie</a>

let me know what i am doing wrong ...and what exact querey will be
like..Atleast the concept.
Thank's and advance.
Baldaris

Oct 20 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.