I have the following code...

<?php
    $con = mysql_connect("localhost:3306","name","pass");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }

    mysql_select_db("barndata", $con);


    $today = date("Y-m-d");



    $result = mysql_query("SELECT * FROM event where Date >= '$today' ORDER BY Date ASC LIMIT 0, 7")  ;


       while ($row = mysql_fetch_array($result)) {
       echo 'banner1.add("IMAGE","';
       echo $row['ImagePath'];
       echo '" , 5, 270, 420, ';
       echo '"';
       echo $row['ImgLink'];
       echo '"';
       echo ');';

       }
       mysql_close($con);
    ?>
                            document.write(banner1);
                            banner1.start();
            </script>

I am attempting to add a date under the image so i added the following

echo $row['ImgLink'];
       echo '"';
    ADDED THIS Line.------->   echo $row['ArtistDate'];
       echo ');';

and it doesnt work. anyone have a idea how to fix it? im sure its simple and im overlooking but im not seeing it.
Anyhow it shows a image and im looking to add the date below that image for each picture that is shown..
Thanks

Recommended Answers

All 3 Replies

Do a var_dump($row) and see what gets output for the index ArtistDate

Nothing wrong with your PHP. Would need to see the JavaScript to know for sure what's going on however I did notice you're missing a comma. After you echo your image link and close the " you'll need another comma to identify the next item you're adding to your jQuery object and since you're adding text it will probably need to be enclosed in quotes as well:

echo $row['ImgLink'];
echo '","';
echo $row['ArtistDate'];
echo '");';

OK here is all the code. When i run it it doesnt show the images or the txt. but if i remove the echo containing the artist date it works fine.

    <script language="javascript">
                        banner1 = new Banner('banner1');

<?php
$con = mysql_connect("localhost:3306","user","pass");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("barndata", $con);


$today = date("Y-m-d");



$result = mysql_query("SELECT * FROM banner where DateExpires >= '$today' ORDER BY DateExpires ASC");


   while ($row = mysql_fetch_array($result)) {
   echo 'banner1.add("IMAGE","';
   echo $row['ImgLink'];
   echo '" , 5, 270, 420, ';
   echo '"';
   echo $row['UrlLink'];
   echo '"';
   echo');';

   }
   mysql_close($con);
?>

<?php
$con = mysql_connect("localhost:3306","user","pass");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("barndata", $con);


$today = date("Y-m-d");



$result = mysql_query("SELECT * FROM event where Date >= '$today' ORDER BY Date ASC LIMIT 0, 7")  ;


   while ($row = mysql_fetch_array($result)) {
   echo 'banner1.add("IMAGE","';
   echo $row['ImagePath'];
   echo '" , 5, 270, 420, ';
   echo '"';
   echo $row['ImgLink'];
   echo '","';
   echo $row['ArtistDate'];
   echo ');';

   }

   mysql_close($con);
?>
                        document.write(banner1);
                        banner1.start();
        </script>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.