Page 1 of 1

loading images with php code

Posted: Thu Feb 17, 2011 4:19 am
by descuadro
Hello everyone!
I'm new to this forum and practically new to php.
What i'm going to ask probably has an obvious answer, but to me it is a riddle.
Thanks in advance to everyone:

I'm creating a personal photo portfolio of different events in different dates.
I have an event.php page, where i want different sets of images to be loaded, depending on the event name and date.
I have already managed to change the page's title with this code:

<?php
$EventName;
function event ()
{
global $EventName;
return htmlspecialchars($_GET["EventName"]);
}
echo event();
?>

so that when i add ?EventName=whatever

it returns "whatever" to my page title.

I would like now to load a set of images, all from the same directory -which would be already created and in its place-.
I want to "call" the directory with the same type of function.

Is there a way to link to "evento.php?EventName=whatever", so that it loads a directory called "whatever", where i have the images stored? And so that if i change the name it will change the directory where the images are coming from (they would be named 1.jpg, 2.jpg, etc.)

Thank you so much, i'm struggling to find the right code but i find myself in trouble.
Bye!

Re: loading images with php code

Posted: Thu Feb 17, 2011 5:42 am
by jankidudel
Just create database table and with events names and directory names , for example with this structure:

table gallery
1. id
2. eventname
3. dirname


and your problem will be solved.

Then , get from url event. and get from database your event directory.


"SELECT `dirname` FROM gallery WHERE eventname='$eventname'";

Re: loading images with php code

Posted: Thu Feb 17, 2011 3:20 pm
by descuadro
jankidudel wrote:Just create database table and with events names and directory names , for example with this structure:

table gallery
1. id
2. eventname
3. dirname


and your problem will be solved.

Then , get from url event. and get from database your event directory.


"SELECT `dirname` FROM gallery WHERE eventname='$eventname'";
Hey man! You're from Vilnius! I'm actually preparing to go there for a week or so with some friends of mine! (another friend told me the most beautiful girls on earth are there :P)
The thing is i'm quite new to the language, i only have some basic knowledge of general programming.
By creating a database do you mean creating a file (for example a txt)?
I have a couple more questions after that.
Thank you very much

Re: loading images with php code

Posted: Thu Feb 17, 2011 3:22 pm
by descuadro
that emotican face is awful

Re: loading images with php code

Posted: Thu Feb 17, 2011 3:27 pm
by jankidudel
Yes, girls are very beautiful here, but they require more $$$ :D.

If you don't know how to use database, you can just create statement like this

$directory = htmlspecialchars($_GET[' event' ]));

/* code for opening $directory and getting images */

You name directories with the same names as event names and then open them.

Re: loading images with php code

Posted: Sat Feb 19, 2011 8:58 am
by descuadro
Hey again!
I hope so, cause we don't have any $$$...
I'm gonna try to make it with your advice. I'll post again probably if i find myself in jeopardy