[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 08-08-2005, 02:02 PM   #1 (permalink)
Barru.
 
Barrucadu's Avatar
 
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,731
78.50 NP$ (Donate)

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 online now  
Old 08-08-2005, 02:14 PM   #2 (permalink)
DNOA Member
 
mholt's Avatar
 
Join Date: May 2004
Location: Utah
Posts: 5,041
18.01 NP$ (Donate)

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...
__________________
codeboards

A high-quality community of programmers -- Join today and post! We want new members!
mholt is offline  
Old 08-08-2005, 02:19 PM   #3 (permalink)
Barru.
 
Barrucadu's Avatar
 
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,731
78.50 NP$ (Donate)

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 online now  
Old 08-08-2005, 02:20 PM   #4 (permalink)
DNOA Member
 
mholt's Avatar
 
Join Date: May 2004
Location: Utah
Posts: 5,041
18.01 NP$ (Donate)

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 ... :-/
__________________
codeboards

A high-quality community of programmers -- Join today and post! We want new members!
mholt is offline  
Old 08-08-2005, 02:23 PM   #5 (permalink)
Professional Monkey
 
Amnezia's Avatar
 
Join Date: Jul 2005
Location: Escaped from the zoo
Posts: 908
13.25 NP$ (Donate)

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?
__________________
[http://www.webmasterwords.com/python-split-and-join-examples]Python Tutorials[/url]
Amnezia is offline  
Old 08-08-2005, 03:23 PM   #6 (permalink)
NamePros Member
 
Join Date: Jan 2005
Location: Texas USA
Posts: 71
203.00 NP$ (Donate)

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>";

// 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
    
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 04:09 PM.
Outer is offline  
Old 08-09-2005, 12:58 AM   #7 (permalink)
Barru.
 
Barrucadu's Avatar
 
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,731
78.50 NP$ (Donate)

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 online now  
Old 08-09-2005, 09:10 AM   #8 (permalink)
NamePros Member
 
Join Date: Jan 2005
Location: Texas USA
Posts: 71
203.00 NP$ (Donate)

Outer is an unknown quantity at this point


PHP Code:
$_GET['name']
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, 09:55 AM   #9 (permalink)
DNOA Member
 
mholt's Avatar
 
Join Date: May 2004
Location: Utah
Posts: 5,041
18.01 NP$ (Donate)

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.
__________________
codeboards

A high-quality community of programmers -- Join today and post! We want new members!
mholt is offline  
Old 08-10-2005, 12:35 PM   #10 (permalink)
NamePros Regular
 
Join Date: Jul 2005
Location: Florida
Posts: 232
349.00 NP$ (Donate)

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, 12:42 PM   #11 (permalink)
DNOA Member
 
mholt's Avatar
 
Join Date: May 2004
Location: Utah
Posts: 5,041
18.01 NP$ (Donate)

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)
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! ^_^
__________________
codeboards

A high-quality community of programmers -- Join today and post! We want new members!
mholt is offline  
Old 08-10-2005, 03:08 PM   #12 (permalink)
NamePros Member
 
Join Date: Jan 2005
Location: Texas USA
Posts: 71
203.00 NP$ (Donate)

Outer is an unknown quantity at this point


Quote:
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, 04:35 PM   #13 (permalink)
Professional Monkey
 
Amnezia's Avatar
 
Join Date: Jul 2005
Location: Escaped from the zoo
Posts: 908
13.25 NP$ (Donate)

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.
__________________
[http://www.webmasterwords.com/python-split-and-join-examples]Python Tutorials[/url]
Amnezia is offline  
Old 08-10-2005, 08:02 PM   #14 (permalink)
DNOA Member
 
mholt's Avatar
 
Join Date: May 2004
Location: Utah
Posts: 5,041
18.01 NP$ (Donate)

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!
__________________
codeboards

A high-quality community of programmers -- Join today and post! We want new members!
mholt is offline  
Old 08-11-2005, 01:32 AM   #15 (permalink)
Professional Monkey
 
Amnezia's Avatar
 
Join Date: Jul 2005
Location: Escaped from the zoo
Posts: 908
13.25 NP$ (Donate)

Amnezia has a spectacular aura aboutAmnezia has a spectacular aura about

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

Quote:
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.
__________________
[http://www.webmasterwords.com/python-split-and-join-examples]Python Tutorials[/url]
Amnezia is offline  
Old 08-11-2005, 05:55 AM   #16 (permalink)
DNOA Member
 
mholt's Avatar
 
Join Date: May 2004
Location: Utah
Posts: 5,041
18.01 NP$ (Donate)

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.
__________________
codeboards

A high-quality community of programmers -- Join today and post! We want new members!
mholt is offline  
Old 08-11-2005, 08:58 AM   #17 (permalink)
Professional Monkey
 
Amnezia's Avatar
 
Join Date: Jul 2005
Location: Escaped from the zoo
Posts: 908
13.25 NP$ (Donate)

Amnezia has a spectacular aura aboutAmnezia has a spectacular aura about

Cancer Survivorship Save a Life
Quote:
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

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.
__________________
[http://www.webmasterwords.com/python-split-and-join-examples]Python Tutorials[/url]

Last edited by Amnezia; 08-11-2005 at 09:06 AM.
Amnezia is offline  
Old 08-11-2005, 09:02 AM   #18 (permalink)
DNOA Member
 
mholt's Avatar
 
Join Date: May 2004
Location: Utah
Posts: 5,041
18.01 NP$ (Donate)

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.
__________________
codeboards

A high-quality community of programmers -- Join today and post! We want new members!
mholt is offline  
Old 08-11-2005, 09:12 AM   #19 (permalink)
Professional Monkey
 
Amnezia's Avatar
 
Join Date: Jul 2005
Location: Escaped from the zoo
Posts: 908
13.25 NP$ (Donate)

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

Quote:
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.
__________________
[http://www.webmasterwords.com/python-split-and-join-examples]Python Tutorials[/url]

Last edited by Amnezia; 08-11-2005 at 09:27 AM.
Amnezia is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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 01:24 PM
Googlism - What does google think of you? deadserious The Break Room 55 12-15-2005 09:09 AM
Paypal Settlement CMachuca The Break Room 3 07-31-2004 10:14 PM
Paypal Settlement Lord The Break Room 2 07-30-2004 09:30 PM
2 PPC sites with design morpheus666 Web Development Wanted 1 02-28-2004 04:40 AM

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 12:21 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85