PHP Table Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
frosty16
Forum Newbie
Posts: 19
Joined: Sat Jan 26, 2008 6:58 am

PHP Table Question

Post by frosty16 »

Heya guys

I am new to PHP and am just tryin to display data from a mysql database in a form however its not working and i was wondering if someone could help me out.

I have got the following code:

Code: Select all

<?php
    $user="PHC";
    $host="localhost";
    $password="password";
    $database = "PHCAdminSystem";
    $con = mysqli_connect($host, $user, $password, $database)
           or die ("Couldn't connect to the PHC SQL Server.  Please try again or if the problem persists contact LKF Computing");
    $query = "SELECT * FROM customer_system_report_orders_placed";
    $result = mysqli_query($con, $query)
              or die ("Couldn't create this report.  Please try again or if the problem persists contact LKF Computing");
    while($row = mysqli_fethch_assoc($result))
    {
        extract($row);
        $f_price = number_format($TotalCost,2);
        echo "<table width="656" border="1" align="center">
  <tr>
    <td><table width="648" border="0">
      <tr>
        <td width="98" class="style6">Title:</td>
        <td width="538" class="style6">&nbsp;</td>
      </tr>
      <tr>
        <td class="style6">First Name: </td>
        <td class="style6">&nbsp;</td>
      </tr>
      <tr>
        <td class="style6">Surname:</td>
        <td class="style6">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><table width="648" border="0">
      <tr>
        <td width="196" class="style6">Address 1: </td>
        <td width="196" class="style6">&nbsp;</td>
      </tr>
      <tr>
        <td class="style6">Address 2:</td>
        <td class="style6">&nbsp;</td>
      </tr>
      <tr>
        <td class="style6">Address 3: </td>
        <td class="style6">&nbsp;</td>
      </tr>
      <tr>
        <td class="style6">Address 4: </td>
        <td class="style6">&nbsp;</td>
      </tr>
      <tr>
        <td class="style6">Postcode:</td>
        <td class="style6">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><table width="648" border="0">
      <tr>
        <td><span class="style6">Date Ordered: </span></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><span class="style6">Total Cost: </span></td>
        <td>&nbsp;</td>
      </tr>
    </table></td>
  </tr> <br>";
 }
echo "</table>";
?>
However when i run it i get the following error:

"Parse error: syntax error, unexpected T_LNUMBER, expecting ',' or ';' in C:\AppServ\www\PHCAS\OrdersPlaces.php on line 49"

Where line 49 is the one that contains the following:

"echo "<table width="656" border="1" align="center">"

What am i doing wrong?

Thank you in advance

Frosty
Last edited by Benjamin on Sat May 02, 2009 12:12 pm, edited 1 time in total.
Reason: Changed code type from text to php.
divito
Forum Commoner
Posts: 89
Joined: Sun Feb 22, 2009 7:29 am

Re: PHP Table Question

Post by divito »

1. You're using double quotations with your HTML; use single.
2. You don't place a semi-colon at the end of the echo.
3. I've found that it's sometimes easier to close off your PHP when you plan to have blocks of HTML so that there will be no issues.
frosty16
Forum Newbie
Posts: 19
Joined: Sat Jan 26, 2008 6:58 am

Re: PHP Table Question

Post by frosty16 »

Ok i have actioned 1 & 2 however with the finish the PHP and have the HTML seperate how can i then create a new table for each record in the database and place data from the database into each table?
divito
Forum Commoner
Posts: 89
Joined: Sun Feb 22, 2009 7:29 am

Re: PHP Table Question

Post by divito »

If it runs properly after fixing what you did, then you don't really need to worry about closing off the PHP before the HTML.
frosty16
Forum Newbie
Posts: 19
Joined: Sat Jan 26, 2008 6:58 am

Re: PHP Table Question

Post by frosty16 »

ok brilliant thank you very much
Post Reply