Jump to content

code not working please help


redarrow

Recommended Posts

Can you see why this part of my code not working from below please cheers.
[code]
//if there no result echo message using mysql_num_rows.
if (mysql_num_rows($result) == 0){
echo" sorry no results";
echo $link;
exit;
}
[/code]



[code]
<html>
<head>
<title> serch me</title>
<body>
<h2>Search result</h2>

<?
// link for user to go back to.
$link="<br><a href='http://xxxxxxxxxxxxxxxxx'>Please Search Agin</a>";


//trim name input box for spaces in input box.
$name=trim($fname);



//if name not there echo message.
if(!$name) {
echo"search result nothink sorry";
echo $link;
exit;
}



//connect to database for data result useing like and %wildcard
$db=mysql_connect("xxxx","xxxx","xxxx");
mysql_select_db("xxxx" , $db);
$query="select xxxxx from xxxx where xxxx like '%".$name."%'";
$result=mysql_query($query);


//if there no result echo message using mysql_num_rows.
if (mysql_num_rows($result) == 0){
echo" sorry no results";
echo $link;
exit;
}


//Fetch the data using asscote array if result there.
while($record=mysql_fetch_assoc($result)){
while(list($title,$data)=each($record)){
echo "<br>".$title.":".$data."<br>";
}
echo $link;
}
?>
[/code]
Link to comment
Share on other sites

how do you add a statement to the above

if the user dosent enter the exact word there is no results so the user can not just put an example r and get all.

i tried this way but dosent seem to work

[code]

if($name > 4 ) {

//go for it

}else{

echo "sorry no result";
echo $link;
exit;
}

[/code]



[code]

if($name == $result ) {

//go for it

}else{

echo "sorry no result";
echo $link;
exit;
}

[/code]


THIS IS THE PROPER WAY BUT DOSENT SEEM TO WORK ON HERE LOL
[code]

// GET THE LENTH OF NAME

$lenth=strlen($name);

//IF THE NAME LESS THEN 3 LETTERS ECHO MESSAGE.

if($lenth < 3) {

echo" sorry you must enter a larger name";

// ELSE RUN THE REST.

}else{

do somethink

}
[/code]
Link to comment
Share on other sites



[!--sizeo:4--][span style=\"font-size:14pt;line-height:100%\"][!--/sizeo--]solved [!--sizec--][/span][!--/sizec--]cheers

[code]
//if name not there echo message.
if(!$name) {
echo"search result nothink sorry";
echo $link;
exit;

}else{

//if type less then 2 letters echo message.
$lenth=strlen($name);
if($lenth <= 2) {
echo"Type a longer word!";
echo $link;
exit;
}
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.