Jump to content


Photo

code not working please help


  • Please log in to reply
2 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 10 April 2006 - 10:23 AM

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



<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;
}
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 10 April 2006 - 10:59 AM

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


if($name > 4 ) {

//go for it

}else{

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





if($name == $result ) {

//go for it

}else{

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



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

// 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

}

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 10 April 2006 - 11:48 AM



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

//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;
}

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users