hello all. i wasnt sure if this should go in the php or javascript forum but here we go. i have a php table pulling info from a mysql table. each row contains the name of a user. the users names are links which should take you to a bio page when clicked. i cant seem to get the coding right though. heres my code...

<?php
$mosttracks = mysql_query ("SELECT *, member_id as mem_id, name as n, COUNT(name) as cn, MIN(date_added) FROM tracks GROUP BY name ORDER BY COUNT(name) DESC, date_added asc LIMIT 3");

$number=1;
while($row = mysql_fetch_array($mosttracks))
{
echo "<tr>";
echo "<td align=left><a href=\"generic profile.php\" onclick=\"createcookie()\">" . $number . ". " . $row['n'] . " (" . $row['cn'] . ")" . "</a></td>";
echo "</tr>";
$number++;
$id=($row['mem_id']);
}
?>
<SCRIPT LANGUAGE="JavaScript">
function createcookie()
{
document.cookie = "UMAlink=<?php echo "$id"; ?>;"
}
</script>

...the code is supposed to get the users member id and put it ina cookie to be retrieved and used to populate info on a linked page called generic profile. im thinking the problem is with my javascript but if its a php issue i'll repost this in the php forum. thanks in advance for the help.

try with this:

<?php
$mosttracks = mysql_query ("SELECT *, member_id as mem_id, name as n, COUNT(name) as cn, MIN(date_added) FROM tracks GROUP BY name ORDER BY COUNT(name) DESC, date_added asc LIMIT 3");

$number=1;
while($row = mysql_fetch_array($mosttracks))
{
echo "<tr>";
echo "<td align=left><a href=\"generic profile.php\" onclick=\"createcookie(" . $row['n'] . " )\">" . $number . ". " . $row['n'] . " (" . $row['cn'] . ")" . "</a></td>";
echo "</tr>";
$number++;
}
?>
<SCRIPT LANGUAGE="JavaScript">
function createcookie(x)
{
document.cookie = "UMAlink="+x;
}
</script>

thanks for the help Shanti. i wasnt able to get this to work with your method(possibly by my own error) but i actually found an easier way of doing what it is that i'm trying to do. i simply passed the variable through the url (please bear with me b/c i am a newbie). any other newbies that may be interested in learning how to do this can follow this link http://www.plus2net.com/php_tutorial/variables2.php