Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I'm currently trying to order by table between two given values on my HTML page. But I'm getting some errors, and I cannot find out why..

Anyone know what I'm doing wrong?

Notice: Undefined offset: 10 in D:\Program Files\xampp\htdocs\Week 5\verwerken.php on line 8

Notice: Undefined offset: 50 in D:\Program Files\xampp\htdocs\Week 5\verwerken.php on line 9


HTML Page:
XML
<form action="verwerken.php" method="post">
Kies een minimumprijs:
 <select>
    <option value="10" name="min">10 euro</option>
    <option value="30" name="min">30 euro</option>
    <option value="50" name="min">50 euro</option>
    <option value="100" name="min">100 euro</option>
    <option value="500" name="min">500 euro</option>
</select>

<br>Kies een maximumprijs:
 <select>
    <option value="10" name="max">10 euro</option>
    <option value="30" name="max">30 euro</option>
    <option value="50" name="max">50 euro</option>
    <option value="100" name="max">100 euro</option>
    <option value="500" name="max">500 euro</option>
</select>

<br><input type="submit" name="submit" value="Geef overzicht artikelen"><br><br>
</form>



PHP PAGE:
XML
<?php
$con=mysqli_connect("localhost","root","","mysql");
// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$min = mysqli_real_escape_string($con, $_POST['min']);
$max = mysqli_real_escape_string($con, $_POST['max']);

$result = mysqli_query($con,"SELECT * FROM artikel
WHERE Verkoopprijs
BETWEEN $min AND $max
ORDER BY Verkoopprijs");


echo "<table border='1'>
<tr>
<th>Artikelnr</th>
<th>Verkoopprijs</th>
</tr>";

while($row = mysqli_fetch_array($result)) {
  echo "<tr>";
  echo "<td>" . $row['Artikelnr'] . "</td>";
  echo "<td>" . $row['Verkoopprijs'] . "</td>";
  echo "</tr>";
}

echo "</table>";

mysqli_close($con);
?>
Posted
Comments
Herman<T>.Instance 8-Oct-14 7:44am    
It seems like Name is not a valid attribute. See here
Member 11137921 8-Oct-14 7:52am    
That's all I needed, thanks a lot.

For future people who ran into the same mistake as me:

<form action="verwerken.php" method="post">
Kies een minimumprijs:
<select name="min">
<option value="10">10 euro</option>
<option value="30">30 euro</option>
<option value="50">50 euro</option>
<option value="100">100 euro</option>
<option value="500">500 euro</option>
</select>

<br>Kies een maximumprijs:
<select name="max">
<option value="10">10 euro</option>
<option value="30">30 euro</option>
<option value="50">50 euro</option>
<option value="100">100 euro</option>
<option value="500">500 euro</option>
</select>

<br><input type="submit" name="submit" value="Geef overzicht artikelen"><br><br>
</form>
W Balboos, GHB 8-Oct-14 7:59am    
Let me give you a bit of a hint: use $_REQUEST[] instead of $_POST[] and $_GET[] as it is good for both types.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900