sanderphp Posted May 16, 2008 Share Posted May 16, 2008 I would like to display a link in a table to a result of a query. My query works, but when I try to add the <a href I'm doing something wrong. How should this be written? echo '<td>' <a href="singlerecord.php?id='.$r['id'].'">'.$r['date'].'</a> '</td>'; Link to comment https://forums.phpfreaks.com/topic/105997-solved-syntax-question/ Share on other sites More sharing options...
DarkWater Posted May 16, 2008 Share Posted May 16, 2008 Sorry for being so blunt, but why the hell would you end your echo statement on the <td>? =X echo '<td> <a href="singlerecord.php?id='.$r['id'].'">'.$r['date'].'</a></td>'; Link to comment https://forums.phpfreaks.com/topic/105997-solved-syntax-question/#findComment-543220 Share on other sites More sharing options...
sanderphp Posted May 17, 2008 Author Share Posted May 17, 2008 Not really sure what you mean by that but I only want the hyperlink in the first cell of the table. I'm new at this and trying to learn. This is how I figured out how to make my page work. I'm sure there is a better way of doing this, but I'm just proud that I have made it this far. echo '<table>'; echo "<td>Date</td>"; echo "<td>Miles</td>"; echo "<td>Time</td>"; echo "<td>Average</td>"; foreach($results as $r){ echo '<tr>'; echo '<td> <a href="singlerecord.php?id='.$r['id'].'">'.$r['date'].'</a></td>'; echo '<td>' . $r['total_distance'] . '</td>'; echo '<td>' . $r['total_time'] . '</td>'; echo '<td>' . $r['ave_speed'] . '</td>'; echo '</tr>'; } echo '</table>'; Link to comment https://forums.phpfreaks.com/topic/105997-solved-syntax-question/#findComment-543324 Share on other sites More sharing options...
DarkWater Posted May 17, 2008 Share Posted May 17, 2008 No, it's fine how you're doing it. Does it work with my correction? Link to comment https://forums.phpfreaks.com/topic/105997-solved-syntax-question/#findComment-543326 Share on other sites More sharing options...
sanderphp Posted May 17, 2008 Author Share Posted May 17, 2008 yes thanks. Link to comment https://forums.phpfreaks.com/topic/105997-solved-syntax-question/#findComment-543329 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.