PDA

View Full Version : want to know the logic


gilberto
04-19-2015, 10:12 PM
I'm a newbie to create a website. I want to build a website for a cinema including a seat reservation function. The function is that customer can first choose the film and timeslot they want to watch. After clicking in, there is a seat plan for customer to choose their preferred seat . Then it will consist of the payment part. if customer B choose the same seat as customer A choosed at the same timeslot and movie, it will pop up an error. Will it consist of the database?

I have no idea about the logic of designing this function:cry::cry:.
there are lots of questions i can't figure out.
how to create a seatplan for customers to choose and how the website can recognize the seat is already taken by someone in the same timeslots?


Please help. :sad::sad:

edbr
04-20-2015, 02:14 AM
logic is with a database i would suggest.
a table would consist of
1 seat number
2 time slot
3 booked/confirmed yes or no (0 or 1 perhaps}
insert on condition not equal to time and if booked = no

edbr
04-20-2015, 07:28 AM
or try modify thois open souce script http://www.openmyseat.com

gilberto
04-20-2015, 07:30 PM
Thanks A lot!!! It really helps me.
right now i have created a table including all seats number
A1 A2 A3
B1 B2 B3
C1 C2 C3
.....

and below the table i have a form including a textfield and submit button.
is it possible if i click on the seat number in the table, the seat number i clicked will be shown on a textfield in the form?

edbr
04-21-2015, 01:59 AM
yes, use the seat selection in a form itself then collect the value by $_post or $_get

gilberto
04-21-2015, 10:19 PM
Thanks !!!! but im confused of using it. I have created 4 buttons and assigned seat numbers as a value on each button. For example, if A2 button is clicked, it will shift to the next page and display the value passed from the first page. but my code doesnt work and seesion seems not work here.
help would be very appreciated!!

<?php
session_start();

static $_SESSION[$x]=A;
static $_SESSION[$y]=1;

//loop for checking which button is clicked and pass the value to next page
while($x<C){
if(isset($_POST[$x.$y])){
'value'=$_SESSION[$_POST[$x.$y]];
}
$y++;

//next row
if($y%3){
$y==0; //
$x++;
}

}
?>

<body>

<div id="CONTENT">


<div id="A1" class="unit" style="left: 310px; top: 350px;"
<form action ="payment.php" method ="post">
<input type="submit" name="A1" value="A1">
</form>
</div>


<div id="A2" class="unit" style="left: 345px; top: 350px;">
<form action ="payment.php" method ="post">
<input type="submit" name="A2" value="A2" >
</form>
</div>

<div id="B1" class="unit" style="left: 310px; top: 385px;">
<form action ="payment.php" method ="post">
<input type="submit" name="B1" value="B1" >
</form>
</div>

<div id="b2" class="unit" style="left: 345px; top: 385px;">
<form action ="payment.php" method ="post">
<input type="submit" name="B2" value="B2" >
</form>
</div>
</div>


payment.php
<body>
<?php
echo $_POST['value'];
?>
</body>

edbr
04-22-2015, 02:03 AM
static $_SESSION[$x]=A;
static $_SESSION[$y]=1;

why static? the usage for that is in a class.



//loop for checking which button is clicked and pass the value to next page
while($x<C){
if(isset($_POST[$x.$y])){
'value'=$_SESSION[$_POST[$x.$y]];
}
$y++;

//next row
if($y%3){
$y==0; //
$x++;
}

}
what is the purpose of that?

edbr
04-22-2015, 04:56 AM
here are your buttons, action set to itself so you can see the 4_post value being sent


<body>
<div id="A1" class="unit" style="left: 310px; top: 350px;"></div>
<form action =" " method ="post">
<input type="submit" name="A1" value="A1">
</form>
</div>


<div id="A2" class="unit" style="left: 345px; top: 350px;">
<form action ="" method ="post">
<input type="submit" name="A2" value="A2" >
</form>
</div>

<div id="B1" class="unit" style="left: 310px; top: 385px;">
<form action =" " method ="post">
<input type="submit" name="B1" value="B1" >
</form>
</div>

<div id="b2" class="unit" style="left: 345px; top: 385px;">
<form action =" " method ="post">
<input type="submit" name="B2" value="B2" >
</form>
</div>
</div>


payment.php
<body>
<?php
print_r($_POST);
?>
</body>

edbr
04-22-2015, 06:49 AM
If you use $_GET you can use an image fo the seat


<a href="<?php $_SERVER['PHP_SELF'];?>?seat=A1"> <img src="images/general/favicon.ico" >
A1 </a>
<br>
<a href="<?php $_SERVER['PHP_SELF'];?>?seat=A2"> <img src="images/general/favicon.ico" >
A2 </a>
<br>

<a href="<?php $_SERVER['PHP_SELF'];?>?seat=A3"> <img src="images/general/favicon.ico" >
A3 </a>
<br>
<?php
print_r($_GET);
?>

gilberto
04-22-2015, 09:02 AM
Thanks a lot! Finally I successfully passed the value from the button to other page. But I experience another problem in which for example I click on A2, it shows (array([A2]=>A2). However, I just want to show the value "A2" in the page without the array.
Here are the codes that I have.
<div id="A1" class="unit" style="left: 310px; top: 350px;">
<form action="payment.php" method="post">
<input type="submit" name="A1" value="A1" class="seatbutton">
</form>
</div>


<div id="A2" class="unit" style="left: 345px; top: 350px;">
<form action="payment.php" method="post">
<input type="submit" name="A2" value="A2" class="seatbutton">
</form>
</div>

<div id="B1" class="unit" style="left: 310px; top: 385px;">
<form action="payment.php" method="post">
<input type="submit" name="B1" value="B1" class="seatbutton">
</form>
</div>

<div id="b2" class="unit" style="left: 345px; top: 385px;">
<form action="payment.php" method="post">
<input type="submit" name="B2" value="B2" class="seatbutton">
</form>
I am trying to make some buttons for the seats in a php and pass the value of the buttons clicked to payment.php.
Thanks for your reply in advance.

edbr
04-22-2015, 09:26 AM
<?php
print_r($_GET);
?>
will show the array
you have multiple forms so the passed var will be different for each submission. $_POST['A1'],$_POST['A2'],$_POST['A3'] etc.

name all the submits the same
<input type="submit" name="seat" value="A1" class="seatbutton">

<input type="submit" name="seat" value="A2" class="seatbutton">
echo $_POST['seat'];


if you use the $ get example i gave you

<a href="payment.php?seat=A3"> <img src="images/general/favicon.ico" >
A3 </a>

could collect any submission on payment.php as
echo $_GET['seat'] :

gilberto
05-04-2015, 05:41 AM
Thanks a lot! I now try to create a seat plan by creating a table in database for each. However, it seems that after pressing the buttons of the seat, the page refreshed and I lose all the post value in this page. How can I obtain the value without refreshing the page? Thanks.

<?php
session_start();
?>
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="en"; charset="utf-8" />
<meta name="description" content="movie, online ticket"/>
<meta name="keywords" content="movie, online ticket"/>
<meta http-equiv="Content-Language" content="en-US">
<title>Cineteatro Macau</title>
<link href="css/body.css" rel="stylesheet" type="text/css">
<link href="css/slidebox.css" rel="stylesheet" type="text/css">
<link href="css/seats.css" rel="stylesheet" type="text/css">
<link href="css/frame.css" rel="stylesheet" type="text/css">
<link href="css/table.css" rel="stylesheet" type="text/css">
<script src="js/jquery-1.11.2.min.js"></script>
<script src="js/jquery.cycle.all.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="js/jquery.seat-charts.min.js"></script>


</head>

<body>
<div id="WRAPPER">
<a href="../index.php"> <img src="../images/BANNER.jpg" width="1201" height="170" alt=""/></a>


<div id="menu">
<ul class="menu">
<li><a href="#">About Us</a>
<ul>
<li><a href="history.php">History</a></li>
</ul>
</li>
<li><a href="#">Movies</a>
<ul>
<li><a href="ticketing.php">Ticketing</a></li>
<li><a href="comingsoon.php">Coming Soon</a></li>
</ul>
</li>

<li><a href="news.php">News</a></li>
<li><a href="#">Members</a>
<ul>
<li><a href="coupon.php">Coupons</a></li>
</ul>
</li>
<li><a href="#">Venue</a>
<ul>
<li><a href="map.php">Map</a></li>
</ul>
</li>
<li><a href="#">Customer Service</a>
<ul>
<li><a href="faq.php">FAQ</a></li>
<li><a href="contact.php">Contact Us</a></li>
</ul>
</li>
</ul>
</div>
<!--Menu-->
<!-- catalog -->
<div class="catalog">
<a href="index.php" title="Home">Home</a>
<span title="Ticketing">Ticketing</span>
</div>
<!-- catalog end -->
<div id="SIDE">
<div id="announ">
<textarea style="resize:none" name="" cols="21" rows="28">

請輸入賬戶編號。請輸入賬戶編號。請輸入電路編號。請輸入安裝職員編號。請輸入安裝職員密碼。請輸入安裝職 員PPPoE登入名稱。請輸入聯絡電話號碼。 賬戶號碼 Account No - 電路編號 Circuit ID 安裝職員編號 Installer ID

</textarea>
</div>
</div>

<div id="CONTENT">
<div id ="seat" align="center">
<div id="fontcolor">
<div id="log">
<?php
$user =$_SESSION['username'];
echo "Welcome, $user ";
?>
<a href="/member/logout.php"><img src="images/logout.png" width="16" height="16" alt=""/></a>
</div>
<?php
if($_POST['movie']== 1)
echo "<h2>Avengers 2: Age of Ultron</h2>";
else if ($_POST['movie']== 2)
echo "<h2>When Marnie Was There</h2>";
else if ($_POST['movie']== 3)
echo "<h2>Fast and Furious 7</h2>";?>
<br><br><br>
<div class="demo">
<div id="seat-map">
<div class="front">SCREEN</div>
<?php
define('MAX_SEATS', 40);
define('ROW_CELLS', 10);
$connection = mysql_connect("localhost","root","otreblig") or die("Could not connect to database" . mysql_error());
mysql_select_db("mydb");
if( isset($_POST['team']) && is_array($_POST['team']) ) {
foreach($_POST['team'] as $key => $value) {
if($_POST['movie']== 1){
$insert="INSERT INTO seat (id, seat) VALUES ('$key', '$value')";
mysql_query($insert);
}
if($_POST['movie']== 2){
$insert2="INSERT INTO seat1 (id, seat) VALUES ('$key', '$value')";
mysql_query($insert2);
}
if($_POST['movie']== 3){
$insert3="INSERT INTO seat2 (id, seat) VALUES ('$key', '$value')";
mysql_query($insert3);
}
}
}


if($_POST['movie']== 1){
$seat_array = array();
$sql_query = mysql_query("select id, seat from seat");}
else if($_POST['movie']== 2){
$seat_array = array();
$sql_query = mysql_query("select id, seat from seat1");}
else if($_POST['movie']== 3){
$seat_array = array();
$sql_query = mysql_query("select id, seat from seat2");}
while( $tmp = mysql_fetch_array($sql_query) ) {
$seat_array[$tmp['id']] = $tmp['seat'];
}

if( count($seat_array) >= MAX_SEATS ) {
echo "All seats are not available";
exit();
}

?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

<table bgcolor="#030303" border="1" bordercolor="#FFFFFF"cellpadding="0" cellspacing="0">
<?php
for( $i=0; $i<MAX_SEATS;) {
echo '<tbody>';
echo '<tr>';
for($j=0; $j<ROW_CELLS; $j++,$i++) {
echo '<td align="center">';
if( !isset($seat_array[$i]) ) {
echo '<input name="team[' . $i . ']" value="' . ($i+1) . '" type="submit" method="post" class="seatbutton"/>';
} else {
echo '<font style="font-family:Calibri; font-size: 12px; font-weight:bold; color: #ff0000;">X</font>';
}
echo '</td>';
}
echo '</tr>';
}
?>
</tbody>
</table>

<form action="payment.php" method="post" class="paymentform">

<label>Username: <?php
$username = $_SESSION['username'];
echo $username;
?>
</label>
<br>


<label>Price: $60<td width="25"></label>
<br>

<label>Movie :<?php if($_POST['movie']== 1)
echo "Avengers 2: Age of Ultron";
else if ($_POST['movie']== 2)
echo "When Marnie Was There";
else if ($_POST['movie']== 3)
echo "Fast and Furious 7";?>
</label>
<br>

<h3>By pressing the seats, you will be directing to the payment page.</h3>

</div>
</div>
</div>
</body>
</html>

edbr
05-04-2015, 08:07 AM
Sorry not clear what you want to do with it , if the data is inserted in a database you can call it, else set sessions or read up on ajax