Skip to main content
Known Participant
April 14, 2010
Question

php to flash (beginners level)

  • April 14, 2010
  • 2 replies
  • 2283 views
<?php
require_once 'db_config.php';

$sql="SELECT * FROM guestbook";
$result=mysql_query($sql) or die(mysql_error());

$count=mysql_num_rows($result);

while ($data = mysql_fetch_assoc($result)){
   
    $id = $data"[msg_id"];
    $sender = $data["msg_sender"];
    $subject = $data["msg_subject"];
    $text = $data["msg"];
    $date = $data["msg_date"];
   
   
    echo($count);
    echo($id);
    echo($sender);
    echo($subject);
    echo($text);
echo($date);}

?>

wich gives me this result in a browser

Actionscript Code:
21Arnetest 1.2 3hallo, dit is een eerste test berichtje  blablablabalba  grtzzzzzzzzz2010-04-14 14:03:0022Arne Janssenshallo!test nog een keer2010-04-14 14:03:00

now is my question;

how can i write this code better, so that flash can handle it?

do i make an array of the results? ive been reading tutorials on this, but i cant figur it out ...



thx in advance for any help

grtzzz
This topic has been closed for replies.

2 replies

Inspiring
April 15, 2010

yes, you can use delimiters in between of your variables but comma(,)?? I won’t suggest to use comma as a delimiter because there are possibilities that the content/text in variables might contain commas so better to use some other delimiter rather than a comma.


Thanks & Regards

Ankur Arora

Project Leader(Flash and Flex)

http://flashdeveloper.blogspot.com

http://www.ankur-arora.com


kglad
Community Expert
Community Expert
April 14, 2010

add a delimiter to your echos (which you parse in flash):

echo $count.",,";

echo $id.",,";

etc

in flash:

var yourdataA:Array=yoururlloader.data.split(",,");

Allice_DAuthor
Known Participant
April 14, 2010

can u give some more info on this?

a delimiter? and why?

kglad
Community Expert
Community Expert
April 14, 2010

so you can easily parse the data.  and because you're in a while-loop, you should use:

echo $count.",,".$id.",,".$sender.",,".$subject.",,".$text.",,".$date;

then push each echo return into an array in flash.  then split each array element on the ,, delimiter