is that correct:
1- is $conn
2- error in paste
3- is not there clientes select box. that is my table to update
giros and vendedores select box is show at the same time, only without:
<?php if (!(strcmp($row_vendedores['idvendedor'], "$row_clientes['idvendedor']"))) {echo "SELECTED";} ?>
and
<?php ((strcmp($row_giros['idgiro'] , "$row_clientes['idgiro']")) ? echo "SELECTED"); ?>
but do not show the Clientes current record value.
can show too if there are only one of this select box, inluding the refered code
go the code again:
<?php require_once('conn.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $SERVER['PHP_SELF'];
if (isset($SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($POST["MM_update"])) && ($POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE clientes SET rut=%s, sucursal=%s, empresa=%s, idgiro=%s, direccion=%s, comuna=%s, ciudad=%s, idzona=%s, telefono=%s, fax=%s, email=%s, contacto=%s, idvendedor=%s, tipocliente=%s WHERE idcliente=%s",
GetSQLValueString($POST['empresa'], "text"),
GetSQLValueString($POST['idgiro'], "int"),
GetSQLValueString($_POST['idvendedor'], "int"));
mysql_select_db($database, $conn);
$Result1 = mysql_query($updateSQL, $conn) or die(mysql_error());
}
mysql_select_db($database, $conn);
$query_clientes = "SELECT * FROM clientes";
$clientes = mysql_query($query_clientes, $conn) or die(mysql_error());
$row_clientes = mysql_fetch_assoc($clientes);
$totalRows_clientes = mysql_num_rows($clientes);
mysql_select_db($database, $conn);
$query_giros = "SELECT * FROM giros";
$giros = mysql_query($query_giros, $conn) or die(mysql_error());
$row_giros = mysql_fetch_assoc($giros);
$totalRows_giros = mysql_num_rows($giros);
mysql_select_db($database, $conn);
$query_vendedores = "SELECT idvendedor, nombre FROM vendedores";
$vendedores = mysql_query($query_vendedores, $conn) or die(mysql_error());
$row_vendedores = mysql_fetch_assoc($vendedores);
$totalRows_vendedores = mysql_num_rows($vendedores);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Documento sin título</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Empresa:</td>
<td><input type="text" name="empresa" value="<?php echo $row_clientes['empresa']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Idgiro:</td>
<td>
<select name="idgiro">
<?php
do {
?>
<option value="<?= $row_giros['idgiro']?>" <?php if (!(strcmp($row_giros['idgiro'], "$row_clientes['idgiro']"))) {echo "SELECTED";} ?>><?= $row_giros['giro']?></option>
<?php
} while ($row_giros = mysql_fetch_assoc($giros));
?>
</select>
</td>
<tr valign="baseline">
<td nowrap align="right">Idvendedor:</td>
<td>
<select name="idvendedor">
<?php
do {
?>
<option value="<?php echo $row_vendedores['idvendedor']?>" <?php if (!(strcmp($row_vendedores['idvendedor'], "$row_clientes['idvendedor']"))) {echo "SELECTED";} ?>><?= $row_vendedores['nombre']?></option>
<?php
} while ($row_vendedores = mysql_fetch_assoc($vendedores));
?>
</select>
</td>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Actualizar registro"></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="idcliente" value="<?php echo $row_clientes['idcliente']; ?>">
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($clientes);
mysql_free_result($giros);
mysql_free_result($vendedores);
?>