Counter problem, arrays
Posted: Mon Feb 21, 2005 4:18 pm
Hi again:
I've got the following problem:
I've got a counter with this code:
The problem is that I dont seem capable of adding one (1) to $obtengo_votos_respuestas[$x][$z][0], an array.
$obtengo_votos_respuestas = obtener_votos_respuestas ();
and the function obtener_votos_respuestas () is:
Any help would be appreciated... thanks
I've got the following problem:
I've got a counter with this code:
Code: Select all
for ($x = 1; $x <=8; $x++){
if (!$obtengo_preguntasї$x]ї0] == ''){
$idpregunta = $x;
for ($z = 1; $z <= 11; $z++){
if (!$formї$x]ї$z] == '') {
$idrespuesta = $z;
$query = "UPDATE enc_respuestas SET contador="(int)($obtengo_votos_respuestasї$x]ї$z]ї0] + 1)" WHERE (idvotacion='$idvotacion' AND idpregunta='$idpregunta' AND idrespuesta='$idrespuesta')";
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
}
}
}
}$obtengo_votos_respuestas = obtener_votos_respuestas ();
and the function obtener_votos_respuestas () is:
Code: Select all
function obtener_votos_respuestas () {
global $idvotacion;
for ($x = 1; $x <= 8; $x++){
for ($z = 1; $z <= 11; $z++) {
$query_votos_respuesta = "SELECT contador FROM enc_respuestas WHERE idvotacion='$idvotacion' AND idpregunta='$x' AND idrespuesta='$z'";
$result_votos_respuesta = mysql_query($query_votos_respuesta) or die ("Error in query: $query_votos_respuesta. ".mysql_error());
while ($registro_votos_respuesta = mysql_fetch_row($result_votos_respuesta))
{
$get_contador_respuestaї$x]ї$z] = $registro_votos_respuesta;
}
}
}
return $get_contador_respuesta;
}