Ver Mensaje Individual
  #3 (permalink)  
Antiguo 03/12/2010, 21:18
Jose07
 
Fecha de Ingreso: abril-2008
Mensajes: 22
Antigüedad: 16 años
Puntos: 0
Respuesta: Como restar cantidad a un articulo php mysql

Hola tazzwt creo que esto te puede ayudar..!! No probe el código pero creo que te puede dar una idea de como lo hago..!! Saludos

Código PHP:
<html>
<head>
   <title>Libros</title>
   <script type="text/javascript">
   function validar(cantidadStock,idField){
       if(document.getElementById(idField).value <= cantidadStock){
           alert("Se Puede Comprar esa Cantidad");
       } else {
           alert("No Se puede Comprar");
       }
   }  
   </script>
</head>
<body>
 
 <table width="630" border="0">
  <tr>
    <td>Titulo</td>
    <td>Stock</td>
    <td>Precio</td>
    <td>Cantidad</td>
 </tr>
  <tr>
 
<?php
   
include("conex.php");
   
$link=Conectarse();
   
$result=mysql_query("select * from libros",$link);
?>
 
 
<?php
 
 
   
while($row mysql_fetch_array($result)) {
 
    
$id $row["id"];
    
$titulos  $row["titulos"];
    
$precio  $row["precio"];
    
$autor  $row["autor"];
    
$titulos  $row["titulos"];
    
$cantidad $row["cantidad"];
 
      echo 
"
        <td>$titulos</td>
        <td>$cantidad </td>
        <td>$$precio</td>
        <td><input type='text' id='$id' size='5' maxlength='5'/></td>
        <td><input name='button' value='Comprar' onclick='validar($cantidad,$id);'/></td>
     </tr>
      "
;
   }
 
   
mysql_free_result($result);
   
mysql_close($link);
?>
 
</table>
</body>
</html>