Código PHP:
<?php require('../Connections/conecta.php');?>
<!DOCTYPE html>
<html>
<meta charset="ISO-8859-1">
<?php
//$prec=mysql_query("SELECT * FROM arti ORDER BY descripcion_arti ASC",$cn);
$sql=mysql_query("SELECT * FROM arti LEFT JOIN arti_cat ON arti.id_cat_arti = arti_cat.id_cat_arti LEFT JOIN arti_grupo ON arti.id_gp_arti = arti_grupo.id_gp_arti WHERE arti.id_cat_arti = arti_cat.id_cat_arti",$cn);
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<script src="../js/jquery-203.js"></script>
<script src="js/addrow.js"></script>
<script src="js/data.js"></script>
</head>
<body>
<form id="form1" name="form1" method="post" action="cprecio.php">
<input type="text" name="id" value="" hidden="hidden">
<select name="articulo"><option value="0">Seleccione Artículo</option>
<?php
while($row=mysql_fetch_array($sql))
{
echo "<option value='".$row['id_arti']."'>".$row['descripcion_arti']," / ", $row['categoria']."</option>";
}
?>
</select>
<table border="1" cellspacing="0" cellpadding="0" id="tabla">
<th>Tipo Precio</th>
<th>Precio</th>
<th></th>
<th>Borrar</th>
<tr>
<td><input type="text" name="tprecio[]"></td>
<td><input type="text" name="precio[]"></td>
<td><a href="#"><img src="http://www.forosdelweb.com/f18/png/cancelar.png" width="20" height="20"></a></td>
</tr>
</table>
<input type="button" value="+" id="addrow">
<input id="sub" type="submit" value="ENVIAR">
</form>
<span id="result"></span>
</body>
</html>
Código PHP:
<?php require('../Connections/conecta.php');
$id=$_POST['id'];
$tp=$_POST['tprecio'];
$p=$_POST['precio'];
$art=$_POST['articulo'];
$values = array();
//$i = 0;
for($i = 0; $i <=sizeof($tp); ++$i)
//foreach (array($tp,$p,$art) as $valor)
{
$values[] = sprintf('(\'%s\', \'%s\', \'%s\', \'%s\')',$id, $tp[$i], $p[$i], $art);
$i++;
//echo $tp;
print_r($values);
}//echo $p;
//$insert="INSERT INTO arti_precios VALUES('$values')";
//$rs=mysql_query($insert,$cn) or die ('hay un problema'.mysql_info());
//}
//echo 'si se pudo ingresar';
mysql_close();
?>
ya lo edité un poco pero aun tengo problemas ahora me salen repetidos
Código PHP:
Array ( [0] => ('', 'CF', '45', '6') ) Array ( [0] => ('', 'CF', '45', '6') [1] => ('', 'Cliente B', '78', '6') ) Array ( [0] => ('', 'CF', '45', '6') [1] => ('', 'Cliente B', '78', '6') [2] => ('', 'Xela', '12', '6') ) Array ( [0] => ('', 'CF', '45', '6') [1] => ('', 'Cliente B', '78', '6') [2] => ('', 'Xela', '12', '6') [3] => ('', 'Free C/I', '12', '6') )
Código PHP:
Array ( [0] => ('', 'cf', '56', '7') )
( ! ) Notice: Undefined offset: 2 in C:wampwwwcortiarticuloscprecio.php on line 12
Call Stack
# Time Memory Function Location
1 0.0003 255576 {main}( ) ..cprecio.php:0
( ! ) Notice: Undefined offset: 2 in C:wampwwwcortiarticuloscprecio.php on line 12
Call Stack
# Time Memory Function Location
1 0.0003 255576 {main}( ) ..cprecio.php:0
Array ( [0] => ('', 'cf', '56', '7') [1] => ('', '', '', '7') )
Código PHP:
<form name="nuevo" method="post" action="cprecio.php">
<table>
<tr>
<td>Artículo:</td>
<td>
<select name="articulo">
<option value="0">Seleccione Artículo</option>
<?php
while($row=mysql_fetch_array($sql))
{
echo "<option value='".$row['id_arti']."'>".$row['descripcion_arti']," / ", $row['categoria']."</option>";
}
?>
</select>
<td><input type="text" value="" name="id"></td>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td valign="middle" align="left">CF:</td>
<td><input type="text" value="CF" name="tprecio[]" hidden="hidden"></td>
<td><input type="text" value="" name="precio[]"></td>
</tr>
<tr>
<td valign="middle" align="left">Cliente A:</td>
<td><input type="text" value="Cliente A" name="tprecio[]" hidden="hidden"></td>
<td><input type="text" value="" name="precio[]"></td>
</tr>
<tr>
<td valign="middle" align="left">Cliente B:</td>
<td><input type="text" value="Cliente B" name="tprecio[]" hidden="hidden"></td>
<td><input type="text" value="" name="precio[]"></td>
</tr>
<tr>
<td valign="middle" align="left">Distribuidor:</td>
<td><input type="text" value="Distribuidor" name="tprecio[]" hidden="hidden"></td>
<td><input type="text" value="" name="precio[]"></td>
</tr>
<tr>
<td valign="middle" align="left">Xela:</td>
<td><input type="text" value="Xela" name="tprecio[]" hidden="hidden"></td>
<td><input type="text" value="" name="precio[]"></td>
</tr>
<tr>
<td valign="middle" align="left">Free S/I:</td>
<td><input type="text" value="Free S/I" name="tprecio[]" hidden="hidden"></td>
<td><input type="text" value="" name="precio[]"></td>
</tr>
<tr>
<td valign="middle" align="left">Free C/I:</td>
<td><input type="text" value="Free C/I" name="tprecio[]" hidden="hidden"></td>
<td><input type="text" value="" name="precio[]"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Enviar"></td>
</tr>
</table>
</form>