Jump to content

MySQL + PHP - UPDATE with do...while


villas

Recommended Posts

Hi ... newbie (and diferent language) calling here please be pacient!

I need UPDATE a NEW table with data of OLD table (only 2 columns) in all table (1600 regs) comparing with another diferent column

The script was an parser error in first UPDATE nd stop.

[code]
<?php require_once('../Connections/connNOR2.php'); ?>
<?php


//----recordset  (OLD table)-------------

mysql_select_db($database_connNOR2, $connNOR2);
$query_rsREAJUSTAtudoVELHA = "SELECT * FROM tab082005_2";
$rsREAJUSTAtudoVELHA = mysql_query($query_rsREAJUSTAtudoVELHA, $connNOR2) or die(mysql_error());
$row_rsREAJUSTAtudoVELHA = mysql_fetch_assoc($rsREAJUSTAtudoVELHA);
$totalRows_rsREAJUSTAtudoVELHA = mysql_num_rows($rsREAJUSTAtudoVELHA);

//----------------------------------
$codTT=$row_rsREAJUSTAtudoVELHA['tab_cod'];
$velha_hier=$row_rsREAJUSTAtudoVELHA['tab_hier'];
//-----------------------------------

//----recordset (NEW table)---------------

mysql_select_db($database_connNOR2, $connNOR2);
$query_rsREAJUSTAtudoNOVA = "SELECT * FROM tab01022006_2 WHERE tab_cod='$codTT'";
$rsREAJUSTAtudoNOVA = mysql_query($query_rsREAJUSTAtudoNOVA, $connNOR2) or die(mysql_error());
$row_rsREAJUSTAtudoNOVA = mysql_fetch_assoc($rsREAJUSTAtudoNOVA);
$totalRows_rsREAJUSTAtudoNOVA = mysql_num_rows($rsREAJUSTAtudoNOVA);

?>
<?php do {

// put the "hhhh" and "eeee" where value is empty.

if ($velha_hier=='')

{

UPDATE tab01022006_2 SET tab_hier='hhhh',qtde_emb='eeee';  // <---PARSE ERROR ??

} else {

// put the OLD value in a NEW table

UPDATE tab01022006_2 SET tab01022006_2.tab_hier=$row_rsREAJUSTAtudoVELHA['tab_hier'], qtde_emb=$row_rsREAJUSTAtudoVELHA['qtde_emb'];

}
?>

<?php } while ($row_rsREAJUSTAtudoNOVA = mysql_fetch_assoc($rsREAJUSTAtudoNOVA)); ?>

<?php
mysql_free_result($rsREAJUSTAtudoVELHA);
mysql_free_result($rsREAJUSTAtudoNOVA);

?>
[/code]

Thanks and sory about the english


Villas
Link to comment
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.