Solved

slideshow in php

Posted on 2010-09-24
8
318 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
php string detection problem 7 34
error log using ftp 7 41
PHP Installer 5 24
PHP Form Calculate Total Price 10 42
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

777 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