我在showphoto.php页取得图片id,想把它传给show.php页显示大图,然后又传给图片评论那一页comment.php,把每个评论内容和图片的id对应起来,我在下面这样写不对,要怎么修改??求帮忙
$query=mysql_query("select * from tb_tpsc where type='达人收藏' order by id desc limit ".($page_num-1)*$row_per_page." ,$row_per_page",$conn);
while($row=mysql_fetch_array($query))
{
<a href=commentadd.php?id=".$row[id]."></a>;
echo "<a href=show.php?id=".$row[id]."><img widht=100 height=100 src='$row[tpmc]'></a>";
}
$query=mysql_query("select * from tb_tpsc where type='达人收藏' order by id desc limit ".($page_num-1)*$row_per_page." ,$row_per_page",$conn);
while($row=mysql_fetch_array($query))
{
<a href=commentadd.php?id=".$row[id]."></a>;
echo "<a href=show.php?id=".$row[id]."><img widht=100 height=100 src='$row[tpmc]'></a>";
}
解决方案 »
- 急。。在线等。。sql语句。。
- PHP 如何自己发送PSOT数据 从而登陆别人的网站
- 缩放图片时 报Call to undefined function ImageCreateFrom.jpeg()是什么原因
- 关于PHP在XP下的运行环境问题
- 关于通过浏览器 调用socket后台超时问题
- 请问在php查询页面中,如何实现上页,下页,首页,尾页跳转功能?
- 如何用php读取到这个变量!
- 数据表导入
- $_SERVER['REMOTE_ADDR']返回值为::1怎么改成ipv4的ip地址
- php在网页中画图数据量比较大(几万个点),想看清楚图片的细节。有什么解决方法和工具?
- 求教一个小问题
- 帮忙看意思sql语句中的like怎么使用?
while($row=mysql_fetch_array($query))
{
echo "<a href=commentadd.php?id=$row[id]></a>";//ID已经GET形式传递,评论页可以$_GET['id']获取到图片ID
echo "<a href=show.php?id=".$row[id]."><img widht=100 height=100 src='$row[tpmc]'></a>"; //同上
}
if($_POST["submit"]=="提交"){
$tpid=$_GET[id];
$content=$_POST[txt_content];
$datetime=date("Y-m-d H:i:s");
$INS="Insert Into tb_comment (tpid,content,datetime) Values ('$tpid','$content','$datetime')";
$info=mysql_query($INS);
图片的id没传过去,数据库里没有
如果在comment.php内
<a href=commentadd.php?id=$row[id]>aaa</a>//你要先点击这个链接才能传过去参数
然后在表单内做个隐藏数据项,$_GET['id']获取就可以了
showphoto.php
$query=mysql_query("select * from tb_tpsc where type='达人收藏' order by id desc limit ".($page_num-1)*$row_per_page." ,$row_per_page",$conn);
while($row=mysql_fetch_array($query))
{
//echo "<a href=commentadd.php?id=".$row[id].">aaa</a>";//ID已经GET形式传递,评论页可以$_GET['id']获取到图片ID
echo "<a href=show.php?id=".$row[id]."><img widht=100 height=100 src='$row[tpmc]'></a>"; //同上
}
show.php
<body>
<table width="376" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<div align="center">
<?php if($_GET['id']){
$id=$_GET['id'];
//echo"$id";
$query=mysql_query("select * from tb_tpsc where id='$id'",$conn);
$row=mysql_fetch_array($query);
echo "<img src='$row[tpmc]'>";
}
?></div></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
</table> <form name="myform" method="post" action="commentadd.php">
<table width="560" border="1" align="center" cellpadding="3" cellspacing="1" bordercolor="#9CC739" bgcolor="#FFFFFF">
<tr align="left" colspan="2" >
<td width="390" height="25" colspan="3" valign="top" bgcolor="#EFF7DE"> <span class="right_head"><SPAN style="FONT-SIZE: 9pt; COLOR: #cc0033"></SPAN></span><span class="tableBorder_LTR"> 发表评论</span> </td>
</tr>
<td height="112" align="center" valign="top" >
<input name="tpid" type="hidden" value="<?php echo "$_GET[id]";?>">[/color]
<table width="500" border="1" cellpadding="1" cellspacing="0" bordercolor="#D6E7A5" bgcolor="#FFFFFF">
<tr>
<td align="center">我要评论</td>
<td width="410"><textarea name="txt_content" cols="66" rows="8" id="txt_content" ></textarea></td>
</tr>
<tr align="center">
<td colspan="2"><input type="submit" name="submit" value="提交" onClick="return check();">
<input type="reset" name="submit2" value="重置"></td>
</tr>
</table> </td>
</table>
</form>
</body>commentadd.php
<?php
header ( "Content-type: text/html; charset=gb2312" ); //设置文件编码格式
session_start();
include "conn/conn.php";
//echo "$_GET[id]";
if($_POST["submit"]=="提交"){
$tpid=$_GET[id]; $content=$_POST[txt_content];
$datetime=date("Y-m-d H:i:s");
$INS="Insert Into tb_comment (tpid,content,datetime) Values ('$tpid','$content','$datetime')";
$info=mysql_query($INS);
if($info){
echo "<script> alert('成功发表评论!');</script>";
echo "<script> window.location.href='$_SERVER[HTTP_REFERER]';</script>";
}
else{
echo "<script> alert('评论发表操作失败!');</script>";
echo "<script> history.go(-1);</script>";
}
}
?>
while($row=mysql_fetch_array($query))
{
echo '<img src=commentadd.php?id=".$row[id]."/>';
echo '<img src=show.php?id=".$row[id]."><img widht=100 height=100 src='$row[tpmc]'></a>';
}