Functions, Fors, While, Foreach, Arrays: Problem [SOLVED]
Moderator: General Moderators
Ok, I got something new going on, I think I'm in the right direction
What you told me about the foreach I think is OK, now I got the 3!!! answers, but as "Array". Before, I got only 2 because the for loop wha beginning from $x=1 and somehow the while loop begins from 0, or I think at least...
Now, how can I get to the Array stuff? How can I read the content?
Thanks very much!
Code: Select all
function prueba ($edit) {
if ($edit !== 0){
for ($x = 1; $x <= 8; $x++) {
$query_edit_pregunta = "SELECT pregunta FROM enc_preguntas WHERE idvotacion='$edit' AND idpregunta='$x'";
$result_edit_pregunta = mysql_query($query_edit_pregunta) or die ("Error in query: $query_edit_pregunta. ".mysql_error());
while ($registro_edit_pregunta = mysql_fetch_row($result_edit_pregunta))
{
$get_edit_preguntaї] = $registro_edit_pregunta;
}
}
return $get_edit_pregunta;
}
}
$var = prueba ($edit);
for ($x = 0; $x <= 8; $x++) {
echo "{$varї$x]}<br>";
}Now, how can I get to the Array stuff? How can I read the content?
Thanks very much!
Ok, you were right, but I got this little problem with the output.
returns:
Array ( [0] => ¿Qué busca en nuestro sitio web? ) Array ( [0] => ¿Cómo conoció nuestra empresa? ) Array ( [0] => A usted le interesaría… )
And I'm almost there... but I'm not
Code: Select all
$var = prueba ($edit);
for ($x = 0; $x < count($var); $x++) {
print_r($varї$x])."<br>";
}Array ( [0] => ¿Qué busca en nuestro sitio web? ) Array ( [0] => ¿Cómo conoció nuestra empresa? ) Array ( [0] => A usted le interesaría… )
And I'm almost there... but I'm not