请帮帮忙,小弟我贴代码了,现在不用下载文件看了

WBOY
发布: 2016-06-13 11:58:37
原创
984 人浏览过

请帮帮忙,我贴代码了,现在不用下载文件看了。

本帖最后由 abkey1 于 2014-06-01 10:13:30 编辑
a.php  包含一个删除选中书签的复选框<br /><br />function display_user_urls($url_array)<br />{<br />  // display the table of URLs<br /><br />  // set global variable, so we can test later if this is on the page<br />  global $bm_table;<br />  $bm_table = true;<br />?><br />  <br /><br />  <form name='bm_table' action='delete_bms.php' method='post'><br />  <table width=300 cellpadding=2 cellspacing=0><br />  <?php<br />  $color = "#cccccc";<br />  echo "<tr bgcolor='$color'><td><strong>Bookmark</strong></td>";<br />  echo "<td><strong>Delete?</strong></td></tr>";<br />  if (is_array($url_array) && count($url_array)>0)<br />  {<br />    foreach ($url_array as $url)<br />    {<br />      if ($color == "#cccccc")<br />        $color = "#ffffff";<br />      else<br />        $color = "#cccccc";<br />      // remember to call htmlspecialchars() when we are displaying user data<br />      echo "<tr bgcolor='$color'><td><a href=\"$url\">".htmlspecialchars($url)."</a></td>";<br />      echo "<td><input type='checkbox' name=\"del_me[]\"<br />             value=\"$url\"></td>";<br />      echo "</tr>"; <br />    }<br />  }<br />  else<br />    echo "<tr><td>No bookmarks on record</td></tr>";<br />?><br />  </table> <br />  </form><br /><?php<br />}
登录后复制


点击上面删除的复选框后,需要点击下方的删除书签<br /><?php<br />  // only offer the delete option if bookmark table is on this page<br />  global $bm_table;<br />  if($bm_table==true)<br />    echo "<a href='#' onClick='bm_table.submit();'>Delete BM</a> | "; <br />  else<br />    echo "<font color='#cccccc'>Delete BM</font> | "; <br />?>
登录后复制


delete_bms.php 删除函数如下<br /><?php<br />  require_once('bookmark_fns.php');<br />  session_start();<br /> <br />  //create short variable names<br />  $del_me = $HTTP_GET_VARS['del_me'];<br />  $valid_user = $HTTP_GET_VARS['valid_user'];<br /> <br />  do_html_header('Deleting bookmarks');<br />  check_valid_user();<br />  if (!filled_out($HTTP_GET_VARS))<br />  {<br />    echo 'You have not chosen any bookmarks to delete.<br />         Please try again.';<br />    display_user_menu();<br />    do_html_footer();  <br />    exit;<br />  }<br />  else <br />  {<br />    if (count($del_me) >0)<br />    {<br />      foreach($del_me as $url)<br />      {<br />        if (delete_bm($valid_user, $url))<br />          echo 'Deleted '.htmlspecialchars($url).'.<br />';<br />        else<br />          echo 'Could not delete '.htmlspecialchars($url).'.<br />';<br />      }  <br />    }<br />    else<br />      echo 'No bookmarks selected for deletion';<br />  }<br />  // get the bookmarks this user has saved<br />  if ($url_array = get_user_urls($valid_user))<br />    display_user_urls($url_array);<br /><br />  display_user_menu(); <br />  do_html_footer();<br />?>
登录后复制


<br>delete_bm函数的代码如下<br><br>function delete_bm($user, $url)<br>{<br>  // delete one URL from the database<br>  $conn = db_connect(); //此处已经包含在另一个php文件中,连接数据库是正常的<br>  // delete the bookmark<br>  if (!$conn->query( "delete from bookmark <br>                       where username='$user' and bm_url='$url'"))<br>    throw new Exception('Bookmark could not be deleted');<div class="clear">
                 
              
              
        
            </div>
登录后复制
相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板