I want to create drop down menu where I can sort my product by price. Now I am trying this version, maybe it's not best idea, but if you have better please show.
<h3>Mobilieji Telefonai</h3>
<form method="post" action="">
<select name="price">
<option value="prioritetas">Atsitiktinis</option>
<option value="kaina DESC">Kaina nuo mažiausios</option>
<option value="kaina ASC">Kaina nuo didžiausios</option>
</select>
<input type="submit" name="orderPrice" value="orderPrice" />
</form>
</div>
<?php
if (!isset($_GET['startrow']) or !is_numeric($_GET['startrow'])) {
$startrow = 0;
} else {
$startrow = (int)$_GET['startrow'];
}
$sort = @$_POST['price'];
$fetch = mysql_query("SELECT * FROM telefonai order by ".$sort." LIMIT $startrow, 15")or
die(mysql_error());
$fetch = mysql_query($query);
print mysql_error();
$num=Mysql_num_rows($fetch);
if($num>0)
{
echo "<table border=2 >";
echo "<tr><td>Telefono pavadinimas</td><td>Nuotrauka<td>Kaina</td> <td>Parduotuve</td><td>Nuoroda</td></tr>";
for($i=0;$i<$num;$i++)
{
$row=mysql_fetch_row($fetch);
echo "<tr>";
echo"<td>$row[1]</td>";
echo "<td> <img src=\"{$row[5]}\" width=75 height=75/> </td>";
echo"<td>$row[2] LT</td>";
echo"<td>$row[3]</td>";
echo "<td><a href=\"{$row[4]}\"><img src=\"".base_url()."images/parduotuve.png\" /></a></td>";
echo"</tr>";
}
echo"</table>";
}
echo '<a href="'.base_url().$this->uri->segment(1)."/".'?startrow='. ($startrow+5).'">Sekantis</a>';
$prev = $startrow - 5;
if ($prev >= 0)
echo '<a href="'.base_url().$this->uri->segment(1)."/".'?startrow='.$prev.'"> Buves</a>';
?>
</form>
</body>
</html>
<br>
Nothing Clicked, just opened page
after click sorting
also with sorting not working table pagination, but this I will try to fix later
need to correct code and I want to fix this error. Any idea how to fix this error?
$price
without defining it