Page 2 of 2

Posted: Mon Feb 21, 2005 10:00 am
by danf_1979
I get no output with that... inside the function or outside...

Posted: Mon Feb 21, 2005 10:06 am
by feyd
then you're doing something wrong..

Posted: Mon Feb 21, 2005 10:11 am
by danf_1979
Ok, I got something new going on, I think I'm in the right direction

Code: Select all

function prueba ($edit) {
if ($edit !== 0){
	for ($x = 1; $x <= 8; $x++) &#123;
	$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))
			&#123;
				 $get_edit_pregunta&#1111;] = $registro_edit_pregunta;
					&#125;
				&#125;
			return $get_edit_pregunta;
			
				&#125;
			&#125;
			
			

$var = prueba ($edit);
for ($x = 0; $x <= 8; $x++) &#123;
echo "&#123;$var&#1111;$x]&#125;<br>";
&#125;
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!

Posted: Mon Feb 21, 2005 10:16 am
by feyd
print_r($var).. it's all in arrays..

Posted: Mon Feb 21, 2005 10:24 am
by danf_1979
Ok, you were right, but I got this little problem with the output.

Code: Select all

$var = prueba ($edit);
for ($x = 0; $x < count($var); $x++) &#123;
print_r($var&#1111;$x])."<br>";
&#125;
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 :(

Posted: Mon Feb 21, 2005 10:26 am
by feyd
echo $var[$x][0];

within the for loop.. time to play a lot with arrays :P

Posted: Mon Feb 21, 2005 10:29 am
by danf_1979
Thank U!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! I love this forum!!! I'm never leaving!!