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
Mister_Bob
Forum Newbie
Posts: 15 Joined: Thu Apr 08, 2010 6:59 pm
Post
by Mister_Bob » Thu Apr 08, 2010 7:07 pm
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'> €" . $row['Goal'] . "</td>";
echo "<td id='bid' align='center' width='50px'> €" . $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
Architek
Forum Commoner
Posts: 44 Joined: Wed Jul 01, 2009 5:01 am
Location: Portland OR
Post
by Architek » Thu Apr 08, 2010 9:13 pm
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
Post
by Mister_Bob » Thu Apr 08, 2010 9:36 pm
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.
Architek
Forum Commoner
Posts: 44 Joined: Wed Jul 01, 2009 5:01 am
Location: Portland OR
Post
by Architek » Thu Apr 08, 2010 11:12 pm
I am not sure I have tried linking a whole table row like that before. let me see if I can even create it...
Architek
Forum Commoner
Posts: 44 Joined: Wed Jul 01, 2009 5:01 am
Location: Portland OR
Post
by Architek » Thu Apr 08, 2010 11:35 pm
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
Post
by Mister_Bob » Fri Apr 09, 2010 7:41 am
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
Architek
Forum Commoner
Posts: 44 Joined: Wed Jul 01, 2009 5:01 am
Location: Portland OR
Post
by Architek » Fri Apr 09, 2010 10:39 am
yea that end section is a stickler some times.