Note that there are some explanatory texts on larger screens.

plurals
  1. POMySQL/PHP: Multiple AND/OR tags in SELECT from two tables
    primarykey
    data
    text
    <p>I've got two tables, <code>customer</code> and <code>reservations</code>. <code>customer</code> and <code>reservations</code> both contain a row called <code>customerID</code>. <code>reservations</code> contains two columns named resStart and resEnd that only have dates in them (YYYY-MM-DD, which is the exact format I'll be using to establish the $todaysdate variable.</p> <p>I'd like to join those two to produce a table with single column of <code>customerID</code> along with other info, but only if $todaysdate falls on or between two dates. Note: $todaysdate is established elsewhere in my documents as either a _GET from url (ie. day.php?date=2012-07-04) or if none is established, today's date with date('Y-m-d'). This part of the code is not where my problems are lying, I'm sure of that. <strong>I'm thinking it's a syntax error somewhere while defining the information in the mySql query.</strong> </p> <p>Here's what I'm working with. A little explanation: I'm wrapping PHP code around Javascript, and the goal here is to produce a separate DIV for each resStart. The Javascript is fetching offset variables to add to the CSS of each DIV, so each DIV is automatically placed relative to the equipment it's representing. </p> <pre><code>&lt;?php $getreservations = mysql_query(" SELECT * FROM customer LEFT JOIN reservations WHERE ( customer.customerID = reservations.customerID ) AND ($todaysdate = resStart OR $todaysdate &gt;= resStart AND $todaysdate &lt;= resEnd ) ") or die(mysql_error()); while( false !== ($row = mysql_fetch_assoc($getreservations))) { $nameLast = $row["nameLast"]; $nameFirst = $row["nameFirst"]; $customerID = $row["customerID"]; $equipID = $row["equipID"]; $resStart = $row["resStart"]; $resEnd = $row["resEnd"]; $timeStart = $row["timeStart"]; $timeEnd = $row["timeEnd"]; $result = strtotime($timeStart); $minute = date("i", $result ); $second = date("s",$result ); $hour = date("H", $result ); if(true) { ?&gt; &lt;script language='javascript'&gt; var left = $('#&lt;?php echo("$hour$minute");?&gt;').offset().left; var top = $('#&lt;?php echo $equipID;?&gt;').offset().top; $(document).ready(function() { $('#&lt;?php echo ("$customerID$equipID");?&gt;).css( { 'left': (pos.left + width) + 'px', 'top': (pos.top + top) + 'px' } ); } &lt;/script&gt; &lt;?php } echo ("&lt;div class='resContainer $customerID$equipID' id=$customerID$equipID&gt;$nameLast, $nameFirst&lt;/div&gt; "); } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload