Hello - I have an SQL database setup which contains Herbal Information such as
CommonName, LatinName, MedicalUse etc, and need to display the information in a
Flash DataGrid Component.
I also have the corresponding PHP script to connect, retrieve, add and delete
items from the database (see below).
Although I am familiar with Flash in a design sense I have limited experience
using Action Scripts and am unable to complete the connection myself. Should I
use AS2 or AS3? Please Help! Sc3
<?php
Define( "DATABASE_SERVER", "xxx" );
Define( "DATABASE_USERNAME", "xxx" );
Define( "DATABASE_PASSWORD", "xxx" );
Define( "DATABASE_NAME", "xxx" );
//connect to the database
$mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME,
DATABASE_PASSWORD);
mysql_select_db( DATABASE_NAME );
// Retrieve exchanged data
$action = $_POST["action"];
$ID=$_POST["ID"];
$CommonName= $_POST["CommonName"];
$LatinName=$_POST["LatinName"];
$MedicalUse=$_POST["MedicalUse"];
$PaganUse=$_POST["PaganUse"];
$Descriprion=$_POST["Description"];
$Toxic=$_POST["Toxic"];
$ImageLink=$_POST["ImageLink"];
// del item
if ($action=="del")
{
$Query="DELETE FROM GB_Herbs WHERE ID='$ID'";
$Result=mysql_query($Query);
}
// add item
if ($action=="add")
{
$Query = "INSERT INTO GB_Herbs
(CommonName,LatinName,MedicalUse,PaganUse,Description,Toxic,ImageLink)
VALUES('$CommonName','$LatinName','$MedicalUse','$PaganUse','$Description','$Tox
ic','$ImageLink')";
$Result = mysql_query($Query);
}
//return a list of all herb items
$Query = "SELECT * FROM GB_Herbs";
$Result = mysql_query( $Query );
$Return = "<DataSet>";
while ( $Item = mysql_fetch_object( $Result ) )
{
$Return .= "<DataThing>";
$Return .= "<ID>".$Item->ID."</ID>";
$Return .= "<CommonName>".$Item->CommonName."</CommonName>";
$Return .= "<LatinName>".$Item->LatinName."</LatinName>";
$Return .= "<MedicalUse>".$Item->MedicalUse."</MedicalUse>";
$Return .= "<PaganUse>".$Item->PaganUse."</PaganUse>";
$Return .= "<Description>".$Item->Description."</Description>";
$Return .= "<Toxic>".$Item->Toxic."</Toxic>";
$Return .= "<ImageLink>".$Item->ImageLink."</ImageLink>";
$Return .= "</DataThing>";
}
$Return .= "</DataSet>";
mysql_free_result( $Result );
print ($Return);
?>
MYSCREENNAMEISUNAVAILABLE - 25 Feb 2008 02:28 GMT
you will find the book recommended to me by someone on this forum, invaluable. David Powers: Foundation PHP5 for Flash. ISBN: 1-59059-466-5
The Feldkircher - 28 Feb 2008 12:26 GMT
Hi
Here is a http://www.adobe.com/devnet/flash/articles/flash_xmlphp.html that
will explain how to do.
It was originally written for FlashMX, but I have tested it in Flash8 without
issue
Hope it helps