ok so here is the code, this is for the search option on my site. However it only ever outputs: the else option. Whats wrong?

<html>
<head>
<link rel=stylesheet type=text/css href=style.css>
<title>
Search Results
</title>
</head>
<body>
<?php include("header.php"); ?>
<center>
<div class=indexboxlarge2>
<?php
SESSION_start();
include("dbcon.php");
$searchresult = $_POST['result'];
dbcon();
$name = str_replace(".", " ", $row["username"]);
$query1 = mysql_query("SELECT * FROM user_info WHERE 1_name LIKE '%{$searchresult}%' OR 2_name LIKE '%{$searchresult}%'OR username LIKE '%{$name}%'");
$total = mysql_num_rows($query1);
if ($total<0) {
while ($row = mysql_fetch_array($query1)) {
echo $row["1_name"];
echo " ";
echo $row["2_name"];
echo "<br>";
echo "<br>";
}
}

else
{
	echo "Sorry there results to display.";
}

?>
</div>
</center>
</body>
</html>

This is your fifth post here, use code tags. It is shouted at you at the very instant you try to post a comment. In the background of the text box, in the required reading to post on the forums and in the rules of the forums.
When you don't use code tags it makes the code extremely hard to read, thereby making your problem harder to solve. Most people just skip the post if there is no code tags and for good reason.

Member Avatar for diafol

Jakx - you posted this problem on another thread and then started a new one. What's going on??
Looks like this is your prob: if ($total<0) as it should be if ($total>0) AFAIK a the number of returned records from a query can't be less than 0.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.