Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

slideshow in php

Posted on 2010-09-24
8
Medium Priority
?
332 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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 2000 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

772 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