hey all,

Just a quick one (I hope). I've only ever really done this as a button from something simple like a drop down box.

I have a table which is populated by a mysql db:

echo "<table class=\"gridtable\" cellpadding=\"0\" cellspacing=\"0\">
<tr>
<th>Employer</th>
<th>Vacancy</th>
<th>Vacancy Type</th>
<th>NoVacancies</th>
<th>Learning Provider</th>
<th>Contact Details</th>



</tr>";

while($row=mysqli_fetch_array($results)){

    echo'<tr><td>'.$row['Employer'].'</td>';
    echo'<td>'.$row['VacancyTitle'].'</td>';
    echo'<td>'.$row['VacancyType'].'</td>';    
    echo'<td>'.$row['NoVacancies'].'</td>';  
    echo'<td>'.$row['LearningProvider'].'</td>';   
    echo'<td>'. nl2br($row['ContactDetails']).'</td>';  
    echo'<tr>';

}

echo "</table>";

Heres my question, I want to be able to hyperlink each entry in the Employer row to their own page which will be Vacancy.php

in my head I thought of doing something like this:

 echo'<tr><td><a href="Vacancy.php?ID=". $row['ID']' . ' .$row['Employer'].'</td>';

but it didn't quite work.

Thanks guys

Recommended Answers

All 5 Replies

I'm not a PHP developer, but from an HTML perpesctive it doesn't appear that you properly closed the anchor element in your example that you indicated didn't work.

You didn't close the starting tag and didn't include the content or ending tag.

Hey Jorge, that was just an example I wrote here without an IDE :P so it's slightly off.

echo '<tr><td><a href="Vacancy.php?ID=' . $row['ID'] . '">' . $row['Employer'] . '</a></td>';

or

echo "<tr><td><a href=\"Vacancy.php?ID={$row['ID']}\">{$row['Employer']}</a></td>"; <-- Courtesy of Pritaeas on IRC

Thanks guys :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.