Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Heres an example, ill leave you to do the query:</p> <pre><code>&lt;?php //Some pseudo data kinda as your receive it from your query $datafromSql = array( array('id'=&gt;1,'date'=&gt;1,'month'=&gt;1,'year'=&gt;2012,'theData'=&gt;'This is some data when the user select 1/1/2012'), array('id'=&gt;2,'date'=&gt;2,'month'=&gt;2,'year'=&gt;2012,'theData'=&gt;'This is some data when the user select 2/2/2012'), array('id'=&gt;3,'date'=&gt;3,'month'=&gt;3,'year'=&gt;2012,'theData'=&gt;'This is some data when the user select 3/3/2012'), ); //Super simple API to access the data if($_SERVER['REQUEST_METHOD']=='POST' &amp;&amp; isset($_SERVER['HTTP_X_REQUESTED_WITH']) &amp;&amp; strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest'){ header('Content-Type: text/html'); //pseudo code, really you would just format your query result $return=array(); foreach($datafromSql as $row){ //Select all from array which match select choice if($row['date']==$_POST['day'] || $row['month']==$_POST['month'] || $row['year']==$_POST['year']){ $return[]=$row['theData'].'&lt;br /&gt;'; } } //output, with a fancy horizontal rule echo implode('&lt;hr /&gt;',$return); die; }?&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt; &lt;script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js" charset="utf-8"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; function update(){ $.post('./&lt;?php echo basename(__FILE__)?&gt;', { day: $("#day").val(), month: $("#month").val(), year: $("#year").val() }, function(data) { $('#result').replaceWith('&lt;div id="result"&gt;&lt;h1&gt;The Result:&lt;/h1&gt;'+ data +'&lt;/div&gt;'); }); } $(document).ready(function(){ update(); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="dateform" &gt; &lt;p&gt;Select Date: &lt;select size="1" name="day" id="day" onChange="update()"&gt; &lt;?php foreach(range(1,31) as $i){echo '&lt;option value="'.$i.'"&gt;'.$i.'&lt;/option&gt;';} ?&gt; &lt;/select&gt; &lt;select size="1" name="month" id="month" onChange="update()"&gt; &lt;?php foreach(range(1,12) as $i){echo '&lt;option value="'.$i.'"&gt;'.$i.'&lt;/option&gt;';} ?&gt; &lt;/select&gt; &lt;select size="1" name="year" id="year" onChange="update()"&gt; &lt;?php foreach(range(2008,2012) as $i){echo '&lt;option value="'.$i.'"&gt;'.$i.'&lt;/option&gt;';} ?&gt; &lt;/select&gt; &lt;/p&gt; &lt;/form&gt; &lt;p id='result'&gt;&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    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.
    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