/    Sign up×
Community /Pin to ProfileBookmark

PHP + mySQL Photo/picture Gallery

..Yes i know, another How do i..? thread.

I’ve basically took a few days of free time to learn PHP scripting so I can do this.. but still don’t usnderstand how to do what I am after:

If I make a list of what I’m hoping to create perhaps this could shed some light onto what I am asking:

An upload .php file which allows a picture to get uploaded e.g. uploads/01.jpg
But also has a form under it that is sent to a mySQL database to be added :
Location of file (automatic),
Name (limited to XXX characters),
Comment (limited to XXX characters),
Date uploaded (automatic),
Date Taken (month)

The scripting needed to pull these individual fields into areas, e.g <img src=”$…..” /> and be able to make an automatic grid of say 6 images, ordered from recently uploaded to eldest.
I’m still a bit fuzzy around the area of pulling data from a mySQL database and it may just be a simple case of [database].[field] similar to Action script.

That’s what i’m hoping to be able to implement into a .html file but I just have no idea about the logic behind it. I would go about looking at other .php files on the net, and see they’re coded and the different syntax, but as you know, hitting cmd+u on a webpage you only see the rendered .html text, no server-side scripts..

Now since it’s xmas I was hoping that you’d take a simple amount of time to give me some pointers in how to do these , what seem, simple things.

But I’m not looking for any criticism, like “go to http:// and learn you ***” or “Just use a free tool on the web”

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@BarrieHieDec 19.2008 — I can help you here but right now I've got to go to work! :-) I'll check back later.

Barrie
Copy linkTweet thisAlerts:
@Hen_AsrafDec 21.2008 — You MySQL query for pulling the data should be similar to the following.

I'm assuming you have an image ID. If not, you could ORDER BY the date (though image ID would be a better choice)
SELECT * FROM <span><code>images</code></span> ORDER BY <span><code>id</code></span> DESC

To pull the data with PHP, you have to query the database:
[code=php]<?php
mysql_connect($server, $user, $pass);
mysql_select_db($db);
$result = mysql_query("SELECT * FROM images ORDER BY id DESC");
?>[/code]


Now logic says that a grid of 6 means that there's a new line every 6 images, so cound an $i in the while loop that fetches the info of every image:[code=php]<?php
$i = 0;
while ($image = mysql_fetch_array($result))
{
$i++;
echo '<img src="'.$image['location'].'" />';
if ($i == 6)
{
$i = 0;
echo '<br />';
}
}[/code]
×

Success!

Help @Hells-Tears spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...