PHP and tables

Posted on 2005-04-30
Last Modified: 2009-12-16
In the code below I have a table with 1 row and 3 colums. How is the best way to place the 3 echo statements into the table, such as the first statement in the first column, etc.
Question by:mhoggatt1
    LVL 13

    Accepted Solution

    <td><?php echo "..."?></td>
    <td><?php echo "..."?></td>
    <td><?php echo "..."?></td>

    Author Comment

    Well that was easy enough. I thought it would be more difficult.
    LVL 1

    Expert Comment

    Ok here is my code :

    My question is  how do i change it for each record to in a separte row  in a table format.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    <html xmlns="">
    <title>Joke CMS: Manage Authors</title>
    <meta http-equiv="content-type"
        content="text/html; charset=iso-8859-1" />
    <!--<h1>Manage Authors</h1></!-->

    $dbcnx = @mysql_connect('', 'root','fireman');
    if (!$dbcnx) {
      exit('<p>Unable to connect to the ' .
          'database server at this time.</p>');

    if (!@mysql_select_db('guest')) {
      exit('<p>Unable to locate the joke ' .
          'database at this time.</p>');

    $authors = @mysql_query('SELECT id, firstname,lastname,email,Comment FROM guest');
    if (!$authors) {
      exit('<p>Error retrieving authors from database!<br />'.
          'Error: ' . mysql_error() . '</p>');

    while ($author = mysql_fetch_array($authors)) {
      $id = $author['id'];
      $firstname = htmlspecialchars($author['firstname']);
        $lastname = htmlspecialchars($author['lastname']);
          $Comment = htmlspecialchars($author['Comment']);
      $email = htmlspecialchars($author['email']);
      echo "firstname: ".$author["firstname"]."<br>\n";
         echo "Last Name: ".$author["lastname"]."<br>\n";
       echo "email: ".$author["email"]."<br>\n";
        echo "Comment: ".$author["Comment"]."<br>\n";
          "<a href='editauthor.php?id=$id'>Edit</a> ".
          "<a href='deleteauthor.php?id=$id'>Delete</a></li>";

    <p><a href="newauthor.php">Add new author</a></p>
    <p><a href="index.html">Return to front page</a></p>
    LVL 13

    Expert Comment

    Shouldn't you open your own question?
    LVL 1

    Expert Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    As this topic comes over and over again in different forms, I've finally decided to write a short (yea, right...) article / tutorial about pagination with PHP with MySQL database. There are dozens of these kind of tutorials, I know - I wanted to mak…
    Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now