Solved

slideshow in php

Posted on 2010-09-24
8
307 Views
Last Modified: 2012-05-10
I have a slideshow in php, and I seems to only have one image looping.  I figure it has something to do with the '.' in the following line of code:

<?php  print "<img src".="\$fb_pic\"/>"; ?></a>

How do I reword this line to work effectively?
0
Comment
Question by:g0mab2
  • 4
  • 4
8 Comments
 
LVL 6

Expert Comment

by:neorush
ID: 33756224
Your slideshow is not in PHP, it is actually probably in javascript.  PHP is simply used to output the information for the javascript slideshow.  You would need to provide a lot more code for anyone to answer this question.
0
 

Author Comment

by:g0mab2
ID: 33756282
Here is the full code that I am using, it currently just displays the first person with the highest ranking.

<?php
include_once "connection/connect_to_mysql.php";

$sql = "SELECT fb_pic FROM fb_data17 ORDER BY rank DESC LIMIT 0,100";
    $result = mysql_query($sql) or die(mysql_error());
    while ($row = mysql_fetch_array($result))
    {
            
      $fb_pic = $row["fb_pic"];
      $rank = $row["rank"];
      }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
      <title>Visual Slideshow generated by VisualSlideshow.com</title>
      <meta http-equiv="content-type" content="text/html; charset=utf-8" />
      <meta name="keywords" content="Visual Slideshow, Slideshows Software, Software For Slideshow" />
      <meta name="description" content="Visual Slideshow created with Visual Slideshow, a free wizard program that helps you easily generate beautiful web slideshow" />
      <!-- Start VisualSlideShow.com HEAD section -->
      <link rel="stylesheet" type="text/css" href="engine/css/slideshow.css" media="screen" />
      <style type="text/css">.slideshow a#vlb{display:none}</style>
      <script type="text/javascript" src="engine/js/mootools.js"></script>
      <script type="text/javascript" src="engine/js/visualslideshow.js"></script>
      <!-- End VisualSlideShow.com HEAD section -->
</head>
<body style="background-color:#ffffff">
      <!-- Start VisualSlideShow.com BODY section -->
      <div id="show" class="slideshow">
      <div class="slideshow-images">
<?php  print "<img src=\"$fb_pic\"/>"; ?></a>
</div>

</body>
</html>
0
 
LVL 6

Expert Comment

by:neorush
ID: 33756463
This is kind of a wild guess, but $fb_pic is an array, and you also have a random '</a>' sitting in there, but you would need to output all of the images in the array, and engine/js/visualslideshow.js probably does something with them, so you can try replacing: <?php  print "<img src=\"$fb_pic\"/>"; ?></a>
with something like the following:

<?php

foreach($fb_pic as $fb_pic_details){

echo '<img src="'.$fb_pic_details['fb_pic'].'" />';

}

?>

Open in new window

0
 

Author Comment

by:g0mab2
ID: 33756551
I tried that and got the following error:

Warning: Invalid argument supplied for foreach() in /home/content/g/o/m/gomab2/html/index.php on line 34

line 34 is this:
foreach($fb_pic as $fb_pic_details){
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 6

Expert Comment

by:neorush
ID: 33756591
Your query may not be returning any results, try adding an empty array just in case there are none:
$sql = "SELECT fb_pic FROM fb_data17 ORDER BY rank DESC LIMIT 0,100";
$result = mysql_query($sql) or die(mysql_error());
$fb_pic = array(); // NEW LINE
0
 

Author Comment

by:g0mab2
ID: 33756692
I am getting the same error for some reason, still has an issue with that same line.  I also tried the:
$fb_pic = array(); // NEW LINE  
without this:
<?php
foreach($fb_pic = $fb_pic_details){
echo '<img src="'.$fb_pic_details['fb_pic'].'" />';
}
?>

replaced with this:
<?php  print '<img src="'.$fb_pic.'"/>'; ?>

and it still only rotates the first image.
0
 
LVL 6

Assisted Solution

by:neorush
neorush earned 500 total points
ID: 33756758
ok, I think I see what's going on here...try this:
<?php
	include_once "connection/connect_to_mysql.php";
	
	$fb_pic = array();
	$sql = "SELECT fb_pic FROM fb_data17 ORDER BY rank DESC LIMIT 0,100";
    $result = mysql_query($sql) or die(mysql_error());
    while ($row = mysql_fetch_array($result)){
      $fb_pic[] = $row;
    }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
      <title>Visual Slideshow generated by VisualSlideshow.com</title>
      <meta http-equiv="content-type" content="text/html; charset=utf-8" />
      <meta name="keywords" content="Visual Slideshow, Slideshows Software, Software For Slideshow" />
      <meta name="description" content="Visual Slideshow created with Visual Slideshow, a free wizard program that helps you easily generate beautiful web slideshow" />
      <!-- Start VisualSlideShow.com HEAD section -->
      <link rel="stylesheet" type="text/css" href="engine/css/slideshow.css" media="screen" />
      <style type="text/css">.slideshow a#vlb{display:none}</style>
      <script type="text/javascript" src="engine/js/mootools.js"></script>
      <script type="text/javascript" src="engine/js/visualslideshow.js"></script>
      <!-- End VisualSlideShow.com HEAD section -->
</head>
<body style="background-color:#ffffff">
      <!-- Start VisualSlideShow.com BODY section -->
      <div id="show" class="slideshow">
      <div class="slideshow-images">
<?php
	foreach($fb_pic as $fb_pic_details){
		echo  '<img src="'.$fb_pic_details['fb_pic'].'" />';
	}
?>
</div>
</body>
</html>

Open in new window

0
 

Accepted Solution

by:
g0mab2 earned 0 total points
ID: 33756928
okay, that worked perfectly, thank you very much.  It seems I have this same problem with my other question I posted yesterday.  If you don't mind, would you please look at that one as well if you have time?

it is called "user's link to user's data"  it is also a php question.

Thank you very much, I will close out this question.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now