首页 \ 问答 \ 使用php中的编辑和删除图像删除和更新行(Delete and update row using edit and delete image in php)

使用php中的编辑和删除图像删除和更新行(Delete and update row using edit and delete image in php)

这是我的branch.php页面,我想在用户点击php中的编辑和删除图像时删除和更新行,直接在表中删除或更新该行。但是这两行都没有更新或删除。

<?php
$a1=mysql_connect('localhost','root1','oec@123');
$b1=mysql_select_db('rms',$a1);
?> 
  <!doctype html>
  <html>
  <head>
  <meta charset="utf-8">
    <title>branch</title>
     <link href="styles/branch.css" rel="stylesheet" type="text/css">
     </head>

      <body>

   <div id="wrapper">
   <header id="top">
   <h1>Reporter Management System</h1>
    <nav id="mainnav">
    <ul>
    <li><a href="admin.php">Home</a></li>
    <li><a href="branch.php">Branch</a></li>
    <li><a href="branchadmin.php">Branch Admin</a></li>
    <li><a href="reporter.php">Reporters</a></li>
    <li><a href="accountant.php">Accountant</a></li>
    <li><a href="setting.php">Settings</a></li>
    <li><a href="">Log out</a></li>
    </ul>
    </nav>
    </header>
    <div id="hero">
    <img src="News2.jpg" width="1000" height="320"  alt=""/>  </div>
    <form  role="form"  action ="searchbranch.php" method="post">
    <p><label for="Search">Search Branch :</label>
    <input class="textbox" type="Search" placeholder="Name" name="Search">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="submit"  class="classname" value="Search" >

       </form>
      <form role= "form" action="createbranch.php" method="post">
       <input type="submit"  class="classname" value="Add Branch"                       onClick="href 'createbranch.php' " ></p>
       </form>
        <section class="page container">
        <div>
       <div class="span12">
       <div class="box pattern ">
       <div class="box-header">
        <i class="icon-list"></i>

        </div>
        <table id="sample-table" class="table table-hover table-bordered  tablesorter">
          <thead>
         <tr>
         <th>Sl no</th>
         <th>Branch</th>
         <th>Description</th>
         <th>Action</th>
          </tr>
          <?php
          $w='SELECT Sl_no, branch, description from create_branch;';
          $recordset=mysql_query($w,$a1) or die(mysql_error());

          $totalrows=mysql_num_rows($recordset);
          $row_recordset=mysql_fetch_assoc($recordset);
          if($totalrows>0)
          {
           do
          {
         $r=$row_recordset['Sl_no'];
         $d=$row_recordset['branch'];
         $d1=$row_recordset['description'];

         ?>
        </thead>
        <tbody id='tb-content'>
         <tr>
         <td><?php echo $r ;?></td>
         <td><?php echo $d ;?></td>
         <td><?php echo $d1 ;?></td>
         <td> <?php echo  '
         <a  href="edit_branch.php?no='.$row_recordset['Sl_no'].'">'?>
        <img src="pencil.png" />
        <?php   '</a>';? >&nbsp;|&nbsp;<?php echo' 
        <a href="branch_delete.php?no1='.$row_recordset['branch'].'">'?>
        <img src="cross.png" /> <?php '</a>';?>  
         </td>
          </tr>
          <?php    
         }while($row_recordset=mysql_fetch_assoc($recordset));
         }
         mysql_free_result($recordset);
          mysql_close($a1);
          ?>

          </tbody>
           </table>
           </div>
           </div>
           </div>
           </section>
            </body>
              <footer>
           <p>&nbsp;</p><hr>
           <center>&copy;Copyright 2015 RepoterManagnmentSystem
           </center> 
           </footer>
            </div>
            </body>
            </html>

这是branch_delete.php

  <?php
  $cn=mysql_connect('localhost','root1',"oec@123");
  $db_selected=mysql_select_db('rms',$cn);
  $bn=$_REQUEST['no1'];
  $sql='DELETE     au.Sl_no,au.name,au.company_name,au.email_id,au.password,au.confirm_password,au.group,au.branch,au.phone,au.wordcount,au.rating,cb.Sl_no,cb.branch,cb.description from admin_user  au,create_branch  cb where cb.branch="'.$bn.'" AND au.branch=cb.branch ;';
    $s1=mysql_query($sql,$cn);
    mysql_close($cn);
    header('Location: branch.php');
     ?> 

这是update_branch.php

   <?php
   $a1=mysql_connect('localhost','root1','oec@123');
   $b1=mysql_select_db('rms',$a1);
   $bn=$_REQUEST['bname'];
   $sn=$_REQUEST['Sl_no'];
   $d=$_REQUEST['descp'];
   $w= 'SELECT branch,description FROM create_branch;';
   $recordset=mysql_query($w,$a1) or die(mysql_error());
   $totalrows=mysql_num_rows($recordset);
   $row_recordset=mysql_fetch_assoc($recordset);
   if($totalrows>0)
   {
   do
     {
   $r=$row_recordset['branch'];
    $s=$row_recordset['description'];   
   if($bn==$r and $d==$s)
   {
    ?>

    <!doctype html>
    <html>
     <head>
      <meta charset="utf-8">
      <title>Untitled Document</title>
     <link href="styles/createbranch.css" rel="stylesheet" type="text/css">         
     </head>

       <body>

      <div id="wrapper">
       <header id="top">
       <h1>Reporter Management System</h1>
        <nav id="mainnav">
        <ul>
        <li><a href="index.html">Home</a></li>
        <li><a href="">Branch</a></li>
        <li><a href="">Branch Admin</a></li>
        <li><a href="">Reporters</a></li>
        <li><a href="">Accountant</a></li>
        <li><a href="">Settings</a></li>
        <li><a href="">Log out</a></li>
        </ul>
        </nav>
        </header>
        <div id="hero">
         <img src="News2.jpg" width="1000" height="320"  alt=""/>
          </div>

            <form  method="post" action="edit_branch.php">
          <article id="main">

        <?php echo '<h2>branch already exists</h2>' ; ?>

         <h2>Create Branch</h2><hr>
         <p><label for="branch name">Branch Name:</label><br><br>
         <input class="textbox" type="text" placeholder=" <?php echo $bn ;?>" name="bname"></p><br>
         <p><label for="Description">Description:</label><br><br>
         <input class="textbox" type="text" placeholder="<?php echo $d ;?>" name="descp"></p><br>
        <input type="submit"  class="classname" value="Update Branch" ></p>           <br>
      </article>
      </form>
      <footer>
      <p>&nbsp;</p><hr>
      <center> &copy; Copyright 2015 ReporterManagementSystem</center>           </footer>
      </div>
      </body>
      </html>
      <?php 

     exit(0);
         }
          }
     while($row_recordset=mysql_fetch_assoc($recordset));

     $w1='UPDATE create_branch set branch="'.$bn.'" and description="'.$d.'" where Sl_no="'.$sn.'";';
     $x=mysql_query($w1,$a1) or die(mysql_error());

     ?>
        <!doctype html>
        <html>
        <head>
        <meta charset="utf-8">
        <title>Untitled Document</title>

        </head>

        <body>
        <div id="wrapper">
        <header id="top">
        <h1>Reporter Management System</h1>
        <nav id="mainnav">
        <ul>
        <li><a href="branchadmin.php">Home</a></li>
        <li><a href="reporters.php">Reporters</a></li>
        <li><a href="content1.php">News Content</a></li>
        <li><a href="CreateUser.php">Add user</a></li>
        <li><a href="">Log Out</a></li>

        </ul>
        </nav>
        </header>
        <img src="News2.jpg" width="1000" height="320"  alt=""/>




        <?php
         echo "<br>";

       if($x=="true")
        {

        header('Location: branch.php');


        }
        else
        {
        echo "fail to update branch";
        }

        echo"<br>";

        }
        mysql_free_result($recordset);
        mysql_close($a1);
        ?>

This is my branch.php page and I want to delete and update row when the user click on the edit and delete image in php and directly the row should be deleted or updated in the table.But It is not working neither row is getting updated or deleted.

<?php
$a1=mysql_connect('localhost','root1','oec@123');
$b1=mysql_select_db('rms',$a1);
?> 
  <!doctype html>
  <html>
  <head>
  <meta charset="utf-8">
    <title>branch</title>
     <link href="styles/branch.css" rel="stylesheet" type="text/css">
     </head>

      <body>

   <div id="wrapper">
   <header id="top">
   <h1>Reporter Management System</h1>
    <nav id="mainnav">
    <ul>
    <li><a href="admin.php">Home</a></li>
    <li><a href="branch.php">Branch</a></li>
    <li><a href="branchadmin.php">Branch Admin</a></li>
    <li><a href="reporter.php">Reporters</a></li>
    <li><a href="accountant.php">Accountant</a></li>
    <li><a href="setting.php">Settings</a></li>
    <li><a href="">Log out</a></li>
    </ul>
    </nav>
    </header>
    <div id="hero">
    <img src="News2.jpg" width="1000" height="320"  alt=""/>  </div>
    <form  role="form"  action ="searchbranch.php" method="post">
    <p><label for="Search">Search Branch :</label>
    <input class="textbox" type="Search" placeholder="Name" name="Search">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="submit"  class="classname" value="Search" >

       </form>
      <form role= "form" action="createbranch.php" method="post">
       <input type="submit"  class="classname" value="Add Branch"                       onClick="href 'createbranch.php' " ></p>
       </form>
        <section class="page container">
        <div>
       <div class="span12">
       <div class="box pattern ">
       <div class="box-header">
        <i class="icon-list"></i>

        </div>
        <table id="sample-table" class="table table-hover table-bordered  tablesorter">
          <thead>
         <tr>
         <th>Sl no</th>
         <th>Branch</th>
         <th>Description</th>
         <th>Action</th>
          </tr>
          <?php
          $w='SELECT Sl_no, branch, description from create_branch;';
          $recordset=mysql_query($w,$a1) or die(mysql_error());

          $totalrows=mysql_num_rows($recordset);
          $row_recordset=mysql_fetch_assoc($recordset);
          if($totalrows>0)
          {
           do
          {
         $r=$row_recordset['Sl_no'];
         $d=$row_recordset['branch'];
         $d1=$row_recordset['description'];

         ?>
        </thead>
        <tbody id='tb-content'>
         <tr>
         <td><?php echo $r ;?></td>
         <td><?php echo $d ;?></td>
         <td><?php echo $d1 ;?></td>
         <td> <?php echo  '
         <a  href="edit_branch.php?no='.$row_recordset['Sl_no'].'">'?>
        <img src="pencil.png" />
        <?php   '</a>';? >&nbsp;|&nbsp;<?php echo' 
        <a href="branch_delete.php?no1='.$row_recordset['branch'].'">'?>
        <img src="cross.png" /> <?php '</a>';?>  
         </td>
          </tr>
          <?php    
         }while($row_recordset=mysql_fetch_assoc($recordset));
         }
         mysql_free_result($recordset);
          mysql_close($a1);
          ?>

          </tbody>
           </table>
           </div>
           </div>
           </div>
           </section>
            </body>
              <footer>
           <p>&nbsp;</p><hr>
           <center>&copy;Copyright 2015 RepoterManagnmentSystem
           </center> 
           </footer>
            </div>
            </body>
            </html>

This is branch_delete.php

  <?php
  $cn=mysql_connect('localhost','root1',"oec@123");
  $db_selected=mysql_select_db('rms',$cn);
  $bn=$_REQUEST['no1'];
  $sql='DELETE     au.Sl_no,au.name,au.company_name,au.email_id,au.password,au.confirm_password,au.group,au.branch,au.phone,au.wordcount,au.rating,cb.Sl_no,cb.branch,cb.description from admin_user  au,create_branch  cb where cb.branch="'.$bn.'" AND au.branch=cb.branch ;';
    $s1=mysql_query($sql,$cn);
    mysql_close($cn);
    header('Location: branch.php');
     ?> 

This is update_branch.php

   <?php
   $a1=mysql_connect('localhost','root1','oec@123');
   $b1=mysql_select_db('rms',$a1);
   $bn=$_REQUEST['bname'];
   $sn=$_REQUEST['Sl_no'];
   $d=$_REQUEST['descp'];
   $w= 'SELECT branch,description FROM create_branch;';
   $recordset=mysql_query($w,$a1) or die(mysql_error());
   $totalrows=mysql_num_rows($recordset);
   $row_recordset=mysql_fetch_assoc($recordset);
   if($totalrows>0)
   {
   do
     {
   $r=$row_recordset['branch'];
    $s=$row_recordset['description'];   
   if($bn==$r and $d==$s)
   {
    ?>

    <!doctype html>
    <html>
     <head>
      <meta charset="utf-8">
      <title>Untitled Document</title>
     <link href="styles/createbranch.css" rel="stylesheet" type="text/css">         
     </head>

       <body>

      <div id="wrapper">
       <header id="top">
       <h1>Reporter Management System</h1>
        <nav id="mainnav">
        <ul>
        <li><a href="index.html">Home</a></li>
        <li><a href="">Branch</a></li>
        <li><a href="">Branch Admin</a></li>
        <li><a href="">Reporters</a></li>
        <li><a href="">Accountant</a></li>
        <li><a href="">Settings</a></li>
        <li><a href="">Log out</a></li>
        </ul>
        </nav>
        </header>
        <div id="hero">
         <img src="News2.jpg" width="1000" height="320"  alt=""/>
          </div>

            <form  method="post" action="edit_branch.php">
          <article id="main">

        <?php echo '<h2>branch already exists</h2>' ; ?>

         <h2>Create Branch</h2><hr>
         <p><label for="branch name">Branch Name:</label><br><br>
         <input class="textbox" type="text" placeholder=" <?php echo $bn ;?>" name="bname"></p><br>
         <p><label for="Description">Description:</label><br><br>
         <input class="textbox" type="text" placeholder="<?php echo $d ;?>" name="descp"></p><br>
        <input type="submit"  class="classname" value="Update Branch" ></p>           <br>
      </article>
      </form>
      <footer>
      <p>&nbsp;</p><hr>
      <center> &copy; Copyright 2015 ReporterManagementSystem</center>           </footer>
      </div>
      </body>
      </html>
      <?php 

     exit(0);
         }
          }
     while($row_recordset=mysql_fetch_assoc($recordset));

     $w1='UPDATE create_branch set branch="'.$bn.'" and description="'.$d.'" where Sl_no="'.$sn.'";';
     $x=mysql_query($w1,$a1) or die(mysql_error());

     ?>
        <!doctype html>
        <html>
        <head>
        <meta charset="utf-8">
        <title>Untitled Document</title>

        </head>

        <body>
        <div id="wrapper">
        <header id="top">
        <h1>Reporter Management System</h1>
        <nav id="mainnav">
        <ul>
        <li><a href="branchadmin.php">Home</a></li>
        <li><a href="reporters.php">Reporters</a></li>
        <li><a href="content1.php">News Content</a></li>
        <li><a href="CreateUser.php">Add user</a></li>
        <li><a href="">Log Out</a></li>

        </ul>
        </nav>
        </header>
        <img src="News2.jpg" width="1000" height="320"  alt=""/>




        <?php
         echo "<br>";

       if($x=="true")
        {

        header('Location: branch.php');


        }
        else
        {
        echo "fail to update branch";
        }

        echo"<br>";

        }
        mysql_free_result($recordset);
        mysql_close($a1);
        ?>

原文:https://stackoverflow.com/questions/29192547
更新时间:2022-09-13 08:09

最满意答案

Twitter上用户向我指出了一个PDF,我无法相信我以前没有找到过

http://www.semanticmerge.com/documents/SemanticMerge-Perforce.pdf

简而言之,有必要创建一个批处理文件来在Perforce中启动外部差异和合并工具。


A user on twitter pointed me at a PDF which I can't believe I hadn't previously managed to find

http://www.semanticmerge.com/documents/SemanticMerge-Perforce.pdf

In short it's necessary to create a batch file to launch external diff and merge tools in Perforce.

相关问答

更多

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)