Jump to content

[SOLVED] Imbedding php in html


ahvceo

Recommended Posts

Hi All,

 

I got this off of the web because it looked like an interesting thing to try.  If it works I would be able to fill a table from a database, which is something I would like to play with.

 

Here's the code...

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

  <head>

    <title>Make Table</title>

  </head>

  <body>

    <table>

      <tr>

        <?php for($l = 1; $l <=7; $l++): ?>

          <td align="center">

              <?php if($l >= 5;) 

                {echo "yes";}

              else

                {echo "no";}

              ?>

          </td>

        <?php endfor; ?>

      </tr>

    </table>

  </body>

</html>

 

It is supposed to create a table with 7 columns in 1 row with "no" in the first 5 columns and "yes" in the last 2.  Of course the code doesn't work although it looks to me as if it should. Can anyone shed some light on why it doesn't work?

 

And yet again the "echo" statement gives me nothing.  Does the "echo" statement ever do anything?

 

Thanks

ahvceo

Link to comment
Share on other sites

Hi Dannie10

 

Thanks for the quick reply.  I tried your changes and I get the following output when I run it.

 

 

5) {echo "yes";} else {echo "no";} ?>

 

Here's my code copied from the source...

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">

<html>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

  <head>

    <title>Make Table</title>

  </head>

  <body>

    <table>

      <tr>

        <?php for($l = 1; $l <=7; $l++): ?>

          <td align="center">

              <?php if($l > 5) 

                {echo "yes";}

              else

    {echo "no";}

              ?>

          </td>

        <?php endfor; ?>

      </tr>

    </table>

  </body>

</html>

 

Any suggestions?  I would really like to be able to embed php to make tables.  You could have a bunch of images in a database and display them in a nice grid.

Thanks

ahvceo

 

Link to comment
Share on other sites

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
  <head>
    <title>Make Table</title>
  </head>
  <body>
    <table>
      <tr>
        <?php for($l = 1; $l <=7; $l++): ?>
          <td align="center">
              <?php if($l > 5) 
                 {echo "yes";}
              else
                 {echo "no";}
              ?>
          </td>
        <?php endfor; ?>
      </tr>
    </table>
  </body>
</html>

 

Will output:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
  <head>
    <title>Make Table</title>
  </head>
  <body>
    <table>
      <tr>
                  <td align="center">

              no          </td>
                  <td align="center">
              no          </td>
                  <td align="center">
              no          </td>
                  <td align="center">
              no          </td>

                  <td align="center">
              no          </td>
                  <td align="center">
              yes          </td>
                  <td align="center">
              yes          </td>
              </tr>

    </table>
  </body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.