sqli search result

Hi there all this is my first post woop! woop! ;D
I have a successful guestbook & download manager working on my DB.

The download_manager table is as follows [only 5 showing examples … have 1 to 40]

id FILE DOWNLOADS
== === ============
1 01.zip 34
2 02.zip 7
3 03.zip 11
4 04.zip 0
5 05.zip 1

if I specify the row with the id value, all I want to view is the corresponding DOWNLOADS value on the same row.

[php]

<?php error_reporting(E_ALL^E_NOTICE); require('connect.php'); $id = $_GET['xx']; $result = mysqli_query("SELECT * FROM download_manager WHERE id = '$id'"); $data = mysqli_fetch_assoc($result); $result->close(); $body = $data['DOWNLOADS']; echo "returnBody=$body"; ?>

[/php]

And This is my Action Script code for the page to view the result.

//--###### IMPORT ######--// 

import flash.events.Event; 

import flash.net.URLRequest; 

import flash.net.URLVariables; 

import flash.net.URLLoader; 

//--# DOWNLOAD COUNTER #--// 

var urlVariables:URLVariables = new URLVariables(); 

var request:URLRequest = new URLRequest("update.php?xx=1"); 

request.data = urlVariables; 

var getVariables:URLLoader = new URLLoader(); 

getVariables.dataFormat = URLLoaderDataFormat.VARIABLES; 

getVariables.addEventListener(Event.COMPLETE, completeHandler); 

getVariables.load(request); 

function completeHandler(event:Event):void 
{ 
	dCounter.text = "" + event.target.data.returnBody; 
} 

//--# DOWNLOAD BUTTON #--// 

dload01.addEventListener(MouseEvent.MOUSE_OVER, dOver); 

dload01.addEventListener(MouseEvent.MOUSE_OUT, dOut); 

dload01.addEventListener(MouseEvent.CLICK, dClick); 

function dClick(e:MouseEvent):void 
{ 
	navigateToURL(new URLRequest("download.php?file=temp_01.zip"), '_self'); 
} 
function dOut(e:MouseEvent):void 
{ 
	dload01.gotoAndPlay("out"); 
} 
function dOver(e:MouseEvent):void 
{
	dload01.gotoAndPlay("over"); 
}

//--####### STOP #######--//

Hope someone can help

Steven

If all you want is the downloads column value, change your query to

SELECT DOWNLOADS FROM download_manager WHERE id = '$id'"

Then

$data = mysqli_fetch_assoc($result); echo $data['DOWNLOADS'];

is the as3 tag ok how I call the php ?

var request:URLRequest = new URLRequest("update.php?xx=1");

[php]

<?php error_reporting(E_ALL^E_NOTICE); require_once 'connect.php'; $id = $_GET['xx']; $body = ""; $sql = mysql_query("SELECT * FROM download_manager WHERE id = $id"); $row = mysqli_fetch_assoc($sql); $downloads = $row["DOWNLOADS"] $body .= '' . $downloads . ''; mysql_free_result($sql) mysql_close(); echo "returnBody=$body"; exit(); ?>

[php]

please, please can someone help with this as it is so simple but cant get it to work & have been

at it for 2-3 weeks.

Its so easy its dumb.

TABLE AS FOLLOWS

id FILE DOWNLOADS
== === ============
1 01.zip 34
2 02.zip 7
3 03.zip 11
4 04.zip 0
5 05.zip 1

All I want is the download column where I specify the id to show in flash AS3.

var variables_re:URLVariables = new URLVariables();
var varSend_re:URLRequest = new URLRequest("update.php?xx='1'");
varSend_re.method = URLRequestMethod.POST;
varSend_re.data = variables_re;
var varLoader_re:URLLoader = new URLLoader;
varLoader_re.dataFormat = URLLoaderDataFormat.VARIABLES;
varLoader_re.addEventListener(Event.COMPLETE,completeHandler_re);
function completeHandler_re(event:Event):void{
if(event.target.data.returnBody==""){
dCounter.textField.opaqueBackground = 0x333333;
dCounter.text="No data coming through."
}else{
dCounter.editable = false;
dCounter.condenseWhite = true;
dCounter.textField.opaqueBackground = 0xFFFFFF;
dCounter.htmlText = "" + event.target.data.returnBody;
}
}
variables_re.comType = "requestEntries";
varLoader_re.load(varSend_re);

everyone says code is good on both :slight_smile: so why can I not see it on my page when loaded :frowning:

PLZ PLZ PLZ HELP

so what is actually happening when you try your code? do you get errors? or what is displayed/not displayed? thanks

HI … SORRY M8 I FINALLY WORKED IT OUT.

This is the final code

[code]import flash.events.Event;
import flash.net.URLRequest;
import flash.net.URLVariables;
import flash.net.URLLoader;

//–### DOWNLOAD COUNTER ############################################–//

var urlVariables:URLVariables = new URLVariables();
var request:URLRequest = new URLRequest(“update.php?xx=1”);
request.data = urlVariables;
var getVariables:URLLoader = new URLLoader();
getVariables.dataFormat = URLLoaderDataFormat.VARIABLES;
getVariables.addEventListener(Event.COMPLETE, completeHandler);
getVariables.load(request);
function completeHandler(event:Event):void
{
if(event.target.data.returnBody==""){
dCounter.textField.selectable = false;
dCounter.condenseWhite = true;
dCounter.text= “NO DATA”
}else{
dCounter.textField.selectable = false;
dCounter.condenseWhite = true;
dCounter.htmlText = “” + event.target.data.returnBody;
}
}[/code]

[php]<?php
require_once (‘connect.php’);
$id = $_GET[‘xx’];
$body = “”;
if ($id == 0)
{
$body = ‘NO DATA’;
}
else
{
$result = mysql_query(“SELECT * FROM download_manager WHERE id = $id”);
$row = mysql_fetch_assoc($result);
$body = ‘’.$row[‘DOWNLOADS’].’’;
}
echo “returnBody=$body”;
exit();
?>[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service