Forum Moderators: coopster

Message Too Old, No Replies

PHP Mysql Javascript

Lightbox gallery

         

nepoverljiv

9:21 pm on Mar 19, 2010 (gmt 0)

10+ Year Member



<ul class="subjects">
<?php
$subject_set = mysql_query("SELECT * FROM galerija", $connection);
if (!$subject_set) {
die("Database query failed: " . mysql_error());
}

while ($subject = mysql_fetch_array($subject_set)) {
echo "<li>{$subject["ime"]}</li>"."<br>";
$page_set = mysql_query("SELECT * FROM slike WHERE id_gal = {$subject["id_gal"]}", $connection);
if (!$page_set) {
die("Database query failed: " . mysql_error());
}
echo "<ul class=\"pages\">";
while ($page = mysql_fetch_array($page_set)) {
echo "<li><img width=120 height=80 src=admin/galerija/".$page[slika1]."/></a> <img width=120 height=80 src=admin/galerija/".$page[slika2]." /> <img width=120 height=80 src=admin/galerija/".$page[slika3]." /></li>"."<br>";
echo "<li><img width=120 height=80 src=admin/galerija/".$page[slika4]." /> <img width=120 height=80 src=admin/galerija/".$page[slika5]." /> <img width=120 height=80 src=admin/galerija/".$page[slika6]." /></li>"."<br>";
echo "<li><img width=120 height=80 src=admin/galerija/".$page[slika7]." /> <img width=120 height=80 src=admin/galerija/".$page[slika8]." /> <img width=120 height=80 src=admin/galerija/".$page[slika9]." /></li>"."<br>";
}
echo "</ul>";
}

?>
</ul>

Now i wanna this picture to show with lightbox.js. How?

redhatlab

10:10 pm on Mar 19, 2010 (gmt 0)

10+ Year Member



Hi,

Did you included the JavaScript files in the head of the page:

something like:

<script type="text/javascript" src="includes/js/prototype.js"></script>
<script type="text/javascript" src="includes/js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="includes/js/lightbox.js"></script>

nepoverljiv

10:17 pm on Mar 19, 2010 (gmt 0)

10+ Year Member



Yes, but i have problem with <a href> in php

redhatlab

10:24 pm on Mar 19, 2010 (gmt 0)

10+ Year Member



Hi,

Why are you having a problem with <a href> in PHP?

Also I was reading your HTML and you have an UL list and not link in any of the list items "<li>".

The link should look something like this:


<a href="images/full.jpg" rel="lightbox[home]" title="Some text">
<img src="images/thumb.jpg" alt="Some text" width="100" height="75">
</a>

nepoverljiv

10:34 pm on Mar 19, 2010 (gmt 0)

10+ Year Member



I have database, when put name of galleries and images. You can see in my code how get images and show on page in thumbnail. So question is, do you maybe can correct my code and add what need for lightbox?

redhatlab

10:44 pm on Mar 19, 2010 (gmt 0)

10+ Year Member



ok,

I can do one, so you can know how to do the rest.

Question:

Why do you have so many "slika" (slika1, slika2)? Are they table fields?

Also in the why you have you PHP while setup you will create 3 list item every time it runs.

Are you expecting a single result from the query?

nepoverljiv

10:48 pm on Mar 19, 2010 (gmt 0)

10+ Year Member



because, i have lot galleries. in database i have 2 table, first is for name of galleries, second is for images. on my page have first name of galleries, and under galleries name have 3x3 thumbnail. for that i need list, in one row have 3 thumbnail.

redhatlab

10:59 pm on Mar 19, 2010 (gmt 0)

10+ Year Member



Hi,

Here it is, this should be the list item:

echo "<li><a href=admin/galerija/".$page[slika-full]." rel="lightbox[gallery]" title="Some text">
<img width=120 height=80 src=admin/galerija/".$page[slika-thumb]." />
</a></li>"."<br>";

Note: I use "slika-full" and "slika-thumb" to symbolize the name of the field in the image table that holds the full image and the thumbnail image. Also in the rel tag for the lightbox I use the work "gallery" you can use any other.

nepoverljiv

11:06 pm on Mar 19, 2010 (gmt 0)

10+ Year Member



Do not work

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\xampp\phpMyAdmin\arion\galerija.php on line 34

What is error?

redhatlab

11:08 pm on Mar 19, 2010 (gmt 0)

10+ Year Member



The error is the quotes {")

rel="lightbox[gallery]" title="Some text"

change for this:

rel=\"lightbox[gallery]\" title=\"Some text\"

nepoverljiv

11:19 pm on Mar 19, 2010 (gmt 0)

10+ Year Member



Thanks man a lot ! Works! Thanks again!