Jump to content

Beginner needs help....


philb
Go to solution Solved by Barand,

Recommended Posts

Please can anyone help with this? I want to print out my data from NOW for today and the next 3 days (4 days in total). Here's my code so far - which prints everything in the database...

 

$sql = "SELECT dt, people, c_fname, c_lname, c_phone, c_notes, code FROM restaurantbooking_bookings ORDER BY dt ASC";
$result = $conn->query($sql);
 
 
if ($result-> dt < DateTime.Now) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
       
  print '
  <div class="product_item">
   
  
  Date/Time: ' . $row["dt"]. ' - Pers: ' . $row["people"]. '  -  Name: ' . $row["c_fname"]. ' ' . $row["c_lname"]. ' <br/>  Tel: ' . $row["c_phone"]. '   -  VCode: ' . $row["code"].  ' <br/> Notes: ' . $row["c_notes"]. '<br/>';
    }
} else {
    print "0 results";

 

 

Thanks in advance :)

Link to comment
Share on other sites

assuming dt is a date field you just need to add a simple WHERE condition to your SQL

$sql = <<<SQL
SELECT 
  dt,
  people,
  c_fname,
  c_lname,
  c_phone,
  c_notes,
  code
FROM 
  restaurantbooking_bookings 
WHERE dt BETWEEN CURDATE() AND DATE_ADD(CURDATE() INTERVAL 3 DAY)
ORDER BY dt ASC
SQL;

Edit: Missed that you had posted Barand - damn support calls!  ::)

Edited by Muddy_Funster
Link to comment
Share on other sites

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.