Heim  >  Artikel  >  Backend-Entwicklung  >  请教大神,这样写,php的查询是否是执行了两次

请教大神,这样写,php的查询是否是执行了两次

WBOY
WBOYOriginal
2016-06-13 11:43:05878Durchsuche

请问大神,这样写,php的查询是否是执行了两次?

<?php<br />$act=$_GET['act'];<br />$id=$_GET['id'];<br />switch($act){<br />case "del";<br />$del=$dbc->prepare("delete from naszt where 1=1 and id=?");<br />if($del->execute(array($id))){ <br />echo "<script>";<br />echo "$(function() {";<br />echo  "$('.del').click(function() {";<br />echo  " $('#'+$(this).attr('id')).remove()";<br />echo  "})";<br />echo "})";<br />echo "</script>";<br /> }else{<br />	echo  '<script>alert("由于网络原因,删除失败,请重试!");</script>';<br />  }<br />}<br />?><br /><?php <br />$selectSpecialContent=$dbc->prepare("select * from naszt");<br />$selectSpecialContent->execute();<br />?><br /><table align="center" cellspacing="0" cellpadding="0"><br /><tr><br /><th>专题名称</th><br /><th>专题类型</th><br /><th>发表时间</th><br /><th>发表ip</th><br /><th>操作</th><br /></tr><br /><br /><?php while($row=$selectSpecialContent->fetch()){ ?><br /><tr id="<?php echo $row['id']?>"><br /><td><?php echo $row['ztname']?></td><br /><td><?php echo $row['zttype']?></td><br /><td><?php echo $row['zttime']?></td><br /><td><?php echo $row['publiship']?></td><br /><td><button><a href="ztselect.php?id=<?php echo $row['id']?>">查看</a></button><button><a href="upzt.php?act=up&id=<?php echo $row['id']?>">修改</a></button><button class='del' id="<?php echo $row['id']?>"><a href="selectzt.php?act=del&id=<?php  echo $row['id']?>" >删除</a></button></td><br /></tr><br /><?php }; ?><br /></table>


请问大神,这样写,php的查询是否是执行了两次?

<script><br />$(function() {<br /> $('.del').click(function() {<br /> $('#'+$(this).attr('id')).remove();<br /> });<br />});<br /></script>
这段js就是删除当前的tr,但是我觉的$selectSpecialContent=$dbc->prepare("select * from naszt");
$selectSpecialContent->execute(); 这句SQL查询又被执行了一次

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn