0

This is what im trying to do. I qwery the database for 7 events and im attempting to do a rotating banner with link and a caption. However being new to this php coding im having issues with my echo statements. The title Tag is my caption. Im attempting to use nivo-slider and modify for my needs if your unfamilliar with it the website for it is http://nivo.dev7studios.com/. Im preety sure im close to fulilling my needs if I cant get a push over the hill it would be great. Been working on this stuff for 3 days with no avail.

Thanks so Much!!!

<?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 "<img src=";
   echo . $row['ImagePath'] . ;
   echo "alt=;
   echo "Country Music Nightclub Orlando";
   echo " ";
   echo "Title=" . $row['ArtistDate'] .";
   echo " /></a>";



   }

   mysql_close($con);
?>
5
Contributors
4
Replies
5
Views
4 Years
Discussion Span
Last Post by diafol
0

@azgold472

However being new to this php coding im having issues with my echo statements. The title Tag is my caption

Ok, You are getting close of finishing your project.

Instead of this:

echo "<img src=";
echo . $row['ImagePath'] . ;
echo "alt=;
echo "Country Music Nightclub Orlando";
echo " ";
echo "Title=" . $row['ArtistDate'] .";
echo " /></a>";

Try this:

echo "<img src='<?php echo $row['ImagePath']; ?>' alt='Country Music Nightclub Orlando' Title='<?php echo $row['ArtistDate']; ?>' />";

Let me know which echo I'm missing because I might not understand how you want the echoing to be. Can you explain it more?

Edited by LastMitch: grammer

1

Hi,

You can echo them in single line. Use single quotes to eliminate the extra efforts on escaping the double quotes.

Something like this

echo '<img src="'. $row['ImagePath'] .'" alt = "Country Music Nightclub Orlando" title="'. $row['ArtistDate'] .'" /> </a>';
0

@Veedeoo Methode is good ...

You can use your own methode with some changes like

while ($row = mysql_fetch_array($result)) {
    echo "<a><img src='";
    echo $row['ImagePath']."'";
    echo " alt=";
    echo "'Country Music Nightclub Orlando'";
    echo " Title='" .$row['ArtistDate']."'";
    echo " /></a>";

    }
0
echo "<img src=";
echo . $row['ImagePath'] . ;
echo "alt=;
echo "Country Music Nightclub Orlando";
echo " ";
echo "Title=" . $row['ArtistDate'] .";
echo " /></a>";

cAN BECOME:

echo "<img src='{$row['ImagePath']}' alt='Country Music Nightclub Orlando' title= '{$row['ArtistDate']}' />";

However - you seem to have a closing anchor tag (</a>), but no open tag (<a href="...">)

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.