php - searching for results by name with dates -
this question has answer here:
i have been working on awhile now. trying search name , dates. show results.
i need on part of coding.
$sql = mysql_query("select * info patient_name '".$search."' date_of_service between '".$from."' , '".$to."'");
i message
warning: mysql_fetch_assoc() expects parameter 1 resource, boolean given in c:\xampp\htdocs\xampp\prive_tc\testing2.php on line 40
my full code
<?php mysql_connect('localhost', 'root', ''); mysql_select_db('prive_ts'); $search = $_get['search_box']; $from = $_get['from']; // or $from = $_get['from']; $to = $_get['to']; // or $to = $_get['to']; $sql = mysql_query("select * info patient_name '".$search."' date_of_service between '".$from."' , '".$to."'"); ?> <!-- form --> <form name="search_form" method="get" action="#"> search: <input type="text" name="search_box" value="" /> dates : <input type="text" name="from" value=""/> : <input type="text" name="to" value=""/> <input type="submit" name="search" value="look patient ..."> </form> <!-- end --> <table width="70%" cellpadding="5" cellspace="5"> <tr> <td><strong>care provider</strong></td> <td><strong>patient name</strong></td> <td><strong>date of time</strong></td> <td><strong>time in</strong></td> <td><strong>time out</strong></td> <td><strong>remarks</strong></td> </tr> <?php while ($row = mysql_fetch_assoc($sql)){ ?> <tr> <td><?php echo $row['care_provider']; ?></td> <td><?php echo $row['patient_name']; ?></td> <td><?php echo $row['date_of_service']; ?></td> <td><?php echo $row['time_in']; ?></td> <td><?php echo $row['time_out']; ?></td> <td><?php echo $row['remarks']; ?></td> </tr> <?php } ?> </table>
you forgot =
equal sign on where
query clause:
$sql = mysql_query("select * info patient_name = '".$search."' , (date_of_service between '".$from."' , '".$to."')"); ^^ here ^^ here and/or
by way, shouldn't use mysql_
functions anymore. deprecated, , no longer maintained. should switch better extension mysqli or pdo , utilize prepared statements. not directly concatenate user input on statements.
Comments
Post a Comment