Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General »

problema con update en mysql

Estas en el tema de problema con update en mysql en el foro de Bases de Datos General en Foros del Web. buenas lo que debo hacer es un update en un campo de una linea de la tabla.. seria algo asi.. este tema selecciona las 7 ...
  #1 (permalink)  
Antiguo 04/11/2008, 05:00
 
Fecha de Ingreso: agosto-2008
Mensajes: 367
Antigüedad: 16 años, 5 meses
Puntos: 5
problema con update en mysql

buenas lo que debo hacer es un update en un campo de una linea de la tabla..
seria algo asi.. este tema selecciona las 7 preguntas mas consultadas. a lo que deberia cada ves que se seleccione una preguna incrementar al campo "contador" ejemplo. contador 15 sumarle uno y guardarlo nuevamente en ese campo.. de esa linea.. seria algo asi como un update campo contador de la pregunta seleccionada.. el codigo general es algo asi


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<style type="text/css">
<!--
.Estilo7 {font-size: 17px; font-style: italic; font-weight: bold; }
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: none;
}
body {
background-color: #00CC99;
}
-->
</style>
</head>
<?php
$dbhost='localhost';
$dbusername='root';
$dbuserpass='root';
$dbname='club';



mysql_connect ($dbhost, $dbusername, $dbuserpass) or die ("no se conecta a database");
mysql_select_db($dbname) or die("Cannot select database");
$res=mysql_query("SELECT * FROM `preguntas_frecuentes` ORDER BY contador DESC LIMIT 7 ") or die ("no seleciona datos");

$pre=mysql_result($res,0,0);
$pre1=mysql_result($res,0,1);
$pre2=mysql_result($res,0,2);
$pre3=mysql_result($res,1,0);
$pre4=mysql_result($res,1,1);
$pre5=mysql_result($res,1,2);
$pre6=mysql_result($res,2,0);
$pre7=mysql_result($res,2,1);
$pre8=mysql_result($res,2,2);
$pre9=mysql_result($res,3,0);
$pre10=mysql_result($res,3,1);
$pre11=mysql_result($res,3,2);
$pre12=mysql_result($res,4,0);
$pre13=mysql_result($res,4,1);
$pre14=mysql_result($res,4,2);
$pre15=mysql_result($res,5,0);
$pre16=mysql_result($res,5,1);
$pre17=mysql_result($res,5,2);
$pre18=mysql_result($res,6,0);
$pre19=mysql_result($res,6,1);
$pre20=mysql_result($res,6,2);

// en este ejemplo el contador de la pregunta uno seria "$pre2" a este se le deberia agregar uno y guardarlo en el campo nuevamente.,.. quien me podria ayudar con esta sintaxis.. muchas gracias.. de parte de un aprendiz

?>

<body>
<table width="873" height="802" border="1" align="center">
<tr>
<td width="863" height="796" valign="top" bgcolor="#D0DECF"><table width="807" height="80" border="0" align="center">
<tr>
<td width="705" height="76" valign="middle"><table width="805" height="97" border="0">
<tr>
<td width="171" height="93">&nbsp;</td>
<td width="519"><img src="/img/jVmdxC.gif" alt="Bienvenido" width="468" height="60" /></td>
<td width="101"><img src="/img/logut.png" width="87" height="20" /></td>
</tr>
</table></td>
</tr>
</table>
<table width="815" border="0
">
<tr>
<td>&nbsp;</td>
</tr>
</table>
<table width="817" border="0">
<tr>
<td width="58">&nbsp;</td>
<td width="749"><img src="/img/marco.png" width="45" height="35" /><img src="/img/marco.png" alt="marc" width="45" height="35" /><img src="/img/historia.png" alt="his" width="103" height="35" /><img src="/img/vision.png" alt="visi" width="148" height="35" /><img src="/img/mision.png" alt="misi" width="151" height="35" /><img src="/img/contactenos.png" alt="con" width="151" height="35" /><img src="/img/marco.png" alt="marco" width="45" height="35" /><img src="/img/marco.png" alt="marc" width="45" height="35" /></td>
</tr>
</table>

<table width="857" height="518" border="0">
<tr>
<td width="851" valign="top"><table width="855" height="56" border="0">
<tr>
<td width="159" height="52">&nbsp;</td>
<td width="158"><img src="file:///F|/Sitio sin nombre 1/img/tel.png" width="160" height="25" alt="telefono" /></td>
<td width="524"><img src="file:///F|/Sitio sin nombre 1/img/email.png" width="350" height="25" /></td>
</tr>
</table>
<table width="711" height="472" border="0" align="right">
<tr>
<td width="516" height="20" align="center">Preguntas</td>
<td width="172" align="center">visitas</td>
<td width="9" rowspan="3">&nbsp;</td>
</tr>
<tr>
<td height="9" align="center"><a href="ind.log.faq.res1.php"><? echo $pre ?></a></td>
<td width="172" align="center"><?php echo $pre2 ?></td>
</tr>
<tr>
<td height="75" align="center"><?php echo $pre1 ?></td>
<td width="172" align="center">&nbsp;</td>
</tr>
<tr>
<td height="47" align="center"><A HREF="ind.log.faq.res2.php"><? echo $pre3 ?> </A></td>
<td height="47" align="center"><?php echo $pre5 ?></td>
<td rowspan="6">&nbsp;</td>
</tr>
<tr>
<td height="44" align="center"><A HREF="ind.log.faq.res3.php"><? echo $pre6 ?> </A></td>
<td height="44" align="center"><?php echo $pre8 ?></td>
</tr>
<tr>
<td height="63" align="center"><A HREF="ind.log.faq.res4.php"><? echo $pre9 ?> </A></td>
<td height="63" align="center"><?php echo $pre11 ?></td>
</tr>
<tr>
<td height="58" align="center"><A HREF="ind.log.faq.res5.php"><? echo $pre12 ?> </A></td>
<td height="58" align="center"><?php echo $pre14 ?></td>
</tr>
<tr>
<td height="46" align="center"><A HREF="ind.log.faq.res6.php"><? echo $pre15 ?> </A></td>
<td height="46" align="center"><?php echo $pre17 ?></td>
</tr>
<tr>
<td height="59" align="center"><A HREF="ind.log.faq.res7.php"><? echo $pre18 ?> </A></td>
<td height="59" align="center"><?php echo $pre20 ?></td>
</tr>
</table>
<table width="142" height="320" border="0" bgcolor="#D0DECF">
<tr>
<td width="136"bgcolor="#D0DECF"><a href="../ind.log.actividades.php" target="_self"><img src="/img/actividades.png" width="135" height="20" border="0" /></a></td>
</tr>
<tr>
<td><a href="../ind.log.noticias.php" target="_self"><img src="/img/noticias.png" width="134" height="20" border="0" /></a></td>
</tr>
<tr>
<td><a href="..ind.log.consejo.php" target="_self"><img src="/img/dejeconsejo.png" width="133" height="20" border="0" /></a></td>
</tr>
<tr>
<td><a href="../ind.log.faq.php" target="_self"><img src="/img/FAQ.png" width="86" height="20" border="0"/></a></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>
<p>&nbsp;</p></td>
</tr>
</table>
<p>&nbsp;</p>
<table width="863" border="0">
<tr>
<td width="748" height="44">&nbsp;</td>
<td width="150"><img src="file:///F|/Sitio sin nombre 1/img/ugudesign.png" width="150" height="40" /></td>
</tr>
</table> <p>&nbsp;</p></td>
</tr>
</table>
</body>
</html>
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:41.