Very basic search engine-help!

NamecheapNamecheap
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
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains — AI StorefrontUnstoppable Domains — AI Storefront
:-/

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

what exactly are you searching?
 
0
•••
What is that data contained in that is being searched a text file or database or?
 
0
•••
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
•••
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
•••
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
•••
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
•••
wooooooo thanks :-D
 
0
•••
Appraise.net

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy — Payment Flexibility
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back