468,121 Members | 1,561 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,121 developers. It's quick & easy.

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

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
0 1152

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

87 posts views Thread by Sony Music CDs install Malware | last post: by
1 post views Thread by Newbie | last post: by
5 posts views Thread by Meshuggah | last post: by
1 post views Thread by =?Utf-8?B?TWFyZWs=?= | last post: by
2 posts views Thread by MartinRinehart | last post: by
18 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.