Help Please!

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
apple
Forum Newbie
Posts: 21
Joined: Wed Mar 03, 2004 12:50 am
Contact:

Help Please!

Post by apple »

Code: Select all

<?php
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
		echo '<tr><td><a href=apple.php?id=$row[0]">';
		echo "<align="left">" . stripslashes($row[1]) . "</a></td>";
		echo "<td align="left">$row[2]</td>";
		echo "<td align="left">$row[3]</td>";
		echo "<td align="left">$row[4]</td>";
		echo "</tr>";
?>

How can I put $row[0] to the apple.php?

Thanks in Advance.
User avatar
andre_c
Forum Contributor
Posts: 412
Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah

Post by andre_c »

I don't quite understand what you are trying to do, can you elaborate?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

echo '<tr><td><a href="apple.php?id='.$row[0].'">';
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

You pretty much had it right, maybe the problem is getting it from the URL?

How are you echoing/defining the variable $row[0] in the apple.php page?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

The problem as i saw it was..
echo '<tr><td><a href=apple.php?id=$row[0]">';

The single quotes won't interpolate/evaluate $row[0] .. plus there's a stray " in there :o
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

And that's why I don't program this early/late. ;)

I didn't catch that. heh

Apple, fix that parse error and see how things go.
apple
Forum Newbie
Posts: 21
Joined: Wed Mar 03, 2004 12:50 am
Contact:

Thanks

Post by apple »

:D Thanks! :lol:
doeboy
Forum Newbie
Posts: 10
Joined: Sun Mar 21, 2004 10:18 am

Post by doeboy »

Instead of

echo '<tr><td><a href="apple.php?id='.$row[0].'">';

You could use {}

So

echo '<tr><td><a href="apple.php?id={$row[0]}">';

I would much rather do this than make sure I have the right amount/types of quotes.
Post Reply