How to make the price sorting start from 1 and not from 0 when outputting from a database
$sorting = $_GET["sort"]; switch ($sorting) { case 'price-asc' ; $sorting = 'targeting ASC'; $sort_name = 'Дешевле'; break; case 'price-desc'; $sorting = 'targeting DESC'; $sort_name = 'Дороже'; break; case 'darom'; $sorting = 'darom DESC'; $sort_name = 'Даром'; break; case 'obmen'; $sorting = 'obmen DESC'; $sort_name = 'Обмен'; break; case 'new'; $sorting = 'datatime DESC'; $sort_name = 'Новинки'; break; default: $sorting = 'products_id DESC'; $sort_name = 'Нет сортировки!'; break; }
<?php $result = mysql_query("SELECT * FROM table_products ORDER BY $sorting",$connect); if (mysql_num_rows($result)>0) { $row = mysql_fetch_array($result); do{ if ($row["imagesad"] != "" && file_exists("ph_main/".$row["imagesad"])) { $img_path = 'ph_main/'.$row["imagesad"]; $max_width = 114; $max_height = 114; list($width, $height) = getimagesize($img_path); $ratioh = $max_height/$height; $ratiow = $max_width/$width; $ratio = min($ratioh, $ratiow); $width = intval($ratio*$width); $height = intval($ratio*$height); }else { $img_path = "images/no-image.png"; $width = 110; $height = 200; } echo ' <li> <div class="block-images-grid"> <img src="'.$img_path.'" width="'.$width.'" height="'.$height.'"> </div> <p class="style-title-grid"><a href="">'.$row["title"].'</a></p> <ul class="reviews-and-counts-grid"> <li><img src="images/eye-icon.png"><p>0</p></li> <li><img src="images/comment-icon.png"><p>0</p></li> </ul> <p class="style-price-grid"><strong>'.(!empty($row["darom"]) ? $row["darom"] : (!empty($row["obmen"]) ? $row["obmen"] : $row["targeting"])).'</strong></p> <div class="mini-features"> <p>Город:'.$row["gorod"].'</p> <p id="datatime">Дата:'.$row["datatime"].'</p> </div> </li> '; } while ($row = mysql_fetch_array($result)); } ?>
where price>0
- MikeNULL
should be there ... .-. - D-side