Jump to content

Print array into html table


Guest elthomo

Recommended Posts

Guest elthomo

I'm trying to get my results to fit into a html table but I can seem to get it to work. Could someone please tell me what i need to add to my code to get it to work. I assume its something like, I need to define the the variables from the results of the query???

 

TIA

 

<?php
// Make a MySQL Connection
$query = "SELECT * FROM gespraak WHERE $dossiernummer = gespraak.dossiernummer";

$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_object($result)){

echo "<table border=1 cellpadding='0' class=style1>";
echo "<tr bgcolor=#CCFFFF><th>Dossiernummer<th><th>Achternaam<th><th>email<th><th>Tijd<th><th>Week<th><th>Jaar<th><th>Gespreck</th>";
echo "<tr>";
echo "<td>$dossiernummer<td>";
echo    "<td>$achternaam<td>";
echo    "<td>$email<td>";
echo    "<td>$tijd<td>";
echo    "<td>$week<td>";
echo    "<td>$jaar<td>";
echo    "<td>$gesprek<td>";
echo  "</tr>";
echo "</table class=style1>";


}

?>

Link to comment
Share on other sites

Guest elthomo

Thanks Dave

 

That actually how I thought it would work and I tried it before posting on this board. But!....... I get an error message:

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/test2.php on line 12

 

I'm somewhat confused, anyway code looks like this now

 

<?php
// Make a MySQL Connection
// Construct our join query
$query = "SELECT * FROM gespraak WHERE $dossiernummer = gespraak.dossiernummer";

$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_object($result)){

echo "<table border=1 cellpadding='0' class=style1>";
echo "<tr bgcolor=#CCFFFF><th>Dossiernummer<th><th>Achternaam<th><th>email<th><th>Tijd<th><th>Week<th><th>Jaar<th><th>Gespreck</th>";
echo "<tr>";
echo "<td>$row['dossiernummer']<td>";
echo "<td>$row['achternaam']<td>";
echo    "<td>$row['email']<td>";
echo    "<td>$row['tijd']<td>";
echo    "<td>$row['week']<td>";
echo    "<td>$row['jaar']<td>";
echo    "<td>$row['gesprek']<td>";
echo  "</tr>";
echo "</table class=style1>";


}

?>

 

Link to comment
Share on other sites

Guest elthomo

Ok....... I don't know why but this works

 

echo    "<td>" .$row->dossiernummer . "<td>";
echo    "<td>" .$row->achternaam . "<td>";
echo    "<td>" .$row->email . "<td>";
echo    "<td>" .$row->tijd . "<td>";
echo    "<td>" .$row->week . "<td>";
echo    "<td>" .$row->jaar . "<td>";
echo    "<td>" .$row->gesprek . "<td>";

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.