# Grabbing info based on id# (php mysql)

**URL:** <https://forum.kirupa.com/t/grabbing-info-based-on-id-php-mysql/306695>\
**Category:** Uncategorized\
**Created:** [March 20, 2010, 2:08am UTC](https://forum.kirupa.com/t/grabbing-info-based-on-id-php-mysql/306695 "2010-03-20T02:08:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nescience](https://avatars.discourse-cdn.com/v4/letter/n/cab0a1/32.png) [@nescience](https://forum.kirupa.com/u/nescience)\
**Post date:** [March 20, 2010, 2:08am UTC](https://forum.kirupa.com/t/grabbing-info-based-on-id-php-mysql/306695/1 "2010-03-20T02:08:16Z")

</div>

I’m very new to AS3, PHP, and MYSQL, so forgive me for asking a stupid question…

Anyway, I’m trying to create a website that will grab content from a MYSQL database, and display it inside of a dynamic text field in Flash. There are several buttons on the page, and I want each button to grab different information depending on id #. So far, I’ve done a few tutorials both here and elsewhere, and I’ve finally figured out how to get the Flash to connect to the database, but I’m not sure how to get info based on the id.

My current database only has two columns: id & home\_body with one row. I want to add more rows to this soon so I’ll have something like this:

id | home\_body  
1 | info \<-button 1 grabs this  
2 | info \<-button 2 grabs this

Here’s my code thus far:

**AS3:**

// this code gets the home page data from the database for display  
var homePageText:String;  
// Assign a variable name for our URLVariables object  
var home\_variables:URLVariables = new URLVariables();  
// Build the varSend URL variable  
var home\_varSend:URLRequest = new URLRequest(“cms\_control\_file.php”);  
home\_varSend.method = URLRequestMethod.POST;  
home\_varSend.data = home\_variables;  
// Build the varLoader variable  
var home\_varLoader:URLLoader = new URLLoader;  
home\_varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;  
home\_varLoader.addEventListener(Event.COMPLETE, home\_var\_comp);

```
       home_variables.sendRequest = "get_home_text";    
    // Send the data to the php file
       home_varLoader.load(home_varSend);

```

function home\_var\_comp(event:Event):void {  
// Put the about text from mysql database into the about text field  
homePageText = event.target.data.home\_text;  
home\_txt.htmlText = “” + homePageText;

}

**PHP:**

\<?php  
// connect to your MySQL database here  
include\_once “connect\_to\_mysql.php”;

//////////////////////////////////////////////// Gather Home Page Text ///////////////////////////////////////////////////////////////////  
if ($\_POST[‘sendRequest’] == “get\_home\_text”) {

```
$sql = mysql_query("SELECT home_body FROM cms_content");

while($row = mysql_fetch_array($sql)) { 
      $home_body = $row["home_body"];
      print "home_text=$home_body";
}

```

}

?\>
