TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   jquery gallery (http://www.talkphp.com/general/6068-jquery-gallery.html)

Lacrimosa 12-15-2011 03:23 PM

jquery gallery
 
Hey all,

I really need some help with my coding since i'm stuck with a problem I can't seem to solve.

I am currently working with a jquery gallery plugin, but instead of having the images in a folder on the server, I'd like to link to a database, and get them from a php script.
So far I've got this:

<?php

$dblink = mysql_connect("localhost", "mmd4a201105", "*******");
if (!$dblink)
{
echo "Forbindelse til database kunne ikke etableres".mysql_error();
exit;
}

$db = mysql_select_db ("mmd4a201105");
if (!$db)
{
echo "Databasen kunne ikke vælges".mysql_error();
exit;
}


$sql_streng = "select titel, navn, mail, tekst, fotonavn from foto";

$resultat = mysql_query ($sql_streng, $dblink);
$antal_raekker = mysql_num_rows($resultat);

if ($antal_raekker == 0)
{
echo "Der er ingen fotos at vise!";
}
else
{
while ($raekke = mysql_fetch_assoc($resultat))
{
echo "<img src=\"fotos/$raekke[fotonavn]\" alt=\"fotos/$raekke[fotonavn]\" width=\"75px\" height=\"75px\" title=\"$raekke[titel] /><br><br>";

}
}

mysql_close ($dblink);
?>

The gallery currently only displays the first image in the database table but I like it to display all images on the database... loop function perhaps, I'm not sure that's what the term is called?

Appreciate any help, and sorry if it's a bit confusing. I'll gladly specify anything required. :)

AxelG 02-18-2012 08:33 PM

Replace the en of your script by that :

$resultat = mysql_query ($sql_streng, $dblink);
$antal_raekker = mysql_num_rows($resultat);

if ($antal_raekker == 0)
{
echo "Der er ingen fotos at vise!";
}
else
{
while ($raekke = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "<img src=\"fotos/$raekke[fotonavn]\" alt=\"fotos/$raekke[fotonavn]\" width=\"75px\" height=\"75px\" title=\"$raekke[titel] /><br><br>";

}
}


It should work


All times are GMT. The time now is 07:55 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0