/    Sign up×
Community /Pin to ProfileBookmark

Get parameter in URI on the same page.

Hi, i meet a problem: on the same page, i would like to get parameter in URI when i click on <a href….> link such as the following code (i am tried many way but can not, because i am new and only program php about 2 months).

[COLOR=”#FF0000″]home.php?page=den-da[/COLOR]: it is home page and i add more year=[COLOR=”#0000FF”]$nam[/COLOR] in to URI when click on link.

[code=html]<table width=”100%” border=”0″ align=”center” cellspacing=”3″>
<tr>
<td>
<?php
$sql_nam = @mysql_query(“select YEAR(ngaycv) as nam from congvan_den group by nam order by nam DESC”);
while($rownam = @mysql_fetch_array($sql_nam))
{
$nam = $rownam[‘nam’];
$asn = $nam.” | “;
echo ‘<a href=”home.php?page=den-da&year=’.$nam.'” style=”text-decoration: none”>’.$asn.'</a>’;
}
?>
</td>
</tr>
<tr>
<td>
<?php
//$actual_link = “http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]”;
if(isset($_GET[‘year’]))
{
$year = $_GET[‘year’];
$sql_thang = “select YEAR(ngaycv) as nam, MONTH(ngaycv) as thang from congvan_den where nam = “.$year.” group by nam, thang order by thang DESC”;
while($rowthang = @mysql_fetch_array($sql_thang))
{
$n = $rowthang[‘nam’];
$t = $rowthang[‘thang’];
$ast = $thang.” | “;
echo “<a href=’getyear.php?nam=”.$n.”&thang=”.$t.”‘ style=’text-decoration: none’>”.$ast.”</a>”;
}
}
?>
</td>
</tr></table>[/code]

Thanks for any your help.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@lengocanhvuauthorDec 15.2014 — I am sorry, That was my fault: i forget execute query:

$sql_thang = "select YEAR(ngaycv) as nam, MONTH(ngaycv) as thang from congvan_den where nam = ".$year." group by nam, thang order by thang DESC";

--> [B][COLOR="#FF0000"]@mysql_query[/COLOR][/B]("select YEAR(ngaycv) as nam, MONTH(ngaycv) as thang from congvan_den where nam = ".$year." group by nam, thang order by thang DESC")

That's all,
×

Success!

Help @lengocanhvu spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...