php - Select from MySQL based on HTML form -


a html form contain 4 fields (first name, last name, mobile , attendid). search form find record in attend mysql table. of these fields optional intention being more fields enter in form, narrowing down search. know issue first sql not taking account variables.

the second bit confuse in more... results echoed in table, last field of echoed table should contain data selected second sql statement data in table.

sorry if vague have no idea how approach this, been looking @ long!

thanks help!

<html> <body> <table> <table border="1"> <tr><th>attendeeid</th><th>wristband</th><th>firstname</th><th>lastname</th><th>telephone </th><th>mobile</th><th>address 1</th><th>address 2</th><th>town</th><th>postcode</th><th> e-mail</th><th>medical notes</th><th>last reader tap</th></tr>  <?php  include "checkmysqlconnect.php";  $firstname = $_post['firstname']; $lastname = $_post['lastname']; $mobile = $_post['mobile']; $attendid = $_post['attendid']; $search = $_post['search'];  if ($search == "search") {     if ($firstname == '' , $lastname == '' , $attendid == '' , $mobile == '') {         header("location: searchattendform.php?result=1");         $error = true;     }      if ($error != true) {  $sql = "select * `attend` `firstname` = '".$firstname."' or `lastname` = '".$lastname."' or `attendid` = '".$attendid."' or `mobile` = '".$mobile."'"; $query = mysql_query($sql); $count = mysql_num_rows($query);  $sql1 = "select `readerid` `taps` `attendid` = '".$attendid."' order `time` desc limit 1"; $query1 = mysql_query($sql1);  if ($count > 1) {     echo "more 1 matching attendee. entering more details narrow down results."; while($value = mysql_fetch_assoc($query)); while($value1 = mysql_fetch_assoc($query1)) {        echo "<tr><td>".$value['attendid']."</td><td>".$value['wristband']."</td><td>".$value['firstname'].     "</td><td>".$value['lastname']."</td><td>".$value['telephone']."</td><td>".$value['mobile']."</td><td>".$value['address1'].     "</td><td>".$value['address2']."</td><td>".$value['town']."</td><td>".$value['postcode']."</td><td>".$value['email'].     "</td><td>".$value['medical']."</td><td>".$value1['readerid']."</td></tr>"; } } else {     if ($count == 0) {         header("location: searchattendform.php?result=2"); } else {     if ($count == 1) {         ($value = mysql_fetch_assoc($query));             echo "<tr><td>".$value['attendid']."</td><td>".$value['wristband']."</td><td>".$value['firstname'].         "</td><td>".$value['lastname']."</td><td>".$value['telephone']."</td><td>".$value['mobile']."</td><td>".$value['address1'].         "</td><td>".$value['address2']."</td><td>".$value['town']."</td><td>".$value['postcode']."</td><td>".$value['email'].         "</td><td>".$value['medical']."</td><td>".$value1['readerid']."</td></tr>";     } else {         echo "there issue searching attendees. please contact sofia admin.";     } } } } }  ?>  </table> </body> </html> 

take @ outer loop while($value = mysql_fetch_assoc($query));.

shouldn´t not while($value = mysql_fetch_assoc($query)){?


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -