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);
?>
Member Avatar for LastMitch

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

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

@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>";

    }
Member Avatar for diafol
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="...">)

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.