Highlighted

retrieve list from a SQL database and create links for each lines in AS3

Contributor ,
Jan 11, 2016

Copy link to clipboard

Copied

I'm trying to do an AIR app with these conditions :

I've got a SQL database. In my table there is a "categories" column (with differents categories (computer, books..etc)).

enter image description here

In my AS3 I manage to retrieve "theDescription" when the user choose a categorie. With the URLMethod and a php file.

   // create SQL $sql = "SELECT * FROM annonces where categorie = '$categorie'";

$sql_result = mysql_query($sql, $connection) or die ("Couldn't execute query.");

$num = mysql_numrows($sql_result); $phptheDescription = "";

$counter = 0;

while ($row = mysql_fetch_array($sql_result)) {

$theDescription = $row["theDescription"];

$phptheDescription = $theDescription;

}

echo  "phptheDescription=" . $theDescription;

So my AS3 code is retrieving the $phptheDescription from the php and displays it in a output_txt

Problem : in my output_txt, only ONE "theDescription" is displayed. But I have TWO items in the categorie "Informatique" (and I can have 100 items in the same categories).

How do I do to display all "theDescription" that are in the same categories ?

Ex: If I choose "Informatique", it should display "Une Surface Pro 3" and "Un IMAC". But it only displays the last item "Un IMAC".

And, after that, is it possible to create "links" for each item displayed ?

Here's 2 shorts videos (20 sec) explaining my problems :

https://vid.me/DS2r

http://sendvid.com/6iesrygk

Thx

Hi there - I've never used PHP so I may be wrong here - but It looks to me as though you're looping through the records, each time resetting $theDescription to be whatever is in the current record (rather than building up the output). So you're effctively only echoing the last record in the query.

I think you should be either executing the echo command inside your while loop, or alternatively concatenating to a string inside the loop and then echoing this at the end of the loop ?

I'd probably generate XML in the PHP (just by concatenating strings) and then use this in my AS3 code.

TOPICS
Development

Views

156

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

retrieve list from a SQL database and create links for each lines in AS3

Contributor ,
Jan 11, 2016

Copy link to clipboard

Copied

I'm trying to do an AIR app with these conditions :

I've got a SQL database. In my table there is a "categories" column (with differents categories (computer, books..etc)).

enter image description here

In my AS3 I manage to retrieve "theDescription" when the user choose a categorie. With the URLMethod and a php file.

   // create SQL $sql = "SELECT * FROM annonces where categorie = '$categorie'";

$sql_result = mysql_query($sql, $connection) or die ("Couldn't execute query.");

$num = mysql_numrows($sql_result); $phptheDescription = "";

$counter = 0;

while ($row = mysql_fetch_array($sql_result)) {

$theDescription = $row["theDescription"];

$phptheDescription = $theDescription;

}

echo  "phptheDescription=" . $theDescription;

So my AS3 code is retrieving the $phptheDescription from the php and displays it in a output_txt

Problem : in my output_txt, only ONE "theDescription" is displayed. But I have TWO items in the categorie "Informatique" (and I can have 100 items in the same categories).

How do I do to display all "theDescription" that are in the same categories ?

Ex: If I choose "Informatique", it should display "Une Surface Pro 3" and "Un IMAC". But it only displays the last item "Un IMAC".

And, after that, is it possible to create "links" for each item displayed ?

Here's 2 shorts videos (20 sec) explaining my problems :

https://vid.me/DS2r

http://sendvid.com/6iesrygk

Thx

Hi there - I've never used PHP so I may be wrong here - but It looks to me as though you're looping through the records, each time resetting $theDescription to be whatever is in the current record (rather than building up the output). So you're effctively only echoing the last record in the query.

I think you should be either executing the echo command inside your while loop, or alternatively concatenating to a string inside the loop and then echoing this at the end of the loop ?

I'd probably generate XML in the PHP (just by concatenating strings) and then use this in my AS3 code.

TOPICS
Development

Views

157

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 11, 2016 0
Participant ,
Jan 12, 2016

Copy link to clipboard

Copied

Hi there - I've never used PHP so I may be wrong here - but It looks to me as though you're looping through the records, each time resetting $theDescription to be whatever is in the current record (rather than building up the output). So you're effctively only echoing the last record in the query.

I think you should be either executing the echo command inside your while loop, or alternatively concatenating to a string inside the loop and then echoing this at the end of the loop ?

I'd probably generate XML in the PHP (just by concatenating strings) and then use this in my AS3 code.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 12, 2016 0