NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page PHP search form

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 08-08-2005, 03:02 PM THREAD STARTER               #1 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
 




PHP search form


Can someone make or teach me how to make a PHP search form for my image hosting site (wip) it should search for .gif, .jpg, .png and .bmp. It should also when they click on a result take the user to "/uploads/browseupload.php?file=[resultname].[resultextension]". If someone could do that it would be really great, thanks in advance.


if possible a bit of php that would load the image on the "/uploads/browseupload.php?file=[resultname].[resultextension]" page. thanks again.
Barrucadu is offline  
Old 08-08-2005, 03:14 PM   #2 (permalink)
DNOA Member
Join Date: May 2004
Posts: 5,040
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
 


Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
I'll do it if you can add to my reputation

What you might want to do is store the files in a MySQL database (they're MUCH easier to search with instead of raw file names) and then search that...
mholt is offline  
Old 08-08-2005, 03:19 PM THREAD STARTER               #3 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
 




hmmm... id prefer to not use MySQL, i dont like it (dunno why). Reputation updated!
Barrucadu is offline  
Old 08-08-2005, 03:20 PM   #4 (permalink)
DNOA Member
Join Date: May 2004
Posts: 5,040
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
 


Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
Thanks, um, ... actually I guess I wasn't clear - I don't know how to do it without MySQL ... :-/
mholt is offline  
Old 08-08-2005, 03:23 PM   #5 (permalink)
Professional Monkey
 
Amnezia's Avatar
Join Date: Jul 2005
Location: Escaped from the zoo
Posts: 907
Amnezia has a spectacular aura aboutAmnezia has a spectacular aura about
 


Cancer Survivorship Save a Life
you can do it without mysql

what is the search criteria for the images?
__________________
Webmaster Words
Amnezia is offline  
Old 08-08-2005, 04:23 PM   #6 (permalink)
NamePros Member
Join Date: Jan 2005
Location: Texas USA
Posts: 71
Outer is an unknown quantity at this point
 



Try this (i can up with it quickly though, so MIGHT be some errors)

It should work for the most part I believe :/
PHP Code:
<?php 

$form 
"<form method=\"POST\" action=\"search.php\">"
$form .= "Search for: <input type=\"text\" name=\"criteria\"> 
             <input type=\"Submit\" name=\"Submit\" value=\"Submit\">"

$form .= "</form>"
????: NamePros.com http://www.namepros.com/programming/113818-php-search-form.html

// check is user submitted, if not, show the form 
if ($_POST['Search'] != "Search"

    echo 
$form

else 


$directory "/home/username/public_html/images/"

if (
is_dir($directory)) 

   
$open_dir opendir($directory); 
    while ((
$file readdir($open_dir)) !== false
    { 
        
// Place filenames into an array 
        
$files[] = $file
    } 
    
closedir($open_dir); 

    
// files are in an array, check if search criteria meets any names in array 
????: NamePros.com http://www.namepros.com/showthread.php?t=113818
    
if (in_array($_POST['criteria'], $files)) 
    { 
        foreach (
$files AS $file_result
        { 
            if (
stristr($file_result$_POST['criteria'])) 
            { 
               echo 
"<a href=\"uploads/browseupload.php?file=".$file_result."\"></a><br />"
            } 
        } 
    } 
    else 
    { 
        echo 
"Search Criteria not found<br /> Please try again<br /><br />"
        echo 
$form
    } 




?>
Hope this helps
__________________
I wonder...
Last edited by Outer; 08-08-2005 at 05:09 PM.
Outer is offline  
Old 08-09-2005, 01:58 AM THREAD STARTER               #7 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
 




thanks, i'll test it when i can get PHP on my webserver working.

ive just realized something.. I dont know how to use URL parameters in PHP, whats the syntax to get the parameter?
Barrucadu is offline  
Old 08-09-2005, 10:10 AM   #8 (permalink)
NamePros Member
Join Date: Jan 2005
Location: Texas USA
Posts: 71
Outer is an unknown quantity at this point
 



PHP Code:
$_GET['name'
????: NamePros.com http://www.namepros.com/showthread.php?t=113818
so your URL is http://www.mydomain.com/images/brwos...y_vacation.jpg

to get that, use

PHP Code:
$_GET['file'
__________________
I wonder...
Outer is offline  
Old 08-09-2005, 10:55 AM   #9 (permalink)
DNOA Member
Join Date: May 2004
Posts: 5,040
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
 


Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
... don't forget the ; at the end of the line.
mholt is offline  
Old 08-10-2005, 01:35 PM   #10 (permalink)
NamePros Regular
Join Date: Jul 2005
Location: Florida
Posts: 233
TeviH is an unknown quantity at this point
 



searching images by filename?! You'd be better off just showing a bazillion thumbnails... putting keywords in a database would be much more effective.
__________________
www.headlinercreative.com
TeviH is offline  
Old 08-10-2005, 01:42 PM   #11 (permalink)
DNOA Member
Join Date: May 2004
Posts: 5,040
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
 


Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
Yeah, in fact, you should store each image in the database as a BLOB. I know it slows things down, but would be much more effecient otherwise. You could store the uploader's IP address with it as well, plus the upload date, time, and even keywords for searches! Then order them how you want, prune old images, etc, etc! It would be a fabulous alternative.

Example - you could have a database table with these rows in it:

imageid - BIGINT - 10 - UNSIGNED - auto_increment PRIMARY KEY (unique ID no.)
imagedata - BLOB (this would be the actual image as binary)
submitter_ip - TEXT (i just use text for this, but this is the IP address of the uploader)
keywords - TEXT (seperate by spaces, maybe, then use explode() to search)
date - DATE (upload date)
time - TIME (time of upload)
????: NamePros.com http://www.namepros.com/showthread.php?t=113818
views - BIGINT - 10

Now, I added that last field in because you will have to access the image BLOB via a .php file, right? Why not keep track of the number of views an image gets? Might be a neat little extra feature. Just put this in the PHP file before it sends the image to the browser. Do whatever you like! ^_^
mholt is offline  
Old 08-10-2005, 04:08 PM   #12 (permalink)
NamePros Member
Join Date: Jan 2005
Location: Texas USA
Posts: 71
Outer is an unknown quantity at this point
 



Originally Posted by Mikor
hmmm... id prefer to not use MySQL, i dont like it (dunno why). Reputation updated!
Thats why I used the method above :-/
I agree that mysql is a better option...
__________________
I wonder...
Outer is offline  
Old 08-10-2005, 05:35 PM   #13 (permalink)
Professional Monkey
 
Amnezia's Avatar
Join Date: Jul 2005
Location: Escaped from the zoo
Posts: 907
Amnezia has a spectacular aura aboutAmnezia has a spectacular aura about
 


Cancer Survivorship Save a Life
DONT store images as a blob in a mysql database its not what its designed for and if your site recieves and traffic it will grind to stand still.

just keep the images in a folder and record the filename and path in the mysql database.
__________________
Webmaster Words
Amnezia is offline  
Old 08-10-2005, 09:02 PM   #14 (permalink)
DNOA Member
Join Date: May 2004
Posts: 5,040
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
 


Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
Do you realize how LARGE that folder will become? MySQL is designed to handle large databases! Large folders take longer to search through!
mholt is offline  
Old 08-11-2005, 02:32 AM   #15 (permalink)
Professional Monkey
 
Amnezia's Avatar
Join Date: Jul 2005
Location: Escaped from the zoo
Posts: 907
Amnezia has a spectacular aura aboutAmnezia has a spectacular aura about
 


Cancer Survivorship Save a Life
if you re-read my post

Originally Posted by myslef

just keep the images in a folder and record the filename and path in the mysql database.
you dont need to search through a folder if you know the images name and path now do you?

mySQl is designed for storing large amounts of data but that data should be in the form of many small records rather than few large records. Storing large files in Blobs is MESSY and should be avoided at all cost.
__________________
Webmaster Words
Amnezia is offline  
Old 08-11-2005, 06:55 AM   #16 (permalink)
DNOA Member
Join Date: May 2004
Posts: 5,040
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
 


Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
The point is, though, directories aren't built to handle hundreds, or thousands of files in them. Having lots in 1 directory is still going to slow it down, whether you know the filename or not.
mholt is offline  
Old 08-11-2005, 09:58 AM   #17 (permalink)
Professional Monkey
 
Amnezia's Avatar
Join Date: Jul 2005
Location: Escaped from the zoo
Posts: 907
Amnezia has a spectacular aura aboutAmnezia has a spectacular aura about
 


Cancer Survivorship Save a Life
Originally Posted by compuXP
The point is, though, directories aren't built to handle hundreds, or thousands of files in them. Having lots in 1 directory is still going to slow it down, whether you know the filename or not.
directories are just files which contain lists of file records
????: NamePros.com http://www.namepros.com/showthread.php?t=113818

you can store thousands of files in a directory with very little reduction in speed

if you look at a linux distros architecture some of the directories contain 10's of thousands of files so no offence but you're wrong a directory can be used to store A LOT of files.
__________________
Webmaster Words
Last edited by Amnezia; 08-11-2005 at 10:06 AM.
Amnezia is offline  
Old 08-11-2005, 10:02 AM   #18 (permalink)
DNOA Member
Join Date: May 2004
Posts: 5,040
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
 


Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
Directories are designed to handle many SUBdirectories, to divide the files and make them easier to work with.

Mikor - use MySQL blobs -_- They're much easier to handle. And no slower than storing the images in 1 directory.
mholt is offline  
Old 08-11-2005, 10:12 AM   #19 (permalink)
Professional Monkey
 
Amnezia's Avatar
Join Date: Jul 2005
Location: Escaped from the zoo
Posts: 907
Amnezia has a spectacular aura aboutAmnezia has a spectacular aura about
 


Cancer Survivorship Save a Life
i'm sorry but you have no idea what you're talking about. when you also have a degree in computer science we can sit down and discuss this on a level playing feild but until then prehaps you could refrain from giving out false information and bad advice

Originally Posted by compuXP
Directories are designed to handle many SUBdirectories, to divide the files and make them easier to work with.

Mikor - use MySQL blobs -_- They're much easier to handle. And no slower than storing the images in 1 directory.
a sub directory is a directory and a directory is a file so therefore by simple dedtuction directories can handle many files

mysql becomes ALOT slower if you start using using blobs, if you read up about mySQL optimisation on the mySQL website you will see that they recommend avoiding storing binary objects in a database.
__________________
Webmaster Words
Last edited by Amnezia; 08-11-2005 at 10:27 AM.
Amnezia is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
HOWTO: Install the Apache Web Server, Perl, PHP, and MySQL on Windows deadserious Webmaster Tutorials 96 05-27-2007 02:24 PM
Googlism - What does google think of you? deadserious The Break Room 55 12-15-2005 10:09 AM
Paypal Settlement CMachuca The Break Room 3 07-31-2004 11:14 PM
Paypal Settlement Lord The Break Room 2 07-30-2004 10:30 PM
2 PPC sites with design morpheus666 Web Development Wanted 1 02-28-2004 05:40 AM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 12:39 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger