td url issue

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mister_Bob
Forum Newbie
Posts: 15
Joined: Thu Apr 08, 2010 6:59 pm

td url issue

Post 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
User avatar
Architek
Forum Commoner
Posts: 44
Joined: Wed Jul 01, 2009 5:01 am
Location: Portland OR

Re: td url issue

Post 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'] .";\'>";
Mister_Bob
Forum Newbie
Posts: 15
Joined: Thu Apr 08, 2010 6:59 pm

Re: td url issue

Post 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.
User avatar
Architek
Forum Commoner
Posts: 44
Joined: Wed Jul 01, 2009 5:01 am
Location: Portland OR

Re: td url issue

Post 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...
User avatar
Architek
Forum Commoner
Posts: 44
Joined: Wed Jul 01, 2009 5:01 am
Location: Portland OR

Re: td url issue

Post by Architek »

try this...

Code: Select all

echo "<tr onclick=\"document.location.href='http://somesite.com/index.php?post_id=".$row['Post_Id'] ."'\">";
Mister_Bob
Forum Newbie
Posts: 15
Joined: Thu Apr 08, 2010 6:59 pm

Re: td url issue

Post 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
User avatar
Architek
Forum Commoner
Posts: 44
Joined: Wed Jul 01, 2009 5:01 am
Location: Portland OR

Re: td url issue

Post by Architek »

yea that end section is a stickler some times.
Post Reply