First of all i'd like to say hello to everybody.
I've been working upon a script and i seem to be facing a problem with a mysql_query.
Here it goes:
I have 2 tables on my data base and there are some html forms through which tha data is entered in the tables. Also i got one html script as a search, where there are some radio buttons, with the same name and different values that allow the user to pick for which field he's going to give the critiria for searching.
On the php script that handles the data i have written the above:
<html>
<?PHP
$critiria=$_POST['critiria'];
$search=$_POST['search'];
$con=mysql_connect('localhost','root','');
mysql_select_db('test',$con);
if($critiria=="epitheto_iatrou"){
$sql="SELECT * FROM doctors WHERE epitheto='$critiria'";
$result=mysql_query($sql,$con) or die(mysql_error());
while ($newarray=mysql_fetch_array($result)){
echo "Epitheto: $newarray[epitheto] <br>";
echo "Eidikotita: $newarray[eidikotita]<br>";
echo "Misthos: $newarray[misthos]<br>";
}
}
else if($critiria=="eidikotita"){
$sql="SELECT * FROM doctors WHERE eidikotita='$eidikotita'";
$result=mysql_query($sql,$con) or die(mysql_error());
while ($newarray=mysql_fetch_array($result)){
echo "Epitheto: $newarray[epitheto] <br>";
echo "Eidikotita: $newarray[eidikotita]<br>";
echo "Misthos: $newarray[misthos]<br>";
}
}
else if($critiria=="epitheto_patient"){
$sql="SELECT * FROM patients WHERE epitheto='$critiria'";
$result=mysql_query($sql,$con) or die(mysql_error());
while ($newarray=mysql_fetch_array($result)){
echo "Epitheto: $newarray[epitheto] <br>";
echo "Onoma: $newarray[onoma]<br>";
echo "id_doctor: $newarray[id_doctor]<br>";
echo "date: $newarray[date]<br>";
echo "poli: $newarray[poli]<br>";
}
}
else if ($critiria='poli'){
$sql="SELECT * FROM patients WHERE poli='$critiria'";
$result=mysql_query($sql,$con) or die(mysql_error());
while ($newarray=mysql_fetch_array($result)){
echo "Epitheto: $newarray[epitheto] <br>";
echo "Onoma: $newarray[onoma]<br>";
echo "id_doctor: $newarray[id_doctor]<br>";
echo "date: $newarray[date]<br>";
echo "poli: $newarray[poli]<br>";
}
}
else if ($critiria='date'){
$sql="SELECT * FROM patients WHERE date='$critiria'";
$result=mysql_query($sql,$con) or die(mysql_error());
while ($newarray=mysql_fetch_array($result)){
echo "Epitheto: $newarray[epitheto] <br>";
echo "Onoma: $newarray[onoma]<br>";
echo "id_doctor: $newarray[id_doctor]<br>";
echo "date: $newarray[date]<br>";
echo "poli: $newarray[poli]<br>";
}
}
?>
</html>
This script returns a blanc page. I have tried the first if($critiria=="epitheto_iatrou"){
and without the if sentence, within which the mysql_query is created, the query returns the correct data.
Is there any problem with the queries if their inclosed within the commands that are to be executed in an if sentence?
Can you help me out?????
Best regards