php - $result = mysql_query() -


i brand new php/mysql, please excuse level of knowledge here, , feel free direct me in better direction, if doing out of date.

i pulling in information database fill in landing page. layout starts image on left , headline right. here, using query retrieve page headline text:

<?php $result = mysql_query("select banner_headline low_engagement thread_segment = 'a3'", $connection); if(!$result) {     die("database query failed: " . mysql_error()); } while ($row = mysql_fetch_array($result)) {     echo $row["banner_headline"]; } ?> 

this works great, want duplicate headline text inside img alt tag. best way duplicate queries information inside alt tag? there abbreviated code can use this, or better copy code inside alt tag , run twice?

thanks insight!

you are, comment says, using deprecated functions, answer question, should declare variable hold value once retrieve database can use whenever want.

<?php $result = mysql_query("select banner_headline low_engagement thread_segment = 'a3'", $connection); if(!$result) {     die("database query failed: " . mysql_error()); }  $bannerheadline = "";  while ($row = mysql_fetch_array($result)) {     $bannerheadline = $row["banner_headline"]; }  echo $bannerheadline; //use wherever want  ?> 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -