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_q uery($query,$li nk) or die("Can't execute
query" .mysql_error()) ;
while($row=mysq l_fetch_array($ result))
{
$movie_id=$row['movie_id'];
$movie_name=$ro w['movie_name'];
echo $movie_id;
echo $movie_name;
?>
<a href="update.ph p?action=edit&i d=<?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.ph p?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=$_P OST['movie_name'];
$query="INSERT INTO moviesite (movie_id , movie_name) VALUES (' $id
' , ' $movie_name' ) " ;
$sql=mysql_quer y($query);
if (!$sql)
{
die("Can not execute querey" .mysql_error()) ;
}
echo "Added to the database";
mysql_close($li nk);
?>
<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_quer y($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
<?php
include "auth.php";
$query="SELECT movie_id,movie_ name FROM moviesite";
$result=mysql_q uery($query,$li nk) or die("Can't execute
query" .mysql_error()) ;
while($row=mysq l_fetch_array($ result))
{
$movie_id=$row['movie_id'];
$movie_name=$ro w['movie_name'];
echo $movie_id;
echo $movie_name;
?>
<a href="update.ph p?action=edit&i d=<?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.ph p?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=$_P OST['movie_name'];
$query="INSERT INTO moviesite (movie_id , movie_name) VALUES (' $id
' , ' $movie_name' ) " ;
$sql=mysql_quer y($query);
if (!$sql)
{
die("Can not execute querey" .mysql_error()) ;
}
echo "Added to the database";
mysql_close($li nk);
?>
<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_quer y($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
Comment