Make entire row clickable - PHP approach

Hi programmers and web designers, I am working on a small system for the company I work with and everything is almost done (thanks for this site and the help from other sites...) except for this function where I want the entire row of the table my php codes generated, for now I was only able to make my second column clickable. I already tried googling but I can't find a workable solution. FYI, I am a noob and just starting to learn php.... thanks in advance...

while($info = mysql_fetch_array( $data ))  
{ echo "<tr> class='tablerows' align=center onclick=\"window.location=http://active_jobs.php?job_ticket='".$info['job_ticket']."'\">
<td>".$info['date']."</td>; 
<td><a> href=somefile.php?job_ticket=".$info['job_ticket'].">".$info['job_ticket']."</td>
<td>".$info['invoice_no']."</td> <td>".$info['customer']."</td>
<td>".$info['job_type']."</td> <td>".$info['complete_date']."</td>
<td>".$info['complete_time']."</td>
<td>".$info['artist_operator_prepress']."</td>
<td>".$info['status_prepress']."</td>
<td>".$info['status_press']."</td>
<td>".$info['status_postpress']."</td> <td
width='300'>".$info['remarks']."</td>"; echo "</tr>"; 
} echo
"</table>";

Thanks in advance for your help. Marco


Solution 1:

You can’t make entire rows “clickable” using PHP. PHP is a server-side language; you generate HTML and spit it out.

If you wanted to make an entire table row clickable, you’d either have to wrap it in an <a> (invalid HTML), or use a client-side language such as JavaScript to apply an event listener, that listens for the <tr> being clicked and redirects to whatever URL you want.

Solution 2:

You should check the generated html, you are closing the <tr> tag so the class and javascript are no longer part of it:

{ echo "<tr> class='tablerows' align=center onclick=\"window.location=http://active_jobs.php?job_ticket='".$info['job_ticket']."'\">
           ^ remove this and check the html again; it probably works now

You have the same mistake on the fourth line with the a tag.

Solution 3:

For those kind of live edit in table values with php, you can go for client side scripting language javascript & jquery with ajax..

For Reference :

Live Edit table With Ajax

It's worthy...