Jump to content

XML/Flash gallery with PHP/MySQL


ingvaro

Recommended Posts

Ok so i have this photogallery in Flash that loads images from a xml file called images.xml

[code]<?xml root="localhost" version="1.0" encoding="utf-8" standalone="yes"?>
<images>
    <pic><image>gallery/nameofgallery/001.jpg</image></pic>
    <pic><image>gallery/nameofgallery/002.jpg</image></pic>
    <pic><image>gallery/nameofgallery/003.jpg</image></pic>
    <pic><image>gallery/nameofgallery/004.jpg</image></pic>
</images>[/code]

and then i have a page that loads links to each gallery from a table in my database

[code]<div class="main">

<?php

include("gallery/nav.php");

include("includes/connect.php");

if ( $_GET['number'] == NULL ){
$limit = 10;
} else {
$limit = $_GET['number'];
}

if ($_GET['page']==NULL || $_GET['page']<0){
$start = 0;
} else {
$start = $_GET['page'];
}

$query1="SELECT * FROM gallery_list WHERE (type = 'hjol') OR (type='annad')  ORDER BY id DESC LIMIT $start, $limit";
$query2="SELECT * FROM gallery_list WHERE (type = 'hjol') ORDER BY id DESC LIMIT $start, $limit";
$query3="SELECT * FROM gallery_list WHERE (type = 'annad') ORDER BY id DESC LIMIT $start, $limit";

if ($_GET['type'] == 'allt') $result=mysql_query($query1)or die("Query failed: $query with error " . mysql_error());;
if ($_GET['type'] == 'hjol') $result=mysql_query($query2)or die("Query failed: $query with error " . mysql_error());;
if ($_GET['type'] == 'annad') $result=mysql_query($query3)or die("Query failed: $query with error " . mysql_error());;

while ( $row = mysql_fetch_array( $result ))
{echo "
<a href=\"index.php?site=gallery/gallery.php&gallery=yes\" target=\"_parent\">
<div class=\"gallery_menu\">

<img src=\"gallery/thumbs/{$row[ 'linkur' ]}.jpg\" alt=\"description\" width=\"60\" height=\"60\" border=\"0\" />

<p><strong>
{$row[ 'titill' ]} - {$row[ 'date' ]}
</strong></p>

<p>
{$row[ 'description' ]}
</p>

</div>
</a>
";}

$previous = $start - $limit;
$next = $start + $limit;

if($previous<0){
$previous = 0;

}
if ($_GET['type'] == 'allt')
{
echo '<div align="center"><a href="index.php?site=gallery/galleries.php&type=allt&page='.$previous.'&number='.$limit.'">Fyrri síða - </a>';
echo '<a href="index.php?site=gallery/galleries.php&type=allt&page='.$next.'&number='.$limit.'">Næsta síða</a></div>';
}
if ($_GET['type'] == 'hjol')
{
echo '<div align="center"><a href="index.php?site=gallery/galleries.php&type=hjol&page='.$previous.'&number='.$limit.'">Fyrri síða - </a>';
echo '<a href="index.php?site=gallery/galleries.php&type=hjol&page='.$next.'&number='.$limit.'">Næsta síða</a></div>';
}
if ($_GET['type'] == 'annad')
{
echo '<div align="center"><a href="index.php?site=gallery/galleries.php&type=annad&page='.$previous.'&number='.$limit.'">Fyrri síða - </a>';
echo '<a href="index.php?site=gallery/galleries.php&type=annad&page='.$next.'&number='.$limit.'">Næsta síða</a></div>';
}
?>

</div>[/code]

That page is
"http://localhost/index.php?site=gallery/galleries.php&type=allt&page=0&number=10"
and when i press any of the links it gives me
"http://localhost/index.php?site=gallery/gallery.php&gallery=yes"

The gallery.php page is the page that shows the flash file

I want to have it this way because then i can have one gallery.php and one images.xml, because on my old site (im recreating it using php and mysql) i had one gallery.html and one images.xml file in each gallery folder :) but now i want it to be more dynamic :)

OK so here´s  the idea, if i could somehow, for example when i press a link to a gallery called "gallery_no_1" some script would then open the images.xml file and rename everything that says "nameofgallery" in the code above, with "gallery_no_1" and close it, so the flash file would show photos from the "gallery_no_1" gallery :D But theres another thing, i would have to write to the xml file as many lines as i have photos, so it wont show a photo nr.5 when the gallery only has 4 photos.


Actually, this is just my crazy idea of making my galleries more dynamic and less hard to manage, as ive explained, it used to be like this: ive got a folder called "gallery" and a flash file and a xml file and a bunch of photos, in the xml file theres just the names of the images. All i did when i wanted to create another gallery was copy the xml and flash file to the new gallery folder, and find out how many photos are in the gallery and then either remove some lines or add some lines to the xml file, depending on how many photos are in the gallery.
So if you have any ideas on how to make it more dynamic and better, just throw em at me! :D
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.