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
https://forums.phpfreaks.com/topic/3600-mysql-php-update-with-dowhile/
Share on other sites

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.