Jump to content

thara

Members
  • Posts

    604
  • Joined

Everything posted by thara

  1. @Barand, I can get a fetal error when I using above code. This is my updated code: if (isset($_POST['next-step'])) { $restaurantId = 2; $def_times = array('06:30:00', '10:30:00'); // default $sql = "INSERT INTO business_hours ( restaurant_id , day , open_time , close_time ) VALUES (?,?,?,?)"; $stmt = $mysqli->prepare($sql); $stmt->bind_param('iiss', $restaurantId, $dayNo, $openTime, $closeTime); foreach ($_POST['openclose'] as $dayNo => $times) { $dayNo = (int)$dayNo; if ($times[1]==-1) { // closed $times[1] = $times[2] = '00:00:00'; } elseif (empty(array_filter($times))) { $times = $def_times; // set the times to the stored defaults } else { $def_times = $times; // save the times as the default times } $openTime = $times[1]; $closeTime = $times[2]; $stmt->execute(); if ($times[3]!='') { $openTime = $times[3]; $closeTime = $times[4]; $stmt->execute(); } } } This is the error message: line 24 is $times = $def_times; // set the times to the stored defaults
  2. @Barand, I went on your logic. But I am confusing how to figure this out. I tried it something like this. foreach ( $_POST['openclose'] as $day => $time) { //echo "$day and $time<br>"; foreach ($time as $open => $close) { echo "$day - $open, $close<br>"; if($open == '-1') { } } } But, I am not sure how to create insert query for this and don't know how to insert "closed" day into mysql... Hope you may help me out. Thank you.
  3. @Barand, your solution is very flexibility. Great idea. Thank you very much. Can you kindly tell me how to process this HTML form and how to make INSERT query? Do I need to change my database structure? Thank you.
  4. Yes I understand what you have said. Actually I am assuming opening hours is same for everyday. If I use different hours I may use different way to do this, but at this time I need to do this by assuming opening hours is same. If its so, can you tell me how can I make the Insert query for this? Thank you.
  5. @Barand, Thank you for your info. Here I have attached an image to see you how I going to use these date in my website. http://www.tiikoni.com/tis/view/?id=570f668 And this is how I get these info from users http://www.tiikoni.com/tis/view/?id=3d00416 So, can you tell me what is the best way to this? Thank you.
  6. @Ch0cu3r, Thank you for your answer. But My question is I am getting two days from users, like Monday, Saturday with opening and closing time. So Now I need to insert into mysql all the records between this two days. Eg: Monday,9am,10pm Tuesday,9am,10pm Wednesday, 9am, 10am and until Saturday (To user secondly selected date)
  7. I'm working on a website involving local restaurants, and one thing I need to do is store hours of operation. This is how I get operating hours from business owners. // Sunday - Saturday 11AM - 6PM $_POST['from'], $_POST['to'], $_POST['opening_time'], $_POST['closing_time'] Then I need to store these operating hours in `MySql` like below format. - Sunday: 9am - 11pm - Monday: 9am - 11pm - Tuesday: 9am - 11pm - Wednesday: 9am - 11pm - Thursday: 9am - 11pm - Friday: 9am - 11pm - Saturday: 9am - 11pm This is how my mysql table looks like. CREATE TABLE business_hours ( id integer NOT NULL PRIMARY KEY, restaurant_id integer NOT NULL, day integer NOT NULL, open_time time, close_time time ) I am not sure How to do this in php. so can anybody pointed my to right direction here? Any idea would be greatly appreciated. Thank you.
  8. Larry Ullman's php, mysql books definitly helped me to learn php and mysql...I recomend those for all who are just start to learn php
  9. i have only used notepad++ yet... it seems good enough for me..
×
×
  • 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.