rsammy Posted October 26, 2006 Share Posted October 26, 2006 why am in not able to post a new thread? i have a query and need help badly!!!! Quote Link to comment https://forums.phpfreaks.com/topic/25250-solved-need-help-with-passing-a-variable-via-ahref-pleeeeaaaase/ Share on other sites More sharing options...
rsammy Posted October 26, 2006 Author Share Posted October 26, 2006 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"> </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"> </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"]." ".$row["time_sent"]); ?></a></td> <td colspan="8"> </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 Quote Link to comment https://forums.phpfreaks.com/topic/25250-solved-need-help-with-passing-a-variable-via-ahref-pleeeeaaaase/#findComment-115128 Share on other sites More sharing options...
rsammy Posted October 26, 2006 Author Share Posted October 26, 2006 $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"> </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"> </td> <td width="25"> </td> </tr> <tr> <td width="10"> </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"> </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> <?PHPplease help me guys as i am stuck badly here. thanx is advance! Quote Link to comment https://forums.phpfreaks.com/topic/25250-solved-need-help-with-passing-a-variable-via-ahref-pleeeeaaaase/#findComment-115132 Share on other sites More sharing options...
Skatecrazy1 Posted October 27, 2006 Share Posted October 27, 2006 your end php tag shouldn't be <?PHP it should be ?>also try putting your starting <?php tag in lowercase.and the random [/url] bbcode tags can't be helping either. Quote Link to comment https://forums.phpfreaks.com/topic/25250-solved-need-help-with-passing-a-variable-via-ahref-pleeeeaaaase/#findComment-115172 Share on other sites More sharing options...
rsammy Posted October 27, 2006 Author Share Posted October 27, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/25250-solved-need-help-with-passing-a-variable-via-ahref-pleeeeaaaase/#findComment-115206 Share on other sites More sharing options...
trq Posted October 27, 2006 Share Posted October 27, 2006 Do we really need to see all that code? Please narrow your problem down to a few lines and be much more specific with the description of your problem. Quote Link to comment https://forums.phpfreaks.com/topic/25250-solved-need-help-with-passing-a-variable-via-ahref-pleeeeaaaase/#findComment-115243 Share on other sites More sharing options...
rsammy Posted October 27, 2006 Author Share Posted October 27, 2006 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.phpI 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 Quote Link to comment https://forums.phpfreaks.com/topic/25250-solved-need-help-with-passing-a-variable-via-ahref-pleeeeaaaase/#findComment-115351 Share on other sites More sharing options...
rsammy Posted October 31, 2006 Author Share Posted October 31, 2006 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"]." ".$row["time_sent"]); ?></a></td> <td colspan="8"> </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! Quote Link to comment https://forums.phpfreaks.com/topic/25250-solved-need-help-with-passing-a-variable-via-ahref-pleeeeaaaase/#findComment-117514 Share on other sites More sharing options...
trq Posted October 31, 2006 Share Posted October 31, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/25250-solved-need-help-with-passing-a-variable-via-ahref-pleeeeaaaase/#findComment-117527 Share on other sites More sharing options...
kenrbnsn Posted October 31, 2006 Share Posted October 31, 2006 The [nobbc][/url][/nobbc] tag was inserted by the forum software because it thought it saw a URL to translate. That is why all code inserted should be surrounded by the [b][color=red][nobbc][code][/code][/nobbc][/color][/b] tags.Ken Quote Link to comment https://forums.phpfreaks.com/topic/25250-solved-need-help-with-passing-a-variable-via-ahref-pleeeeaaaase/#findComment-117540 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.