<?php $link = mysql_connect('localhost', 'username', 'password'); $sSql="select SPECIALITY_ID, SPECIALITY from speciality ORDER BY speciality"; $sSql1="select PREFER_ID, PREFER from prefer ORDER BY PREFER"; $result=mysql_db_query("dbase", $sSql, $link); $result1=mysql_db_query("dbase", $sSql1, $link);?> <select> <?php echo " <option value='-1'>...</option>\n"; while($row=@mysql_fetch_array($result, MYSQL_BOTH)) { echo " <option value='".$row['SPECIALITY_ID']."' >".$row['SPECIALITY']."</option>\n"; } ?> </select> <select> <?php echo " <option value='-1'>...</option>\n"; while($row1=@mysql_fetch_array($result1, MYSQL_BOTH)) { echo " <option value='".$row1['PREFER_ID']."' >".$row1['PREFER']."</option>\n"; } ?> </select> <button id='btnSubmit' value='clickOnMe'>Click</button><?php $sql="SELECT LNAME, FNAME, F_FNAME, ADDRESS, PHONE1, TK, prefer, sp.speciality FROM supplier s, prefer p, speciality sp WHERE s.speciality=sp.speciality_id AND s.municipa=p.PREFER_ID ORDER BY lname"; $result2=mysql_db_query("dbase", $sSql, $link); echo "result : ".$result."<br>"; while($row2=@mysql_fetch_array($result2)) {?> <table border='1'> <tr> <?php foreach($row2 AS $record) { ?> <td> <?php echo $record['LNAME']." ".$record['FNAME']." του ". $record['F_FNAME']; ?> </td> <td> <?php echo $record['ADDRESS']; ?> </td> <td> <?php echo $record['PHONE1']; ?> </td> <td> <?php echo $record['TK']; ?> </td> <td> <?php echo $record['prefer']; ?> </td> <td> <?php echo $record['speciality']; ?> </td> <?php } ?> </tr> </table><?php }mysql_close($link)?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>Untitled Document</title></head><body><?php $link = mysql_connect('localhost', 'username', 'password'); mysql_select_db ('dbase',$link); mysql_query("SET NAMES 'utf8'", $link); $q1="select SPECIALITY_ID, SPECIALITY from speciality ORDER BY speciality"; $q2="select PREFER_ID, PREFER from prefer ORDER BY PREFER"; $result=mysql_query($q1,$link); $result1=mysql_query($q2,$link); //$result=mysql_db_query("dbase", $sSql, $link); //$result1=mysql_db_query("dbase", $sSql1, $link);?><form method="post" action="doctors.php"> <select name="speciality"> <?php echo " <option value='-1'>...</option>\n"; while($row=@mysql_fetch_array($result, MYSQL_BOTH)) { echo " <option value='".$row['SPECIALITY_ID']."' >".$row['SPECIALITY']."</option>\n"; } ?> </select> <select name="nomos"> <?php echo " <option value='-1'>...</option>\n"; while($row1=@mysql_fetch_array($result1, MYSQL_BOTH)) { echo " <option value='".$row1['PREFER_ID']."' >".$row1['PREFER']."</option>\n"; } ?> </select> <input type="submit" name="search" value="Αναζήτηση" /> </form><?phpif(isset($_POST['search'])){ $nomos=trim($_POST['nomos']); $speciality=trim($_POST['speciality']); $sql="select * from supplier where speciality='$speciality'"; // echo '<br />Q'.$sql.'<br />';$result3=mysql_query($sql,$link);echo $result3;$output="<table border=\"1\"><tr><td>ΟΝΟΜΑΤΕΠΩΝΥΜΟ</td><td></td></tr>";while($data=mysql_fetch_array($result3,MYSQL_NUM)){$output.="<tr><td>".$data[1].$data[2]." ".$data[3]." ".$data[4]." ".$data[5]." ".$data[6]."</td></tr>"; }}$output.="</table>";echo $output;?></body></html>