Page 1 of 1

dataset blues...

Posted: Wed Nov 20, 2002 3:35 pm
by lo-fi

Code: Select all

$result=mysql_query("select * from mydata order by 'id'")or die('died'); 
$num_rows = mysql_num_rows($result); 
$j=0; 
$x=1; 
while($row=mysql_fetch_array($result)){ 
for($j=0;$j<$num_rows;$j++)&#123; 
$name = mysql_field_name($result, $j); 
$object&#1111;$x]&#1111;$name]=$row&#1111;$name]; 
&#125;$x++; 
&#125;
Later in the script I use the below array to gain access to my data

Code: Select all

$i=1; 
$ii=count($object); //quick access function 
for($i=1;$i<=$ii;$i++)&#123; 
echo $object&#1111;$i]&#1111;'your_field_name']; 
&#125;
i got this from php.net manual

but
i need to output

&row0=$article__2|aaaa|tipo 1:&row1=art2|bbbbb|Tipo 2: <-this

any idea?

Posted: Wed Nov 20, 2002 10:28 pm
by volka
unsure wether I got the point but you may try something like

Code: Select all

$result=mysql_query("select * from mydata order by 'id'")or die(mysql_error());
$row_num = 0;
while( $row = mysql_fetch_row($result) )
	echo '&amp;row', $row_num++ , '=', implode('|', $row), ':';
(completely untested, not even by compiler ;) )

Posted: Thu Nov 21, 2002 5:13 am
by lo-fi
hey thanx for the answer,

Code: Select all

function output_data()&#123;#prints the variables to flash, that will then parse them into an array
		$output = "";
		$i=1;
		$ii=count($object);        //quick access function
		for($i=1;$i<=$ii;$i++)&#123;
			$output .= "row".$i."=".$this->recieved_data&#1111;$i]&#1111;$this->fields&#1111;$i]].":";
		&#125;
something like this,
because i cannot hardcode my field names, because it's all dynamic!
&row0=$article__2|aaaa|tipo 1:&row1=art2|bbbbb|Tipo 2:
is what i need to output to flash so i can parse them properly there.
thx!