kamal213 Posted May 12, 2011 Share Posted May 12, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/236215-removing-objects-from-a-list/ Share on other sites More sharing options...
fugix Posted May 12, 2011 Share Posted May 12, 2011 sounds like you could incorporate a simple if,else statement to check if the customer is booked or not..can you show us any code that you have done thus far Quote Link to comment https://forums.phpfreaks.com/topic/236215-removing-objects-from-a-list/#findComment-1214504 Share on other sites More sharing options...
kamal213 Posted May 12, 2011 Author Share Posted May 12, 2011 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"); } Quote Link to comment https://forums.phpfreaks.com/topic/236215-removing-objects-from-a-list/#findComment-1214514 Share on other sites More sharing options...
Maq Posted May 12, 2011 Share Posted May 12, 2011 In the future, please place tags around your code. Quote Link to comment https://forums.phpfreaks.com/topic/236215-removing-objects-from-a-list/#findComment-1214518 Share on other sites More sharing options...
kamal213 Posted May 12, 2011 Author Share Posted May 12, 2011 No problem Maq. I'm not sure wat it does but I will check it out. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/236215-removing-objects-from-a-list/#findComment-1214522 Share on other sites More sharing options...
fugix Posted May 12, 2011 Share Posted May 12, 2011 can you show me the code where the data is displayed please Quote Link to comment https://forums.phpfreaks.com/topic/236215-removing-objects-from-a-list/#findComment-1214528 Share on other sites More sharing options...
kamal213 Posted May 12, 2011 Author Share Posted May 12, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/236215-removing-objects-from-a-list/#findComment-1214532 Share on other sites More sharing options...
fugix Posted May 12, 2011 Share Posted May 12, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/236215-removing-objects-from-a-list/#findComment-1214536 Share on other sites More sharing options...
kamal213 Posted May 12, 2011 Author Share Posted May 12, 2011 Yeah..am with you. Does it mean I have to create field in my table called booked? Do I need an if and else statement? could you give a simple example of how it would look like. Thanks alot fugix Quote Link to comment https://forums.phpfreaks.com/topic/236215-removing-objects-from-a-list/#findComment-1214537 Share on other sites More sharing options...
fugix Posted May 12, 2011 Share Posted May 12, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/236215-removing-objects-from-a-list/#findComment-1214543 Share on other sites More sharing options...
kamal213 Posted May 12, 2011 Author Share Posted May 12, 2011 Genius 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 Quote Link to comment https://forums.phpfreaks.com/topic/236215-removing-objects-from-a-list/#findComment-1214545 Share on other sites More sharing options...
fugix Posted May 12, 2011 Share Posted May 12, 2011 Genius 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 Quote Link to comment https://forums.phpfreaks.com/topic/236215-removing-objects-from-a-list/#findComment-1214552 Share on other sites More sharing options...
kamal213 Posted May 13, 2011 Author Share Posted May 13, 2011 Thanks alot fugix for your time and effort. Problem solved!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/236215-removing-objects-from-a-list/#findComment-1215021 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.