Page 1 of 1

PHP Table Question

Posted: Sat May 02, 2009 7:26 am
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

Re: PHP Table Question

Posted: Sat May 02, 2009 7:48 am
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.

Re: PHP Table Question

Posted: Sat May 02, 2009 7:58 am
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?

Re: PHP Table Question

Posted: Sat May 02, 2009 8:13 am
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.

Re: PHP Table Question

Posted: Sat May 02, 2009 8:17 am
by frosty16
ok brilliant thank you very much