Jump to content

Event Registration


steviemac

Recommended Posts

I am trying to create a on line registration.  I have a two part question.  One is I have a field named Seats,  I have the code that is counting it backwards to 0.  What I would like to be able to code is when it gets to zero it closes out and you can not go to that url.  The second is if you do click on the link after it is closed you will go to a redirect page.

<?php

$db_host = "localhost";
$db_user = "====";
$db_pass = "=====";
$db_name = "name";

function db_connect() {
    global $db_host;
    global $db_user;
    global $db_pass;
    global $db_name;
    $connection = mysql_connect($db_host,$db_user,$db_pass);
    if (!(mysql_select_db($db_name,$connection))) {
        echo "Could not connect to the database";
    }
    return $connection;
}

// Connect to the database
db_connect();

$query = "SELECT (25)-SUM(Seats) FROM table"; 

$result = mysql_query($query) or die(mysql_error());
// Seats left code
while($row = mysql_fetch_array($result)){
echo $row['(11)-SUM(Seats)'];
echo " seats are left.<br />";

}


?>

I have tried the if/else but to no avail.  Any help would be appreciated

Link to comment
https://forums.phpfreaks.com/topic/37074-event-registration/
Share on other sites

I have added the if/else code I am trying

<?php $query = "SELECT (4)-SUM(Seats) FROM table"; 

$result = mysql_query($query) or die(mysql_error());
// Seats left code
while($row = mysql_fetch_array($result))
{
echo $row['(4)-SUM(Seats)'];
echo " seats are left.<br />";


if($row['(4)-SUM(Seats)'] <= "4"){
echo $row['(4)-SUM(Seats)'];
echo " seats are left.<br />";

} elseif($row['(4)-SUM(Seats)'] == "0"){
echo $row['(4)-SUM(Seats)'];
echo "The course closed.";

}else {
echo "Help";
}
}?>

Link to comment
https://forums.phpfreaks.com/topic/37074-event-registration/#findComment-177117
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.