Jump to content

fernando1980

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

fernando1980's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. here is the content of the showroom.php: <?php $mtime = microtime(); $mtime = explode(' ', $mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; ?> <?php $var = $_GET['make'] ; $model = $_GET['model']; $priceOption = $_GET['price']; $body = $_GET['body'] ; $s = $_GET['s'] ; $trimmed = trim($var); $limit=5; if (!isset($var)) { $var = "All"; } $con = mysql_connect('host', 'username', 'password'); if (!$con) die('Could not connect: ' . mysql_error()); mysql_select_db("database", $con); if ($body != ""){ $var = $body; $query = "select * from vehicle WHERE body LIKE '". $var."'"; } elseif($var == "All" || $var == "Make") { $query = "select * from vehicle"; } else { $query = "select * from vehicle WHERE Model LIKE '%" . $model . "%'" . "AND Make LIKE '" . $var . "'"; } $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); if (empty($s)) { $s=0; } $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime); $result_2 = mysql_query("show table status from bdm like 'vehicle'"); if (!$result) { echo mysql_error(); exit(); } $info = mysql_fetch_array($result_2); echo("<li class=comments>"); echo "<ul class=search_time><li class=user> <strong>Search for:</strong> " . $var . " <strong>Results:</strong> $numrows</li>"; echo "<li class=date> <strong>Query took: </strong>" . substr($totaltime, 0, 6). " seconds</li></ul></li>"; $count = 1 + $s ; if ($numrows == 0) { echo "<p><br>Our online database doesn't currently have the listing of the vehicle you're looking for. Please visit or call our showroom for a complete selection and further assistance.<br><br> <strong>Remember</strong> if you really want this vehicle, new or pre-owned, you can ask us to find out for you at <strong>no obligation</strong>!</p><br>"; } echo "<div id=tables>"; echo("<table class=header>"); echo("<tr class=search_results><td class=user>Vehicle</td><td class=user style=\"width:120px\">Make</td><td class=user style=\"width:130px\">Model</td><td class=user style=\"width:70px\">Year</td><td class=user style=\"width:120px\">Transmission</td><td class=user style=\"width:70px\">Fuel</td><td class=user style=\"width:100px\">Mileage</td><td class=user style=\"width:100px\">Price</td></tr>"); $row_count = 0; while ($row = mysql_fetch_array($result)) { $row_count += 1; if (($limit - $row_count) % 2 == 0) $row_format = "bg1"; else $row_format = "bg2"; echo("<tr>"); echo "<td class=gallery_sold_s><a href=\"display.php?make=" . $row['Make'] . "&model=" . $row['Model'] . "&year=" . $row['Year'] . "\"><img src=../cars/" . $row["ImageSmall"] . " width=140 height=75 border=0 /></a>"; if ($row['Availability'] == "Sold") echo "<span></span><a href=\"display.php?make=" . $row['Make'] . "&model=" . $row['Model'] . "&year=" . $row['Year'] . "&s=" . $s . "\"></a></td>"; echo("<td class=".$row_format.">" . $row["Make"] . "</td><td class=".$row_format.">" . $row["Model"] . "</td><td class=".$row_format.">" . $row["Year"] . "</td><td class=".$row_format.">" . $row["Transmission"] . "</td><td class=".$row_format.">" . $row["Fuel"] . "</td><td class=".$row_format.">" . $row["Mileage"] . " Km</td><td class=".$row_format.">R" . $row["Price"] . "</td>"); echo("</tr>"); } echo("</table>"); $currPage = (($s/$limit) + 1); echo("<table class=cont cellpadding=0 cellspacing=0><tr><td>"); //Link to other results if ($s>=1) { $prevs=($s-$limit); if ($body == ""){ print "<p> <a href=\"$PHP_SELF?s=$prevs&make=$var\"><< Prev</a></p>"; } else print "<p> <a href=\"$PHP_SELF?s=$prevs&body=$var\"><< Prev</a></p>"; echo "</td>"; } $pages=intval($numrows/$limit); if ($numrows%$limit) { $pages++; } if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { $news=$s + $limit; echo "<td>"; if ($body == ""){ echo "<p style=\"font-weight:bold\"> <a href=\"$PHP_SELF?s=$news&make=$var\">Next >></a> "; } else echo "<p style=\"font-weight:bold\"> <a href=\"$PHP_SELF?s=$news&body=$var\">Next >></a> "; echo "</td>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<td style=\"font-weight:bold\">"; echo " Displaying $b - $a of $numrows results</p>"; echo "</td>"; echo("<tr></table><br>"); echo "</div>"; ?>
  2. I'm doing a site for a used vehicles company. I have a "searchbar" with the following select options: the first one is to search per vehicle manufacturer (ex. BMW). The second one is for a price range (ex. any - $1 000 000). the third is per mileage (ex. any - 150 000). and the last one is per model (ex. 320). All of them are structured as drop-down selectors except for the last one "model" which is has a input type text. Here is what I struggle with... When I choose a manufacturer and click search then I get the desired results. But as-soon as I choose a value from the price or mileage or model I get all the values from the manufacturer, but it doesn't filter what I have chosen. Can you please help me.... Thank you Here is the code for the searchbar.php: <?php ?> <form name="searchForm" action="showroom.php" method="GET" class="search"> <table cellpadding="0" cellspacing="0"> <tr class="search_bar"> <td><b>Search</b></td> <td><select name="make"> <?php do { ?><option value="<?php echo $row_make['Make']?>"<?php if (!(strcmp($row_make['Make'], $row_make['Make']))) {echo "selected=\"selected\"";} ?>> <?php echo $row_make['Make']?></option> <?php } while ($row_make = mysql_fetch_assoc($make)); $rows = mysql_num_rows($make); if($rows > 0) { mysql_data_seek($make, 0); $row_make = mysql_fetch_assoc($make); } ?> </select> </td> <td><select style="height:20px;" name="price"> <option>Price</option> <option value="">Any</option> <option value="5000">R5,000 </option> <option value="10000">R10,000 </option> <option value="15000">R15,000 </option> <option value="20000">R20,000 </option> <option value="25000">R25,000 </option> <option value="30000">R30,000 </option> <option value="35000">R35,000 </option> <option value="40000">R40,000 </option> <option value="45000">R45,000 </option> <option value="50000">R50,000 </option> <option value="55000">R55,000 </option> <option value="60000">R60,000 </option> <option value="65000">R65,000 </option> <option value="70000">R70,000 </option> <option value="75000">R75,000 </option> <option value="80000">R80,000 </option> <option value="85000">R85,000 </option> <option value="90000">R90,000 </option> <option value="95000">R95,000 </option> <option value="100000">R100,000 </option> <option value="125000">R125,000 </option> <option value="150000">R150,000 </option> <option value="175000">R175,000 </option> <option value="200000">R200,000 </option> <option value="225000">R225,000 </option> <option value="250000">R250,000 </option> <option value="275000">R275,000 </option> <option value="300000">R300,000 </option> <option value="325000">R325,000 </option> <option value="350000">R350,000 </option> <option value="375000">R375,000 </option> <option value="400000">R400,000 </option> <option value="425000">R425,000 </option> <option value="450000">R450,000 </option> <option value="475000">R475,000 </option> <option value="500000">R500,000 </option> <option value="600000">R600,000 </option> <option value="700000">R700,000 </option> <option value="800000">R800,000 </option> <option value="900000">R900,000 </option> <option value="1000000">R1,000,000 </option> </select> </td> <td><select style="height:20px;" name="mileage"> <option>Mileage</option> <option value="0_10000">0-10 000 km</option> <option value="10001_20000">10 001-20 000 km</option> <option value="20001_30000">20 001-30 000 km</option> <option value="30001_40000">30 001-40 000 km</option> <option value="40001_50000">40 001-50 000 km</option> <option value="50001_60000">50 001-60 000 km</option> <option value="60001_70000">60 001-70 000 km</option> <option value="70001_80000">70 001-80 000 km</option> <option value="80001_90000">80 001-90 000 km</option> <option value="90001_100000">90 001-100 000 km</option> <option value="100001_110000">100 001-110 000 km</option> <option value="110001_120000">110 001-120 000 km</option> <option value="120001">120 000km and above</option> </select></td> <td align="right"><b>Model:</b></td> <td><input type="text" name="model" /></td> <td><input type="submit" value="Search" /></td> </tr> </table> </form>
  3. Hello to all my fellow coders.... hope to help and get help. Thank you,
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.