Solved

slideshow in php

Posted on 2010-09-24
8
322 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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…

830 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