Jump to content

help with update query


lingo5

Recommended Posts

Hi,

 

I have this form to update a recordset:

 

<form action="<?php $PHP_SELF;?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
  <table width="850" border="0" align="center" cellpadding="8" cellspacing="0">
    <tr>
      <td><table width="100%" border="0" cellspacing="0" cellpadding="10">
        <tr>
          <td><table width="100%" border="0" cellspacing="0" cellpadding="6">
            <tr>
              <td><span class="CP_blueTXT">Factura para</span></td>
            </tr>
            <tr>
              <td>
              <select name="id_cliente" class="CP_loginFormFields" id="id_cliente" title="<?php echo $row_clientes_RS['id_cliente']; ?>">
                <?php
do {  
?>
                <option value="<?php echo $row_clientes_RS['id_cliente']?>"<?php if (!(strcmp($row_clientes_RS['id_cliente'], $row_clientes_RS['company_name']))) {echo "selected=\"selected\"";} ?>><?php echo $row_clientes_RS['company_name']?></option>
                <?php
} while ($row_clientes_RS = mysql_fetch_assoc($clientes_RS));
  $rows = mysql_num_rows($clientes_RS);
  if($rows > 0) {
      mysql_data_seek($clientes_RS, 0);
  $row_clientes_RS = mysql_fetch_assoc($clientes_RS);
  }
?>
                </select></td>
            </tr>
          </table></td>
        </tr>
      </table>
        <table width="100%" border="0" cellpadding="10" cellspacing="0">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="6">
              <tr>
                <td><span class="CP_blueTXT">Concepto</span></td>
              </tr>
              <tr>
                <td>
              <input name="factura_title" type="text" class="CP_loginFormFields" value="<?php echo $row_facturas_RS['factura_title']; ?>" size="70" /></td>
              </tr>
            </table></td>
          </tr>
        </table>
        <table width="100%" border="0" cellspacing="0" cellpadding="10">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="6">
              <tr>
                <td width="25%"><span class="CP_blueTXT">Fecha factura</span></td>
                <td width="75%"><span class="CP_blueTXT">Nº factura</span></td>
              </tr>
              <tr>
                <td><input name="factura_date" type="text" class="CP_loginFormFields" value="<?php echo date('d/m/Y',strtotime($row_facturas_RS['factura_date'])); ?>" size="32" /></td>
                <td><input name="factura_number" type="text" class="CP_loginFormFields" value="<?php echo $row_facturas_RS['factura_number']; ?>" size="32" /></td>
              </tr>
            </table></td>
          </tr>
        </table>
        <table width="100%" border="0" cellspacing="0" cellpadding="10">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="6">
              <tr>
                <td width="26%" nowrap="nowrap"><span class="CP_blueTXT">Estado factura</span></td>
                <td width="74%" class="CP_blueTXT">Cambiar estado factura</td>
              </tr>
              <tr>
                <td class="AddressTXT"><?php if ($row_facturas_RS['estadofactura_titulo']== 'pagada')
		{     
		echo '<img class="borderBotones" src="CP_img/pagada.jpg">';
		}
		?>
                <?php if ($row_facturas_RS['estadofactura_titulo']== 'pendiente')
		{     
		echo '<img class="borderBotones" src="CP_img/pendiente.jpg">';
		}
		?>
                <?php if ($row_facturas_RS['estadofactura_titulo']== 'anulada')
		{     
		echo '<img class="borderBotones" src="CP_img/anulada.jpg">';
		}?>
                <?php if ($row_facturas_RS['estadofactura_titulo']== 'rectificada')
		{     
		echo '<img class="borderBotones" src="CP_img/rectificada.jpg">';
		}?></td>
                <td class="CP_SiNoText"><label>
                  <select name="estado_actual" class="CP_loginFormFields" id="estado_actual">
                    <option value="value">Seleccione nuevo estado</option>
                    <?php
do {  
?>
<option value="<?php echo $row_estadofacturas_RS['estadofactura_titulo']?>"><?php echo $row_estadofacturas_RS['estadofactura_titulo']?></option>
                    <?php
} while ($row_estadofacturas_RS = mysql_fetch_assoc($estadofacturas_RS));
  $rows = mysql_num_rows($estadofacturas_RS);
  if($rows > 0) {
      mysql_data_seek($estadofacturas_RS, 0);
  $row_estadofacturas_RS = mysql_fetch_assoc($estadofacturas_RS);
  }
?>
                  </select>
                </label></td>
              </tr>
            </table></td>
          </tr>
        </table>
        <table width="100%" border="0" cellspacing="0" cellpadding="10">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="6">
              <tr>
                <td width="26%" class="CP_blueTXT">Factura actual</td>
                </tr>
              <tr>
                <td nowrap="nowrap"><input name="factura_title" type="text" class="CP_loginFormFields" id="factura_title" value="<?php echo $row_facturas_RS['factura_title']; ?>" size="32" /></td>
                </tr>
            </table></td>
          </tr>
        </table>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="6">
              <tr>
                <td width="2%"> </td>
                <td width="98%"><input name="editar" type="submit" id="editar" value="modificar factura" />
                 </td>
              </tr>
            </table></td>
          </tr>
        </table></td>
    </tr>
  </table>
</form>

 

And this update query:

 

$estadoActual = $row_facturas_RS['estadofactura_titulo']; // this is the actual state of an invoice
if($estadofactura=="") // and this function is supposed to maintain the actual state of the invoice if not changed

{  
$estadofactura = $estadoActual;
}
else{

$estadofactura = $_POST["estadofactura_titulo"];
}


$idcliente = $_POST['id_cliente'];
$facturatitle = $_POST["factura_title"];
list($dia,$mes,$ano)=explode("/",$_POST['factura_date']);
$facturadate="$ano/$mes/$dia";
$facturanumber=$_POST["factura_number"];



$Sql="UPDATE t_facturas SET 
id_cliente='$idcliente', factura_title='$facturatitle', factura_date='$facturadate', factura_number='$facturanumber',estadofactura_titulo='$estadofactura',factura_path='$filePath' WHERE id_factura='$colname_facturas_RS'";

$res=mysql_query($Sql) or die ("Error: ". mysql_error(). " with query ". $Sql);

 

The problem is the invoice state field (estadofactura_titulo) is not updated

Link to comment
https://forums.phpfreaks.com/topic/238537-help-with-update-query/
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.