NameSilo

Very basic search engine-help!

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
SpaceshipSpaceship
Watch
Impact
0
<form action="search1.php">
<input type="text" name="search">
<input type="submit" value="Search">
</form>

<?php

function main( $pic, $name, $type, $file, $description )
{
print "<img src=$pic><br><b>Name:</b> $name<br><b>Type:</b> $type<br><b>File-size:</b> ";
$findsize = filesize( "$file" );
$kbsize = $findsize / 128;
print "$kbsize KB<br><b>Added on:</b> ".date( "d M Y", filectime( $file ) )."<br><b>Description:</b> $description<p>";
}

if(!$search)
{
print "You didn't enter keywords to search for!<br>";
}
elseif ( $search == "something" or "something_else" )
{
main("Void.jpg", "Thing", "Logo", "Void.jpg", "Cool");
}
elseif ( $search == "another_thing" or "something" )
{
print "Another sentence<br>";
}
else
{
print "<b>$search</b> was not found on the server.<br>";
}

print "<br>Search tips  |  Click here for all files  |  Search the internet"

?>

theres my code.

Heres what i want to do:
1. User searches for something
2. If the $search variable is empty it says they didnt search for anything
3. If $search contains something, return all "elseif" statements that contain what the user searched for. (which, i know, is impossible..help please?)
4. If what the user searched for was not found say $search wasnt found

I know this code is full of mistakes, but im new to php so any help would be greatly appreciated!

Thanks in advance
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
:-/

i dont understand your code, doenst look like your preforming any search

what exactly are you searching?
 
0
Close
What is that data contained in that is being searched a text file or database or?
 
0
Close
forget it.

Is there any way to make 2 results for a switch case? its impossible to explain so i'll jus give u a example (that doesnt work..i dont think):

case "one" || "two": // this is the line i don't think would work
print "blah blah";
break;
 
0
Close
Not that I know of, you'd probably need an if statement inside the switch statement. But if you're having the same results for case one or two then I don't see why you'd need both cases.
 
0
Close
it needs different cases to give it keywords. in a user searches for "nokia" and i've put one in as "nokia 3510i" it wont show the nokia 3510i..i need to make lots of keywords for each item i put in. So far i've tried to use if elseif and else statements which didnt work..so now im using switch statements instead. I'll have a look round on other websites to see if theres anywhere that explains things which can have 2 cases..its gotta be possible somehow.
 
0
Close
Okay I think something like this would be how you'd do what you're wanting to with the case "one" || "two".

PHP:
<?php
switch ($var) 
{
case "one":
case "two":
case "three":
print "1 2 and 3";
break;
case "four":
print "4";
break;
default:
print "default";
break;
}
?>
 
0
Close
wooooooo thanks :-D
 
0
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back