Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Data Integration / February 2008



Tip: Looking for answers? Try searching our database.

SQL / PHP and the DataGrid

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sc3 - 21 Feb 2008 23:37 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.