Jump to content

Problems with my while loop and also cant delete its corresponding rows on a click of the buttton delete


crack576

Recommended Posts

 <body>
 
 
  <?php
    

 
       include 'sql.php';
       $query = "SELECT * FROM validation";
       $result = mysqli_query($con , $query);  
       $rows = mysqli_fetch_assoc($result) ;
       $totals = mysqli_num_rows($result) ;
   
      
      
          ?>
            <div id="css">
    <form >
       <table width="80%" border="0" cellpadding="2" cellspacing="2" >
          <caption><h2>Personal Details of Customers</h2></caption>
          <tr class="white">
              <td bgcolor="#330033">   </td>
              <td bgcolor="#330033"> Id Number </td>
              <td bgcolor="#330033"> Full Name </td>
              <td bgcolor="#330033"> Email Address </td>
              <td bgcolor="#330033"> Website </td>
              <td bgcolor="#330033"> Comment </td>
              <td bgcolor="#330033"> Time </td>   
     
</tr>
       <?php while($rows=mysqli_fetch_assoc($result)
       {
       <tr>
      
      <input type="raido" name="ID" value="<?php echo $rows['ID']; ?>"  />
      <td bgcolor="#FFFFCC"><?php  echo $rows['ID'];?></td>
      <td bgcolor="#FFFFCC"><?php  echo $rows['Name'];?> </td>
      <td bgcolor="#FFFFCC"><?php  echo $rows['Email'];?></td>
      <td bgcolor="#FFFFCC"><?php  echo  $rows['Website'];?></td>
      <td bgcolor="#FFFFCC"><?php  echo $rows['Comment'];?></td>
      <td bgcolor="#FFFFCC"><?php  echo $rows['Time'];?></td>  
      
       <td> </td>
     
       <td> <a href="delete.php? ID= "$rows[ID]" /"> <input type="submit" name="del" value="Delete" /> </a>                                                       <input type="button" name=   "edit" value="Edit"  /> </td>
       </tr>
              } 

?>
 
     </table>
   </form>
  </div>
 
 </body>

It'd be nice if you spent the bit of time it takes to write a description of your problem, rather than just use the one-line title to cram everything in. Leaves us with questions like "What problems with your while loop?"

 

As for the other issue,

 
Putting aside the malformed HTML,

You can't put a button inside a link. Pick one. However if you need to pass a value then you can use a like

To make that work, though, you need the current script (the one that handles editing) to support deletes too - can't have a form inside a form, and shouldn't try to switch the action of a form based on a button. There's HTML 5 stuff you could do, actually, but I probably wouldn't.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.