Guest elthomo Posted March 13, 2008 Share Posted March 13, 2008 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>"; } ?> Quote Link to comment Share on other sites More sharing options...
Guest elthomo Posted March 13, 2008 Share Posted March 13, 2008 removed Quote Link to comment Share on other sites More sharing options...
php_dave Posted March 13, 2008 Share Posted March 13, 2008 Your vars would be part of the $row[] array so would be accessed like echo "<td>$row['dossiernummer']<td>"; echo "<td>$row['achternaam']<td>"; echo "<td>$row['email']<td>"; /// etc.. HTH Dave Quote Link to comment Share on other sites More sharing options...
Guest elthomo Posted March 13, 2008 Share Posted March 13, 2008 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>"; } ?> Quote Link to comment Share on other sites More sharing options...
php_dave Posted March 13, 2008 Share Posted March 13, 2008 My bad - echo "<TD>".$row['dossiernummer']."</TD>"; You will need to break the echo statement and concatinate the var into it for each of them like above. Dave Quote Link to comment Share on other sites More sharing options...
Guest elthomo Posted March 13, 2008 Share Posted March 13, 2008 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>"; Quote Link to comment Share on other sites More sharing options...
conker87 Posted March 13, 2008 Share Posted March 13, 2008 If you don't want to break the echo, you can also encase them in {} curly brackets. echo "<td>{$row['dossiernummer']}<td>"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.