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
https://forums.phpfreaks.com/topic/7008-code-not-working-please-help/
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]


[!--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]

Archived

This topic is now archived and is closed to further replies.

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