Jump to content

Recommended Posts

Dear Friends

 

  I want your help for adodb update procedure, i have written add code using adodb . please help me

 

i am sending my code please correct me

[CODE]
<table width="932" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
                <td class="bottom_padding"><a href="testinsert.php">Test Insert Adodb</a></td>
              </tr>
              <tr>
               <td class="bottom_padding"><a href="testadodb.php" target="_blank">Test ADODB</a></td>
              </tr>
			  <tr>
               <td class="bottom_padding"><a href="adodblist.php" target="_blank">Test ADODB List</a></td>
              </tr>
			  <tr>
               <td class="bottom_padding"><a href="adodbupdate.php" target="_blank">Test ADODB UPDATE</a></td>
              </tr>
			  
			  </table><!-- index.php -->
[CODE]
[CODE]
<?php
$dbserver=="mysql";
	include_once('adodb/adodb.inc.php');
	include_once('adodb/tohtml.inc.php'); 
	$db = ADONewConnection($dbserver);
    $db = NewADOConnection('mysql');
    $db->Connect("localhost", "root", "", "emp");

    $result = $db->Execute("SELECT * FROM employ");
    if ($result === false) die("failed");

 $result = $db->Execute("SELECT * FROM employ");
    if ($result === false) die("failed");
    
 ?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>
<table width="400" border="1" cellspacing="0" cellpadding="3">
<tr>
<td colspan="4"><strong>List data from mysql </strong> </td>
</tr>

<tr>
<td align="center"><strong>employ_ID</strong></td>
<td align="center"><strong>employ_code</strong></td>
<td align="center"><strong>employ_name</strong></td>
<td align="center"><strong>employ_desig</strong></td>
<td align="center"><strong>employ_dept</strong></td>
<td align="center"><strong>employ_bloodgroup</strong></td>
<td align="center"><strong>Update</strong></td>
</tr>
<tr>
<?php
 while (!$result->EOF) {
     for ($i=0, $max=$result->FieldCount(); $i < $max; $i++)    
	 {
	 
?>


<td><? print $result->fields[$i];  ?>




<?php
}
?></td>
<td align="center"><a href="adodbupdate.php?id=<? print $result->fields[0]; ?>">update</a></td>
</tr>
<?
$result->MoveNext(); 

}
?>


</table>
</td>
</tr>
</table>

<?php
mysql_close();
?>

 

	<?php
    
  
	/*
	# single field primary key 
   $ret = $db->Replace('atable', array('id'=>1000,'firstname'=>'Harun','lastname'=>'Al-Rashid'),        'id', 'firstname',$autoquote = true); 
   # generates UPDATE table SET 
   # firstname='Harun',lastname='Al-Rashid' 
   # WHERE id=1000 
   # or INSERT INTO atable (id,firstname,lastname) 
   # VALUES (1000,'Harun','Al-Rashid') 

   # compound key 
   $ret = $db->Replace('atable2', 
   array('firstname'=>'Harun','lastname'=>'Al-Rashid', 'age' => 33, 'birthday' => 'null'), 
   array('lastname','firstname'), 
       'firstname',$autoquote = true); 

   # no auto-quoting 
   $ret = $db->Replace('atable2', 
   array('firstname'=>"'Harun'",'lastname'=>"'Al-Rashid'", 'age' => 'null'), 
   array('lastname','firstname'), 
       'firstname');


	*/
    ?>
	
	 <?php
	    $record = array();
	# Initialize an array to hold the
	# record data to insert
	 
	    # Set the values for the fields in the record
	    $record["employ_code"] = $_POST['empcode'];
	    $record["employ_name"] = $_POST['empname'];
	    $record["employ_desig"] = $_POST['employ_desig'];
		
	 	$record["employ_dept"] = $_POST['employ_dept'];
		$record["employ_bloodgroup"] = $_POST['employ_bloodgroup'];
		
	    # Pass the empty recordset and
	    #the array containing the data to insert
	    # into the GetInsertSQL function.
	    #The function will process the data and return
	    # a fully formatted insert sql statement.
//	    $insertSQL = $conn->GetInsertSQL($rs, $record);
	 
	//    $conn->Execute($insertSQL);
//adodblist.php	
?>
[/CODE]
[CODE]
<?php
$id=$_GET['id'];
$dbserver=="mysql";
	include_once('adodb/adodb.inc.php');
	include_once('adodb/tohtml.inc.php'); 
	$db = ADONewConnection($dbserver);
    $db = NewADOConnection('mysql');
    $db->Connect("localhost", "root", "", "emp");

    $result = $db->Execute("SELECT * FROM employ where employ_id=".$id);
    if ($result === false) die("failed");
    
	
   
	    $record = array();
print $record["employ_code"] ;
  
  
    ?>
	 <? echo "<form method=\"POST\" action=\"$PHP_SELF\">"; ?>

<table width="1043" cellpadding="0" cellspacing="0" border="0">
<tr>
    <td align=left width="207"> </td>
	<td align=left width="324"><?=$TEXT['ADOdb-dbserver']?></td>
	<td align=left width="215"> </td>
	<td align=left width="297"><?=$TEXT['ADOdb-host']?></td>
</tr>

<tr>
    <td align=left width="207">EMPLOYEE CODE</td>
	<td align=left width="324"><input type="text" name="empcode" size="40" value=<? print $result->fields[$i];  ?>></td>
	<td align=left width="215">EMPLOYEE NAME</td>
	<td align=left width="297"><input type="text" name="empname" size="40" value=<? print $result->fields[$i];  ?>></td>
</tr>
<tr>
    <td align=left width="207"> </td>
	<td align=left width="324"> </td>
	<td align=left width="215"> </td>
	<td align=left width="297"> </td>
</tr>
<tr>
    <td align=left width="207">EMPLOYEE DESIGNATION</td>
	<td align=left width="324"><input type="text" name="employ_desig" size="40" value=<? print $result->fields[$i];  ?>></td>
	<td align=left width="215">EMPLOYEE DEPT</td>
	<td align=left width="297"><input type="text" name="employ_dept" size="40" value=<? print $result->fields[$i];  ?>></td>
</tr>
<tr>
    <td align=left width="207"> </td>
	<td align=left width="324"> </td>
	<td align=left width="215"> </td>
	<td align=left width="297"> </td>
</tr>
<tr>
    <td align=left width="207">EMPLOYEE BLOOD GROUP</td>
	<td align=left width="324"><input type="text" name="employ_bloodgroup" size="40" value=<? print $result->fields[$i];  ?>></td>
	<td align=left width="215"> </td>
	<td align=left width="297"> </td>
</tr>
<?php  // } ?>
<tr>
    <td align=left width="207"> </td>
	<td align=left width="324"><input type="submit" name="adodb" value="submit"></td>
	<td align=left width="215"> </td>
	<td align=left width="297"> </td>
</tr>
</table>


 </form>
	 <?php
	  


	    $record["employ_code"] = $_POST['empcode'];
	    $record["employ_name"] = $_POST['empname'];
	    $record["employ_desig"] = $_POST['employ_desig'];
		
	 	$record["employ_dept"] = $_POST['employ_dept'];
		$record["employ_bloodgroup"] = $_POST['employ_bloodgroup'];
		
	   //adodbupdate.php
	?>
[/CODE]
for the above code adodblist.php, is used for redirecting adodbupdate.php
Thanks in advance
sai gopal
Link to comment
https://forums.phpfreaks.com/topic/281233-adodb-using-php-update-help-required/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.