Page 1 of 1

td url issue

Posted: Thu Apr 08, 2010 7:07 pm
by Mister_Bob
Ok so I am a complete noob to PHP and am trying to build my website from the ground up as I learn. I have a database in place which I am calling some data from to be displayed within a table.

Code: Select all

echo "<table width='748px' border='1'>";
  {
  echo "<tr>";
  echo "<td id='desc' height='25px' width='600px'>" . $row['SDesc'] . "</td>";
  echo "<td id='goal' align='center' width='50px'> &euro;" . $row['Goal'] . "</td>";
  echo "<td id='bid' align='center' width='50px'> &euro;" . $row['Bid'] . "</td>";
  echo "<td align='center' width='40px'> <img src='images/bid.jpg' width='40' height='22' align='right' alt='Bid'/> </td>";
  echo "</tr>";
  }
echo "</table>";
Everything is working fine except i wish to have the entire entry link to its respecive page so from what little I know I think I can achieve this with

Code: Select all

echo "<tr onclick=\”document.location.href='index.php?post_id=" . $row[Post_Id'] .";\'>";
I am just having some trouble with the syntax though and keep getting errors back.

Thank you in advance to anyone that can help me with this.

Bob

Re: td url issue

Posted: Thu Apr 08, 2010 9:13 pm
by Architek
you are missing an apostrophe in the row array item just before the "P" in Post.

Code: Select all

echo "<tr onclick=\”document.location.href='index.php?post_id=" . $row['Post_Id'] .";\'>";

you could also try to use the absolute path to the page instead of a relative one

Code: Select all

echo "<tr onclick=\”document.location.href='http://somesite.com/index.php?post_id=" . $row['Post_Id'] .";\'>";

Re: td url issue

Posted: Thu Apr 08, 2010 9:36 pm
by Mister_Bob
Thankyou for your response, I put

Code: Select all

echo "<tr onclick=\”document.location.href='http://somesite.com/index.php?post_id=" . $row['Post_Id'] .";\'>";
But getting error message from ie: Message: Invalid character and firefore just does nothing. I think PHP hates me :(

Anymore suggestions would be appreciated.

Re: td url issue

Posted: Thu Apr 08, 2010 11:12 pm
by Architek
I am not sure I have tried linking a whole table row like that before. let me see if I can even create it...

Re: td url issue

Posted: Thu Apr 08, 2010 11:35 pm
by Architek
try this...

Code: Select all

echo "<tr onclick=\"document.location.href='http://somesite.com/index.php?post_id=".$row['Post_Id'] ."'\">";

Re: td url issue

Posted: Fri Apr 09, 2010 7:41 am
by Mister_Bob
Thank you so much, I would never have noticed what was differernt if I hadn''t compared them. It works fine now.

Thank you for your time.

Bob

Re: td url issue

Posted: Fri Apr 09, 2010 10:39 am
by Architek
yea that end section is a stickler some times.