12-15-2011, 03:23 PM
|
#1 (permalink)
|
|
The Visitor
Join Date: Dec 2011
Posts: 1
Thanks: 0
|
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. :)
|
|
|
|