Jump to content

php echo into CSS


ja_blackburn

Recommended Posts

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

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.