Forum Moderators: coopster

Message Too Old, No Replies

passing multiple variable id's....

i'm not sure how to set this up

         

mylungsarempty

6:26 pm on Jan 28, 2004 (gmt 0)

10+ Year Member



Here's the code i use to display the subjects of a user's messsages:

####################
<B><U><?=$username?>'s Inbox</U>:</B>

<BR><BR>

<?

mysql_select_db($db, $con);

$find_my_mail="SELECT * FROM messages WHERE recipient='$username'";

$all_my_mail=mysql_query($find_my_mail);

if (!$all_my_mail) {

die('<p>error retrieving mail<br>' . 'Error: ' . mysql_error() . '</p>');

} while ($result = mysql_fetch_array($all_my_mail))

{

$id = $result['id'];
$recipient = $result['recipient'];
$sender = $result['sender'];
$subject = $result['subject'];
$body = $result['body'];
$maildate = $result['date'];
$ifread = $result['ifread'];

echo '<TABLE border="0" cellspacing="2"><colgroup><col valign="top"><col valign="top"><col valign="top"><col valign="top"><col valign="top"><col valign="top"></colgroup><TR><TD><P align="right"><font color="maroon">From: </font></TD><TD><P>' . $sender . '</TD></TR><TR><TD><P align="right"><font color="maroon">Subject: </font></TD><TD><P><B><U><A HREF="right.php?var=var15" target="right" onFocus="if(this.blur)this.blur()"><font color="gold">' . $subject . '</font></A></U></B></TD></TR><TR><TD><P align="right"><font color="maroon"><I>date: </I></font></TD><TD><P><font color="BBBBBB"><I>' . $maildate . '</I></font></TD></TR></TABLE><BR>';

unset($id);
unset($recipient);
unset($sender);
unset($subject);
unset($body);
unset($maildate);
unset($ifread);

}

?>
####################

...but what i'm not sure of, is how to pass each individual message's ID along with the click of the link, so i can display the message in its full context in the other frame of the page. Any suggestions?

coopster

6:35 pm on Jan 28, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Can you append it to the existing query string in your
href
attribute?

<A HREF="right.php?var=var15&amp;id=' . $id . '" target="right"

Forgot the 'ampersand key value equals' part of the query string

[edited by: coopster at 8:49 pm (utc) on Jan. 28, 2004]

mylungsarempty

7:05 pm on Jan 28, 2004 (gmt 0)

10+ Year Member



that sounds good... how would i retrieve the $id from the URL in my php code?

the?var=var15 refers to which page i want displayed in right.php...

every var--starting with 00--is a different page of the site, and var15 is the page which would display individual messages. Appending the $id to the URL could, in theory, work... but i would have to somehow parse the URL in right.php to say "if var begins with 15, assign following digits to $id" . . . and i'm learning this PHP junk as i go along, so, i'm not sure how to go about doing that exactly. perhaps i can integrate an array to make this work out for me?

Romeo

8:20 pm on Jan 28, 2004 (gmt 0)

10+ Year Member



passing several variables in a GET URL string?
try this:
echo "<A HREF=\"right.php?var=var15&id=$id\" ...
and in the right.php page called you will find the var in $_GET["var"] and the id in $_GET["id"].
You should, however, replace the "&" with a "&amp;" in the above link to send valid html.

Regards,
R.