Jump to content

rj300

New Members
  • Posts

    2
  • Joined

  • Last visited

rj300's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks, that worked!!!
  2. Hi guys I'm trying to print the results from a query but it keeps printing "No Result" but it should print one query result. Can someone please help? My code is as follows <form action= "search.php" method="post"> <tr> <td>Location:</td><td> <input type="text" name="loc" maxlength="20"/> </td> </tr> <tr> <td>Date:</td><td> <input type="text" name="date" maxlength="20"/></td> </tr> <tr> <td>Category: </td><td><input type="text" name="category" maxlength="20"/></td> </tr> <tr> <td><input type="submit" value="Submit"/></td> </tr> </form> <?php $username="root"; $password=""; $database='calendar'; $get_location=mysql_real_escape_string($_POST['loc']); $get_doe=mysql_real_escape_string($_POST['date']); $get_category=mysql_real_escape_string($_POST['category']); mysql_connect('localhost',$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query=mysql_query("SELECT f.EVENT, f.LOCATION, f.DOE, f.CATEGORY, f.PRICE, (( ( f.NUMOFLOC * ( Log(f.LOGLOC) ) ) + ( f.NUMOFDOE * ( Log(f.LOGDOE) ) )+ (f.NUMOFCAT * (Log(f.LOGCAT))))) AS FINALRANK FROM (SELECT E.EVENT,ED.LOCATION, ED.DOE,ED.CATEGORY,ED.PRICE, ((ROUND( ED.NUMOFSET / ED.NUMOFLOC ))) AS LOGLOC, ((ROUND( ED.NUMOFSET / ED.NUMOFDOE ))) AS LOGDOE, ((ROUND( ED.NUMOFSET / ED.NUMOFCAT ))) AS LOGCAT, ED.NUMOFLOC, ED.NUMOFDOE, ED.NUMOFCAT FROM EVENT E, EVENTDETAIL ED WHERE E.EVENTID = ED.EVENTID AND ED.LOCATION LIKE '".$get_location."' AND ED.CATEGORY LIKE '".$get_category."' AND ED.DOE LIKE '".$get_doe."') f ORDER BY FINALRANK DESC;"); $result=mysql_query($query); $num=mysql_num_rows($result); $i=0; if(!$num){ echo ("No Results"); } else{ echo '<table border ="0" width ="30" height="20">'; echo '<tr><th colspan ="7" align="middle"> Results</th> </tr>'; echo'<td>Rank</td> <td>Event</td> <td>Loc</td> <td>Date</td> <td>Price</td>'; while ($i < $num) { $eventid=mysql_result($result,$i,"EVENT"); $location=mysql_result($result,$i,"LOCATION"); $doe= mysql_result($result,$i,"DOE"); $price= mysql_result($result,$i,"PRICE"); echo '<tr>'; echo "<td> ".($i+1)."</td><td>$eventid</td><td>$location</td><td>$doe</td><td> $price </td>"; echo "<br>"; echo'</tr>'; echo"<br>"; $i++; } } ?> I think there is some problem when i inject the parameters into the query '$get_location' etc as it it not recognising it and going stright to the if(!$num) statement. Please help
×
×
  • 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.