ouzoumzak
ouzoumzak

Reputation: 95

Outputing a variable

I am making a admin page where admin can add shows for a specific movie and specific theater. Admin can add shows, theater name and movie name.

This is some of the code..

<?php
$showdatetime=$_POST['showdatetime'];
$movieid=$_POST['movieid'];
$theaterid=$_POST['theaterid'];
if(empty($showdatetime)){  
echo  "Show time is a must";
}
else
{
$querycinema=mysql_query("SELECT show.show_datetime, show.theater_id, show.movie_id, theater.theater_name, movie.movie_name FROM `show` 
                        JOIN theater ON theater.theater_id = show.theater_id
                        JOIN movie ON movie.movie_id = show.movie_id                            
                        WHERE  show.show_datetime='$showdatetime' AND show.theater_id='$theaterid' AND show.movie_id='$movieid' ");
 $checkcinema=mysql_num_rows($querycinema);
if($checkcinema != 0)
{ 
echo "Sorry, ".$showdatetime." is already been scheduled for movie".$movieid." in theater ".$theaterid."."; 
}
else
{
 $insert_user=mysql_query("INSERT INTO `show` (show_datetime, movie_id, theater_id) VALUES ('$showdatetime','$movieid', '$theaterid')");

Its working fine, but i have a problem in

 echo "Sorry, ".$showdatetime." is already been scheduled for movie".$movieid." in theater ".$theaterid."."; }

I need a way to add the movie name and the theater name for the theaterid and movieid chosen cz it is better to show the admin the name not the id of theater and movie.

I hope it is clear.. Thank you

Upvotes: 0

Views: 66

Answers (2)

anon
anon

Reputation:

Just add value to your array like this $data['theather_name'] & $data['movie_id']

Upvotes: 0

alexn
alexn

Reputation: 59022

You already have the movie name in your result set from the query so just read it:

if($checkcinema != 0)
{ 
    $data = mysql_fetch_assoc($querycinema);
    echo "Sorry, ".$showdatetime." is already been scheduled for movie".$data['movie_name']." in theater ".$theaterid."."; 
}

Upvotes: 3

Related Questions