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
https://forums.phpfreaks.com/topic/95927-print-array-into-html-table/
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>";


}

?>

 

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>";

Archived

This topic is now archived and is closed to further replies.

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