Jump to content

Recommended Posts

Hi guys,

 

I am currently building a customer appointment booking system with PHP.

 

Customers who are added are store on a customer database and displayed or listed as links dynamically in a 'customer.php' page. So you can click on a customer to view their profile i.e. name, address, time added, an so on.

 

Also there is a button to 'create appointment' for the customer. Click the button, a form appear, select a day and time the click submit. It all works fine.

 

The problem is once the appointment is booked I dont how to remove the customer from the list on the customer.php page. So am looking for something like what they have on e-commerce sites e.g a customer buys an item and that item is no longer available for another customer.

 

Please guys am calling for your expertise, any ideas, inputs or suggestions you may have are more than welcome.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/236215-removing-objects-from-a-list/
Share on other sites

Thanks for you reply fugix.

 

Yeah I think you are right, if customer appointment booked remove else display..somethang like that.

 

The problem is I havent designed a system like this before so am not sure how you would code it.

 

I am using a simple php form and once the user fills in the date and time and hit submit the details are store in the database, please see my php code below (its quite long that why I was not sure in I should send it but I guess you can copy and paste if that helps).

 

Apologies if its too long..let me know if you need more info.

 

         

<form action="customers.php?id=' . $pageid . '" id="form2" name="form2" method="POST" target="_self" onsubmit="return validate_form ( );">
						<table>
						<tr><td><input type="hidden" name="username" value="' . $manager . '" readonly/></td></tr>
						<tr><td><input type="hidden" name="c_name" value="' . $c_name . '" readonly/></td></tr>
						<tr><td><input type="hidden" name="c_address" value="' . $c_address . '" readonly/></td></tr>
						<tr><td><input type="hidden" name="c_city" value="' . $c_city . '" readonly/></td></tr>
						<tr><td><input type="hidden" name="c_id" value="' . $pageid . '" readonly/></td></tr>
						<tr><td><input type="hidden" name="c_postcode" value="' . $c_postcode . '" readonly/></td></tr>
						<tr><td><input type="hidden" name="c_telephone" value="' . $c_telephone . '" readonly/></td></tr>
						<tr><td><input type="hidden" name="c_email" value="' . $c_email . '" readonly/></td></tr>
						<tr><td><input type="hidden" name="c_preference" value="' . $c_preference . '" readonly/></td></tr>

						<tr><td><strong>Appointment Time</strong>     <select name="b_time">
						<option></option><option value="1pm">1pm</option><option value="2pm">2pm</option>
						<option value="3pm">3pm</option><option value="4pm">4pm</option><option value="5pm">5pm</option><option value="6pm">6pm</option>			                            <option value="7pm">7pm</option><option value="8pm">8pm</option></select></td></tr>
						<tr><td><strong>Appointment Date</strong> <input type="text" name="b_date"/></td></tr>

						<tr><td colspan="2"><input type="submit" name="submit" value="Book Appointment"></td></tr>
						</table>
						</form>'
if(isset($_POST['submit'])) {
$manager= mysql_real_escape_string($_POST['username']);
$c_name = mysql_real_escape_string($_POST['c_name']);
$c_address = mysql_real_escape_string($_POST['c_address']);
$c_city = mysql_real_escape_string($_POST['c_city']);
$pageid = mysql_real_escape_string($_POST['c_id']);
$c_postcode = mysql_real_escape_string($_POST['c_postcode']);
$c_telephone = mysql_real_escape_string($_POST['c_telephone']);
$c_email = mysql_real_escape_string($_POST['c_email']);
$salesman = mysql_real_escape_string($_POST['salesman']);
$b_date = mysql_real_escape_string($_POST['b_date']);
$b_time = mysql_real_escape_string($_POST['b_time']);
$c_preference= mysql_real_escape_string($_POST['c_preference']);
$submit= mysql_real_escape_string($_POST['submit']);

if($submit)
{
if($manager)
{
$insert=mysql_query("INSERT INTO book_appointment (username,c_name,c_address,c_city,c_id,c_postcode,c_telephone,c_email,salesman,b_date,b_time,c_preference,b_datestamp) VALUES ('$manager','$c_name','$c_address','$c_city','$pageid','$c_postcode','$c_telephone','$c_email','$salesman','$b_date','$b_time','$c_preference', now()) ");
}
else
{
echo "please fill out all fields";
}
}
 header("location: customers.php?id=$check_id"); 
}

sure fugix

 



	$getquery=mysql_query("SELECT * FROM book_appointment WHERE c_id='$check_id'");
	while($rows=mysql_fetch_assoc($getquery))
	{
	$b_id = $rows['b_id']; //appointment id
	$manager = $rows['username']; // the admin who booked the app. i.e. me
	$b_date = $rows['b_date']; //app date
	$b_time = $rows['b_time']; //app time
	$c_id = $row["c_id"]; //customers id
	$b_datestamp = strftime("%b %d, %Y - %X", strtotime($rows["b_datestamp"]));	
	echo '<p></p><strong><a href="viewdiary.php">Appointment Booked</a></strong> for <strong>' . $b_date . '</strong> - ' . $b_time . ' - by:<strong>' . $manager . ' </strong> on <em>' . $b_datestamp . '</em> </p>'
	;}

 

Let me know if its ok.

 

Thanks

you know what you could do, you could add another field called "booked" or something like that, and when a customer books a client, the value of that field you could make be 1, or yes using an update query...and set the default value to 0, or no. then you can set your display query to this

$getquery=mysql_query("SELECT * FROM book_appointment WHERE c_id='$check_id' and booked='0'");

this would make it so it will only show people that arent booked...make sense?

the query that i provided above should be what you are looking for...whatever query you are using to output the names of the people that customers can book is the table that you will want to add this to. I believe that its this one

$getquery=mysql_query("SELECT * FROM book_appointment WHERE c_id='$check_id' and booked='0'");

now, you will set the default value of that field to 0, meaning that they are not booked yet. Then when a customer books one of the people, you will have an update query similar to this

$getquery=mysql_query("update book_appointment set booked='1' WHERE persons_id='id'");

now granted i dont know what your fields are called, that is just an example...any further questions let me know

Genius :D I follow!

 

So what i should be doing is set it to 0 for example then update it to 1

 

Genius! will try it out.

 

I've finished work now..gotta beat the traffic.

 

If your online tonight or tommorow I let u kno how I get on.

 

Thanks buddy u've been a revelation.

 

speak 2 u soon

Genius :D I follow!

 

So what i should be doing is set it to 0 for example then update it to 1

 

Genius! will try it out.

 

I've finished work now..gotta beat the traffic.

 

If your online tonight or tommorow I let u kno how I get on.

 

Thanks buddy u've been a revelation.

 

speak 2 u soon

no problem at all, if you have any further questions dont hesitate to ask

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.