Hey people, I just read over this topic and I've tried your solutions, but somehow my working php query bugs out trying to link the dropdown form to the Query of my db.
My code atm looks like this and fails to display anything atm, I can get the form & my database but as soon as I put in:
PHP Code:
if($_POST['value'] == '3300')) {
// query to get all Doe records
$query="SELECT * FROM $tabel WHERE LiszCode='3300'";
}
elseif($_POST['value'] == '3400') {
// query to get all Earl records
$query="SELECT * FROM $tabel WHERE LiszCode='3400'";
} else {
// query to get all records
$query="SELECT * FROM $tabel";
}
$sql = mysql_query($query);
I do not understand why, if anyone could help me out that would be great!
My full script should be this, although the problem lies in previous stated script (i think)
As you can see I already tried removing the variables from the dropdown into hardcoded answers but still no luck.
PHP Code:
<HTML>
<form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='post' name='form_filter'>
<select name="value">
<option value="" selected="selected">Kies uw zorgverzekeraar</option>
<option value="3300">VGZ</option>
<option value="3400">Unive</option>
</select>
<input type="submit" value='geef prijzen' />
</form>
</HTML>
<?php
//Variables
$username="******";
$password="******";
$database="prijzen";
$tabel="Tarief";
$value= $_POST["value"];
//connecting to database
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
//point where it goes wrong
if($_POST['value'] == '3300')) {
// query to get all Doe records
$query="SELECT * FROM $tabel WHERE LiszCode='3300'";
}
elseif($_POST['value'] == '3400') {
// query to get all Earl records
$query="SELECT * FROM $tabel WHERE LiszCode='3400'";
} else {
// query to get all records
$query="SELECT * FROM $tabel";
}
$sql = mysql_query($query);
//-end wrong
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
?>
<table border="1" cellspacing="4" cellpadding="6">
<tr><th colspan="4" align="center">Prijzentabel</th></tr>
<tr>
<th width="70px" align=right><font face="Arial, Helvetica, sans-serif">Prestatiecode</font></th>
<th><font face="Arial, Helvetica, sans-serif">Omschrijving</font></th>
<th width="70px"><font face="Arial, Helvetica, sans-serif">Kostprijs</font></th>
<th width="60px"><font face="Arial, Helvetica, sans-serif">Geldig t/m</font></th>
</tr>
<?php
$i=0;
while ($i < $num) {
$f2=mysql_result($result,$i,"Code");
$f3=mysql_result($result,$i,"Omschrijving");
$f4=mysql_result($result,$i,"Bedrag");
$f5=mysql_result($result,$i,"JaarGeldig");
?>
<tr>
<td align=right><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td>
<td align=right><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td>
<td align=right><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td>
<td align=center><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td>
</tr>
<?php
$i++;
}
?></TABLE>
Bookmarks