hello well my problem is that am displaying a list of messages like mails and when you want to read full message u need to go to rmq-demande.php where the full message appeard : here how my list of messages is presented i need to get the id of each message when clicked on it :
<?php
$sql_rev=mysql_query("SELECT * from demande_revision WHERE lu='nl' ");
$comment_count=mysql_num_rows($sql_rev);
?>
<li class="xn-icon-button pull-right">
<a href="#"><span class="fa fa-comments"></span></a>
<div class="informer informer-danger"> <?php if($comment_count!=0)
{
echo "$comment_count nouveau";
}?>
</div>
<div class="panel panel-primary animated zoomIn xn-drop-left xn-panel-dragging">
<div class="panel-heading">
<h3 class="panel-title">
<span class="fa fa-comments"></span> </h3>
<div class="pull-right">
<span class="label label-danger"><?php if($comment_count!=0)
{
echo "$comment_count nouveau";
}?> </span>
</div>
</div>
<div class="panel-body list-group list-group-contacts scroll" style="height: 200px;">
<?php
while ( $msg=mysql_fetch_assoc($sql_rev)) {
$idd=$_SESSION['id_dem']=$msg['id_dem'];
$title=$msg['title'];
$dem=$msg['msg'];
echo "
<form name=\"theform\" method=\"post\" action=\"rmq-demande.php\">
<input type=\"hidden\" name=\"id_demm\" value=\"$idd\">
<a href=\"rmq-demande.php\" class=\"list-group-item\" target='_blank'>
<span class=\"contacts-title\">$title</span>
<p>$dem</p>
</a> </form>";
}
?>
</div>
in the other page (rmq-demande.php) here is how i wanted to get the variable $idd:
$dem=$_POST['id_demm'];
but it gets nothing plz help
答案 0 :(得分:0)
你可以用2(2)种方式完成: -
1. remove link and create submit button like below:-
echo "
<form name=\"theform\" method=\"post\" action=\"rmq-demande.php\">
<input type=\"hidden\" name=\"id_demm\" value=\"$idd\">
<span class=\"contacts-title\">$title</span>
<p>$dem</p>
<input type = \"submit\" name= \"submit\" value=\"submit\" >
</a> </form>";
或者删除表单并将ID附加到以下链接中: -
echo "<a href=\"rmq-demande.php?id_demm=$idd\" class=\"list-group-item\" target='_blank'>
<span class=\"contacts-title\">$title</span>
<p>$dem</p>";
但是为了在php中获取id,你需要这样做: -
$dem=$_GET['id_demm'];
注意: - 第一种方式更安全。感谢强>