[advanced search]
Results from the most recent live auction are here.
22 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Domain Name Industry Newsletter
Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 11-29-2003, 04:39 AM   · #1
StevieWeevie
New Member
 
Trader Rating: (0)
Join Date: Nov 2003
Posts: 5
NP$: 9.00 (Donate)
StevieWeevie is an unknown quantity at this point
Very basic search engine-help!

<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&nbsp;&nbsp;|&nbsp;&nbsp;Click here for all files&nbsp;&nbsp;|&nbsp;&nbsp;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


Please register or log-in into NamePros to hide ads
StevieWeevie is offline   Reply With Quote
Old 11-29-2003, 05:18 AM   · #2
adam_uk
Senior Member
 
Trader Rating: (17)
Join Date: May 2003
Posts: 2,211
NP$: 6170.25 (Donate)
adam_uk is a jewel in the roughadam_uk is a jewel in the roughadam_uk is a jewel in the rough
Breast Cancer


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

what exactly are you searching?
adam_uk is offline   Reply With Quote
Old 11-29-2003, 08:00 PM   · #3
deadserious
Senior Member
 
Trader Rating: (13)
Join Date: Aug 2002
Posts: 1,300
NP$: 2.85 (Donate)
deadserious has a spectacular aura aboutdeadserious has a spectacular aura about
What is that data contained in that is being searched a text file or database or?
deadserious is offline   Reply With Quote
Old 11-30-2003, 02:02 AM   · #4
StevieWeevie
New Member
 
Trader Rating: (0)
Join Date: Nov 2003
Posts: 5
NP$: 9.00 (Donate)
StevieWeevie is an unknown quantity at this point
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;
StevieWeevie is offline   Reply With Quote
Old 11-30-2003, 02:19 AM   · #5
deadserious
Senior Member
 
Trader Rating: (13)
Join Date: Aug 2002
Posts: 1,300
NP$: 2.85 (Donate)
deadserious has a spectacular aura aboutdeadserious has a spectacular aura about
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.
deadserious is offline   Reply With Quote
Old 11-30-2003, 02:25 AM   · #6
StevieWeevie
New Member
 
Trader Rating: (0)
Join Date: Nov 2003
Posts: 5
NP$: 9.00 (Donate)
StevieWeevie is an unknown quantity at this point
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.
StevieWeevie is offline   Reply With Quote
Old 11-30-2003, 02:47 AM   · #7
deadserious
Senior Member
 
Trader Rating: (13)
Join Date: Aug 2002
Posts: 1,300
NP$: 2.85 (Donate)
deadserious has a spectacular aura aboutdeadserious has a spectacular aura about
Okay I think something like this would be how you'd do what you're wanting to with the case "one" || "two".

PHP Code:
<?php
switch ($var)
{
case
"one":
case
"two":
case
"three":
print
"1 2 and 3";
break;
case
"four":
print
"4";
break;
default:
print
"default";
break;
}
?>
deadserious is offline   Reply With Quote
Old 11-30-2003, 02:48 AM   · #8
StevieWeevie
New Member
 
Trader Rating: (0)
Join Date: Nov 2003
Posts: 5
NP$: 9.00 (Donate)
StevieWeevie is an unknown quantity at this point
wooooooo thanks :-D
StevieWeevie is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
Proof is in the Parking Arcade Script Hunting Moon
Advertise your business at NamePros
All times are GMT -7. The time now is 10:01 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0