Jump to content

[SOLVED] NEED HELP WITH passing a variable via "ahref" - PLEEEEAAAASE


rsammy

Recommended Posts

Need help please...

i am trying to work on an application that involves sending and receiving internal emails. that system works fine. what i need to do though is to display the number of emails in the Inbox and Sent Items folders  on each page of the email part.

for instance - first is the main.php page. here the list of emails is displayed by default based on dates selected. On the left hand corner of the screen I have Inbox(xx) and Sent Items(xx) displayed where xx is the number of messages.

I am able to display thsi number on main.php. However, when the user clicks on one of the emails to get to the email boy on view.php, i am not able to display the numbers correctly. I need to do the same when user clicks on Reply button on this page to go the next page(compose.php).

This is how my code is on main.php where it works fine :


if ($user_auth == "2")
{
    $queryz="SELECT message, user_id, status, from_p, subject, DATE_FORMAT(received, '%m/%d/%Y') as date,
                  ID, to_email, time_sent, grp_id
                  FROM messages
                  WHERE received >='$dbdates'
                  and received <='$dbdate' order by ID DESC ";

    $querysent="SELECT messages.message, messages.user_id, messages.status, messages.from_p, messages.subject,
                      DATE_FORMAT(messages.received, '%m/%d/%Y') as date, messages.ID, messages.to_email, messages.time_sent,     
                      messages.grp_id
                      FROM messages, sent_messages
                      WHERE messages.received >='$dbdates'
                      and messages.received <='$dbdate'
                      and messages.id = sent_messages.message_id
                      and sent_messages.user_id='$userid'
                      order by messages.ID DESC";
}
else
{
    $queryz = "SELECT message, user_id, status, from_p, subject, DATE_FORMAT(received, '%m/%d/%Y') as date, ID, to_email,
                    time_sent, grp_id
                    FROM messages
                    WHERE request !='settodelete'
                    AND user_id='$userid' 
                    and received >='$dbdates'
                    and received <='$dbdate'
                    order by ID DESC ";

    $querysent="SELECT messages.message, messages.user_id, messages.status, messages.from_p, messages.subject,
                      DATE_FORMAT(messages.received, '%m/%d/%Y') as date, messages.ID, messages.to_email, messages.time_sent,
                      messages.grp_id
                      FROM messages, sent_messages
                      WHERE messages.request !='settodelete'
                      AND messages.user_id='$userid'
                      and messages.received >='$dbdates'
                      and messages.received <='$dbdate'
                      and messages.id = sent_messages.message_id
                      and sent_messages.user_id='$userid'
                      order by messages.ID DESC";
}

$resultz = mysql_query($queryz);
$num_rowz = mysql_num_rows($resultz);
$sendcounter = $num_rowz;
$from_p = $num_rowz["from_p"];

$resultsent = mysql_query($querysent);
$num_rowsent = mysql_num_rows($resultsent);

<tr>
          <td width="10">&nbsp;</td>
          <td width="213" align="left" valign="top"> <table width="240" border="1" cellspacing="0" cellpadding="0" bordercolor="#006699">
              <tr>
                <td width="236" align="left" valign="top"> <table width="222" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="222">&nbsp;</td>
                    </tr>
                    <tr>
                      <td> <div align="center"><img src="images/selectedfolder-icon.gif" width="16" height="13">
                          <a href="main.php">Inbox
                          ( <?PHP print($num_rowz); ?> )</a></div></td>
                    </tr>
                    <tr>
<td> <div align="center"><img src="images/selectedfolder-icon.gif" width="16" height="13">
  <a href="sent.php">Sent Items  ( <?PHP print($num_rowsent); ?> )</a></div></td>
      </tr>
                    <tr>
                      <td> <div align="center"><img src="images/compose-button.gif" width="21" height="15">
                          <a href="compose.php">Compose</a></div></td>
                    </tr>

        .
        .
        .

      if ($num_rowz > 0)
      {
        .
        .
        .

        <td><a href='view.php?$sendcounter=10'<?PHP
                  print("?mess_id=".$rowz"ID"]. "&m1=".$m1. "&d1=".$d1 . "&y1=".$y1. "&m2=".$m2 . "&d2=".$d2 . "&y2=".$y2 );?>" >
                  <?PHP
$queryfrom = "SELECT user_fname, user_lname, user_email FROM user_mgr WHERE user_email='$from_p' ";
$resultfrom = mysql_query($queryfrom);
$rowfrom = mysql_fetch_array($resultfrom);
            $fname= $rowfrom["user_fname"];
$lname=$rowfrom["user_lname"];
$uname = $user_fname ." ". $user_lname;

print ($uname);
?></a></td>

                  <td><a href="view.php?sendcounter='$sendcounter'"<?PHP
                      print("?mess_id=".$rowz["ID"]. "&m1=".$m1. "&d1=".$d1 . "&y1=".$y1. "&m2=".$m2 . "&d2=".$d2 . "&y2=".$y2 ); ?>"><?PHP print($rowz["subject"]);
                      ?></a></td>
                  <td><a href="view.php?sendcounter='$sendcounter'"<?PHP print("?mess_id=".$rowz["ID"]. "&m1=".$m1. "&d1=".$d1 . "&y1=".$y1. "&m2=".$m2 . "&d2=".$d2 . "&y2=".$y2 ); ?>"><?PHP print($rowz["date"]."&nbsp;&nbsp;".$row["time_sent"]); ?></a></td>
                  <td colspan="8">&nbsp;</td>
                </tr>

..........

when i click on one of the links above, it takes me to view.php and there the code is shown in my reply to this post
Link to comment
Share on other sites

$sendcounter=$_GET["sendcounter"];

          .
          .
          .
if ($user_auth == "2")
{

$querydisplay = "SELECT messages.message, messages.user_id, messages.status, messages.from_p, messages.subject,
  DATE_FORMAT(messages.received, '%m/%d/%Y') as date, messages.ID, messages.to_email, messages.time_sent, messages.grp_id,
  user_mgr.user_fname, user_mgr.user_lname, user_mgr.user_id, user_mgr.user_email
  FROM messages, user_mgr
  WHERE messages.ID='$mess_id'
  AND user_mgr.user_id = messages.user_id";
}
else
{
$querydisplay = "SELECT message, user_id, status, from_p, subject, DATE_FORMAT(received, '%m/%d/%Y') as date, ID, to_email, time_sent, grp_id FROM messages WHERE user_id='$userid' AND ID='$mess_id' AND request !='settodelete'";

}

        <tr>
          <td width="10">&nbsp;</td>
          <td width="235" bgcolor="#006699"> <div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF"><b>FOLDERS</b></font></div></td>
          <td width="1">&nbsp;</td>
          <td width="25">&nbsp;</td>
        </tr>
        <tr>
          <td width="10">&nbsp;</td>
          <td width="235" align="left" valign="top"> <table width="253" border="1" cellspacing="0" cellpadding="0" bordercolor="#006699">
              <tr>
                <td width="249" align="left" valign="top"> <table width="224" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="224">&nbsp;</td>
                    </tr>

[color=red][font=Verdana]***************[color=red][font=Verdana]NOW THIS IS WHERE I AM TRYING TO PRINT IT ON THE SCREEN[/font][/color]*********************[/font][/color]                   
                  <tr>
                      <td> <div align="center"><img src="images/selectedfolder-icon.gif" width="16" height="13">
                          <a href="main.php">Inbox
                                  ( <?PHP if ($sendcounter > 0){ print($sendcounter); } else { print("111");} ?> )
                          </a></div></td>
                    </tr>
                    <tr>
                          <td> <div align="center"><img src="images/selectedfolder-icon.gif" width="16" height="13">
    <a href="sent.php">Sent Items ( <?PHP if ($num_rowz > 0){ print($num_rowsent); } else { print       
                                                                                                                                          ("111");} ? )                       
                              </a></div></td>
      </tr>
                    <tr>
                      <td> <div align="center"><img src="images/compose-button.gif" width="21" height="15">
                          <a href="compose.php">Compose</a></div></td>
                    </tr>
                    <tr>
                      <td>
                        <?PHP

please help me guys as i am stuck badly here.

thanx is advance!
Link to comment
Share on other sites

thanx for ur reply, skatecrazy. yes, i am aware that my end php tag shud be ?>

i had to clip off some code here as it wud not let me post the whole code - may be there is a limit on the number of characters or lines?!

also, i didnt get ur comment on the third line... wat did u mean? can u clarify pelase?
Link to comment
Share on other sites

thorpe,

i am kinda new to php. thats the reason i posted all the code there, so someone can correct me if am wrong somewhere.

my problem is that i shud display the number of items(mails/messages) in the brackets next to Inbox and Sent Items folder names in view.php

I am trying to pass the variable that contains the number of messages - $sendcounter - to view.php from main.php via the url. it does not get through.  how do i retrieve(and display) the value from this variable in view.php?

thanx
Link to comment
Share on other sites

OK here it is:

I am running this query to get the numbre of rows into $num_rowz

$queryz = "SELECT message, user_id, status, from_p, subject, DATE_FORMAT(received, '%m/%d/%Y') as date, ID, to_email, time_sent, grp_id FROM messages WHERE request !='settodelete' AND user_id='$userid'  and received >='$dbdates' and received <='$dbdate' order by ID DESC ";
$resultz = mysql_query($queryz);
$num_rowz = mysql_num_rows($resultz);
$sendcounter = $num_rowz;
I am then passing this variable $sendcounter to the next page via the link to that page. this is how i am doing it...

<td><a href="view.php?sendcounter=$sendcounter"<?PHP
      print("?mess_id=".$rowz["ID"]. "&m1=".$m1. "&d1=".$d1 . "&y1=".$y1. "&m2=".$m2 . "&d2=".$d2 . "&y2=".$y2 ); ?>" >
      <?PHP
            $queryfrom = "SELECT user_fname, user_lname, user_email FROM user_mgr WHERE  user_email='$from_p' ";
$resultfrom = mysql_query($queryfrom);
$rowfrom = mysql_fetch_array($resultfrom);
$fname= $rowfrom["user_fname"];
            $lname=$rowfrom["user_lname"];
$uname = $user_fname ." ". $user_lname;
print ($uname);
      ?></a></td>
     
<td><a href="view.php?sendcounter=$sendcounter"<?PHP print("?mess_id=".$rowz["ID"]. "&m1=".$m1. "&d1=".$d1 . "&y1=".$y1. "&m2=".$m2 . "&d2=".$d2 . "&y2=".$y2 ); ?>"><?PHP print($rowz["subject"]); ?></a></td>

<td><a href="view.php?sendcounter=$sendcounter"<?PHP print("?mess_id=".$rowz["ID"]. "&m1=".$m1. "&d1=".$d1 . "&y1=".$y1. "&m2=".$m2 . "&d2=".$d2 . "&y2=".$y2 ); ?>"><?PHP print($rowz["date"]."&nbsp;&nbsp;".$row["time_sent"]); ?></a></td>
                                        <td colspan="8">&nbsp;</td>
                </tr>
on the next page, view.php, I am doing this...

$sendcounter=$_GET["sendcounter"];

i then try to display it on this page and it only displays a blank as the variable carries the value '$sendcounter' and not the number of rows that it is supposed to carry!!!

this is how i am trying ot display it on the next page(view.php) ---
      <tr>
      <td> <div align="center"><img src="images/selectedfolder-icon.gif" width="16" height="13">
                          <a href="main.php">Inbox
                          ( <?PHP if ($num_rowz > 0){ print($num_rowz); } else { print("111");} ?> )
      </a></div></td>
      </tr>

**********

am i doing the right thing? is there something that i am missing. i really need some HELP here pleaaaaaaaaaaaase!
Link to comment
Share on other sites

Your $sendcounter is outside of php so is not being parsed. Try something like....

[code=php:0]
echo "<td><a href=\"view.php?sendcounter=$sendcounter&mess_id={$rowz['ID']}&m1=$m1&d1=$d1&y1=$y1&m2=$m2&d2=$d2&y2=$y2\">{$rowz['subject']}</a></td>";
[/code]

I also don't understand what the [ / url ] tag is doing in there. It should be a < / a > as ive shown.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.