PDA

View Full Version : frustration with multipul results!


phence
09-06-2002, 08:00 PM
I am trying to get this query to display multipul results.

this is the error:
-------------------------------------------------------------------
Query SELECT * FROM listings WHERE MATCH trading AGAINST ('') returned no results.
-------------------------------------------------------------------

Also i have just noticed, no mater what the '$searchValue' is as long as there is only one item in the database it displays that result, no matter if it matched the search value or not.

And if there is more than one lising in the database, no matter the content, it displays the error msg above also.

I have been gouging out my eyes fro the past week in a half...

heres the code:

PHP SEARCH CODE
-----------------------------------

<?php
// singleSearch.php: Search for_ column, and compare to user input, display results.

include 'error.inc';
include 'db.inc';
//----------------------------------------------------------------------------------------
//connect to the database

if(!($connection = @ mysql_pconnect($hostname, $username, $password)))
die("Could Not Connect to database");
if (!mysql_select_db($databaseName, $connection))
showerror();

//-----------------------------------------------------------------------------------------

// get user search input
$searchValue = $HTTP_POST_VARS["searchValue"];
trim($searchValue);


// Build a query:
$query = "SELECT * FROM listings WHERE MATCH trading AGAINST ('$searchValue')";

// Run the query. If the query fails, it won't return a result set identifier:
$result = mysql_query($query);

if(!$result) {
echo "Query $query failed.";

// If the query failed, MySQL is usually friendly enough to offer a reason why:
echo mysql_error();
} else {
// Just because a query executed succussfully doesn't necessarily mean there are rows in the result set.
// So test the number of rows in the result set:
if(!mysql_num_rows($result)) {
echo "Query $query returned no results.";
} else {
while($data = mysql_fetch_array($result)) {
// process the data array for each row in the result set here...
// Get vars
$trading = $data["trading"];
$for_ = $data["for_"];
$wac_1 = $data["wac_1"];
$wac_2 = $data["wac_2"];
$enter_time = $data["enter_time"];
$overdue_time = $data["overdue_time"];
$user_id = $row["user_id"];

// find time left
// Get the number of seconds:
$seconds = $overdue_time - time();
// the number of whole days is the number of seconds / 86400:
$days = (int)($seconds / (60 * 60 * 24));
// get any remainder:
$r = (int)($seconds % (60 * 60 * 24));
if($r) {
// the number of hours is the remainder divided by 3600:
$hours = (int)($r / (60 * 60));
$r = (int)($r % (60 * 60));
if($r) {
$minutes = (int)($r / 60);
$secs = (int)($r % 60);
}
}
$time_left = date(d, $days) . " days " . date(h, $hours) . " hours " . date(i, $minutes) . " mins " . date(s, $secs) . " secs";

// make over_duetime a user format

// Line contents for each listing
$line1 = "<br><br>$user_id : Wants To Trade $trading For $for_<br>";

// if wac's have no value then display line
if (!(empty($wac_1)) && (!(empty($wac_2)))){
$line2 = "Will also Consider Trading for: $wac_1; $wac_2;<br>";
}
elseif (empty($wac_1) && empty($wac_2)){
$line2 = "$user_id, is not willing to trade for anything else";
}

$line3 = "<a href=\"listing.php\">View Complete Listing</a> Listing ends in $time_left on " . date('m/d/Y', $overdue_time);

// start a <table>, print one listing; Organize results to fit page & display results
echo $header;
echo $ads;
echo "\n<table>\n<tr>" . "\n<tr>" . "\n\t<td>" . $line1 . " </td>
\n<tr>" . "\n<tr>" . "\n\t<td>" . $line2 . " </td>
\n<tr>" . "\n<tr>" . "\n\t<td>" . $line3 . " </td>";
echo $footer;
}
}
}

//end while loop

?>


HTML FORM CODE
------------------------------
<form name="search" method="post" action="singleSearch.php">
Search:
<input type="text" name="searchValue" >
<input type="submit" name="Submit" value="Submit">
</form>

All Help is appreciated!!!