PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have a php code that allows me to upload images on my server. it will rename the image and saves the image names and some texts on the mysql databse.
I just need to know how I can pull those images and texts related to each image and make an slideshow on a PHP page?
<?php
// Connects to your Database
mysql_connect("localhost", "databaseusernam", "password") or die(mysql_error()) ;
mysql_select_db("database") or die(mysql_error()) ;
//Retrieves data from MySQL
$data = mysql_query("SELECT * FROM employees LIMIT 3") or die(mysql_error());
//Puts it into an array
while($info = mysql_fetch_array( $data ))
{
//Outputs the image and other data
Echo "<img src=images22/".$info['uploaded'] ."> <br>";
Echo "<b>Name:</b> ".$info['name'] . "<br> ";
Echo "<b>Email:</b> ".$info['email'] . " <br>";
Echo "<b>Phone:</b> ".$info['phone'] . " <hr>";
}
?>
the page above will show the images but its not a slideshow.
yes but it will only show 3 images ("SELECT * FROM employees LIMIT 3")
I can change that to 1 or 10 if I wanted to but that is not a slideshow. it just pulls the images from the database and shows them all on the page at the same time. slideshow shows images one by one!
Ok, i understand what you have in mind. For this i would use ajax; each time a button is clicked (prev or next) you could pass in the query string prev or next for example. Depending which value is passed you would subtract or add one to the value you currently have. The new value is then passed to the sql query and the new image selected. I haven't tested this but in my mind it seems like it could work.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
<?php
// Connects to your Database
mysql_connect("localhost", "databaseusernam", "password") or die(mysql_error()) ;
mysql_select_db("database") or die(mysql_error()) ;
//Retrieves data from MySQL
$data = mysql_query("SELECT * FROM employees LIMIT 3") or die(mysql_error());
echo "<div class=\"fadein\">";
while($info = mysql_fetch_array( $data ))
{
//Outputs the image and other data
echo "<img src=images22/{$info['uploaded']} />"
}
echo "</div>";
?>
You'll need to tweak it a little to get the name display, but that's the general idea.
Thanks for the prompt reply bud. That resolved the issue with erro but the images are displyed next to eachother and no slideshow!!
I know you guys probably are busy so I don't want to enoy you by asking so many questions. but is there any tutorial(s) that I can watch specifically related to what I am looking for? i have been serching youtube and google and haven't found anything that is suitable to what I am trying to do. I know it is not hard but I am new to PHP.