ja_blackburn Posted February 14, 2010 Share Posted February 14, 2010 I want to dynamically generate content and for as many records as I have in my database but put it into CSS. My mark up template i want to use is as follows: <div class="panel"> <div class="inside"> //here i will echo an embed video from youtube <h2> //here i will echo a heading</h2> <p> // here i will echo description</p> </div> </div> I know how to do this with tables but want to use CSS. I know it will be something like: <? include'E:\domains\s\domain\user\private\mysql_connect.php'; mysql_select_db("pix", $con); $result = mysql_query("SELECT * FROM table); <div class="panel"> <div class="inside"> echo "<img src=' ". $row['embed_url']." ' alt="Mpora Video" />"; echo "<h2>" . $row['heading'] . "</h2>"; echo "<p>" . $row['caption'] . "<p>"; </div> </div> mysql_close($con); ?> But i know I am missing the loop statement and and am struggling. Please help! Thanks Link to comment https://forums.phpfreaks.com/topic/192042-php-echo-into-css/ Share on other sites More sharing options...
wildteen88 Posted February 14, 2010 Share Posted February 14, 2010 Just wrap the while loop around the HTML you wish to repeat. Which I assume is the following block of code <div class="inside"> echo "<img src=' ". $row['embed_url']." ' alt="Mpora Video" />"; echo "<h2>" . $row['heading'] . "</h2>"; echo "<p>" . $row['caption'] . "<p>"; </div> Example while($row = mysql_fetch_assoc($result)) { echo "<div class=\"inside\">"; echo "<img src=' ". $row['embed_url']." ' alt=\"Mpora Video\" />"; echo "<h2>" . $row['heading'] . "</h2>"; echo "<p>" . $row['caption'] . "<p>"; echo "</div>"; } Link to comment https://forums.phpfreaks.com/topic/192042-php-echo-into-css/#findComment-1012151 Share on other sites More sharing options...
ja_blackburn Posted February 14, 2010 Author Share Posted February 14, 2010 Thanks for the reply. I need the class called panel, so I have added it in. It doesn't like the first echo statement though? while($row = mysql_fetch_assoc($result)) { echo "<div class=\"panel\">"; echo "<div class=\"inside\">"; echo "<img src=' ". $row['embed_url']." ' alt=\"Mpora Video\" />"; echo "<h2>" . $row['heading'] . "</h2>"; echo "<p>" . $row['caption'] . "<p>"; echo "</div>"; echo "</div>"; } Parse error: syntax error, unexpected T_CLASS in E:\domains\s\domain.com\user\htdocs\gallery\index.php on line 42 Link to comment https://forums.phpfreaks.com/topic/192042-php-echo-into-css/#findComment-1012153 Share on other sites More sharing options...
wildteen88 Posted February 14, 2010 Share Posted February 14, 2010 The code you posted appears fine. I cannot see anything wrong it. Post lines 38 - 44 from gallery\index.php Link to comment https://forums.phpfreaks.com/topic/192042-php-echo-into-css/#findComment-1012158 Share on other sites More sharing options...
ja_blackburn Posted February 14, 2010 Author Share Posted February 14, 2010 This is whole lot: <? include'E:\domains\s\domain\user\private\mysql_connect.php'; mysql_select_db("pix", $con); $result = mysql_query("SELECT * FROM mpora); while($row = mysql_fetch_assoc($result)) { echo "<div class=\"panel\">"; echo "<div class=\"inside\">"; echo . $row['embed_url'].; echo "<h2>" . $row['heading'] . "</h2>"; echo "<p>" . $row['caption'] . "<p>"; echo "</div>"; echo "</div>"; } mysql_close($con); ?> The error is on line 40, which is the first echo of panel class. Driving me mad! Thanks for looking at it. Link to comment https://forums.phpfreaks.com/topic/192042-php-echo-into-css/#findComment-1012160 Share on other sites More sharing options...
khr2003 Posted February 14, 2010 Share Posted February 14, 2010 try this code: <?php include ('E:\domains\s\domain\user\private\mysql_connect.php'); mysql_select_db("pix", $con); $result = mysql_query("SELECT * FROM mpora); while($row = mysql_fetch_assoc($result)) { echo '<div class="panel">'; echo '<div class="inside">'; echo $row['embed_url']; echo '<h2>' . $row['heading'] . '</h2>'; echo '<p>' . $row['caption'] . '<p>'; echo '</div>'; echo '</div>'; } mysql_close($con); ?> also try to update your php version Link to comment https://forums.phpfreaks.com/topic/192042-php-echo-into-css/#findComment-1012346 Share on other sites More sharing options...
teamatomic Posted February 14, 2010 Share Posted February 14, 2010 check you quotes. $result = mysql_query("SELECT * FROM mpora); HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/192042-php-echo-into-css/#findComment-1012350 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.