logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 09-19-2013, 06:43 AM   #1
lacsoncruz
 
Join Date: Sep 2013
Posts: 1
Unhappy PHP Multiple Update function not updating and gets the 1st row blank

First of all, I use PHP Dreamweaver to make a program with phpMyAdmin Database. This program gets my records in a 1st row blank when I submit the button, and the remaining records in a rows are still there which is 2nd row and below, but the records in a 1st row is still on the database, why should it happen? any idea for me to solve this program, it also won't update my record. this makes me sick, i need help please! tnx...

PHP Code:
<?php require_once('Connections/tlsc_conn.php');
  
mysql_select_db($database_tlsc_conn$tlsc_conn);
  
$query_Recordset1 "SELECT * FROM tbl_name";
  
$Recordset1 mysql_query($query_Recordset1$tlsc_conn) or die(mysql_error());
  
$row_Recordset1 mysql_fetch_assoc($Recordset1);
  
$totalRows_Recordset1 mysql_num_rows($Recordset1);

  if(isset(
$_POST['submit'])) {
      
$count count($_POST['id']);
      
$submit $_GET['id'];

      for(
$i=0;$i<$count;$i++){
          
$sql1="UPDATE $tbl_name SET name='$name[$i]', lastname='$lastname[$i]', email='$email[$i]' WHERE id='$id[$i]'";
          
$row_Recordset1=mysql_query($sql1);
       }

    if(
$row_Recordset1){
            
header("location:lulu.php");
            exit;
    }   
 }
?>
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org    /TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 <title>Untitled Document</title>
</head>
<body>
  <form name="form2" method="post" action="">
  <table width="634" border="1">
    <tr>
       <td>id</td>
       <td>name</td>
       <td>lastname</td>
       <td>email</td>
    </tr>
   <?php do { ?> 
    <tr>
      <td><?php $id[]=$row_Recordset1['id']; ?><?php echo $row_Recordset1['id']; ?> 
      <input name="id[]" type="hidden" value="<?php echo $row_Recordset1['id'];   ?>" />
      </td>
      <td>
        <input name="name[]" type="text" value="<?php echo $row_Recordset1['name']; ?>">                       
      </td>
      <td>
        <input name="lastname[]" type="text" value="<?php echo $row_Recordset1['lastname']; ?>">
      </td>
      <td>
        <input name="email[]" type="text" value="<?php echo  $row_Recordset1['email']; ?>">       </td>
    </tr>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>  
   </table>
    <p>
    <input type="submit" name="submit" value="Submit" />
    </p>
  </form>
   <p>
</body>
</html>

Last edited by lacsoncruz; 09-19-2013 at 06:50 AM..
lacsoncruz is offline   Reply With Quote
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:19 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com