0

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

Edited by azgold472

3
Contributors
3
Replies
4
Views
4 Years
Discussion Span
Last Post by azgold472
0

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 '");';

Edited by GliderPilot

0

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>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.