Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 334
  • Last Modified:

slideshow in php

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
g0mab2
Asked:
g0mab2
  • 4
  • 4
2 Solutions
 
neorushCommented:
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
 
g0mab2Author Commented:
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
 
neorushCommented:
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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
g0mab2Author Commented:
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
 
neorushCommented:
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
 
g0mab2Author Commented:
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
 
neorushCommented:
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
 
g0mab2Author Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now