Jump to content

CLEAR mysql_query FOR NEW SEARCH


nightkarnation

Recommended Posts

Hey i have a doubt...and I think this might be the problem...

 

Im retrieving some information from mysql through php & flash

 

Here's the php code:

 

if ($action == "searchInfo")
{

//retreive data from flash
$location=$_POST['location'];
$user_id=$_POST['user_id'];

        $connect = mysql_connect("localhost", "root", ""); 
        mysql_select_db("learning", $connect); 
        $result = mysql_query("SELECT user_id, email, location FROM tbl_auth_user where location = '$location' OR user_id = '$user_id'"); 
        $cant = 0; 
        while($row=mysql_fetch_array($result)){ 
            echo "user_id$cant=$row[user_id]&email$cant=$row[email]&location$cant=$row[location]&"; 
            $cant++; 
        } 
        echo "cant=$cant"; 

}

 

This works perfect, but lets say the first request i looked for location = Argentina (working perfect), i request for the 2nd time another location or user_id and then on the 3rd time i request again the first location...On flash its giving me the results of the 1st query and the 2nd one...

 

How can i delete the old query results before perfoming a new one ? so it querys only whats being search at that time

Link to comment
https://forums.phpfreaks.com/topic/121609-clear-mysql_query-for-new-search/
Share on other sites

Thanx for the reply revraz!

 

I tried on php and flash...but still not working...

Here's the complete code:

 

FLASH CODE:

 

//btnDownload = download and display user information from mysql! NAME / EMAIL / LOCATION  
btnDownload.onRelease = function() {
//checks if there is something to search for
if (txtName.length | txtLocation.length) {
	//btn data:
	searchBack = false;
	searchNext = true;
	//
	onSearch = true;
	//CLEAN THE SEARCH RESULTS FIRST:
	txtName0.text = "";
	txtEmail0.text = "";
	txtLocation0.text = "";
	txtName1.text = "";
	txtEmail1.text = "";
	txtLocation1.text = "";
	txtName2.text = "";
	txtEmail2.text = "";
	txtLocation2.text = "";
	txtName3.text = "";
	txtEmail3.text = "";
	txtLocation3.text = "";
//CLEANING WHAT COULD BE STORED FROM PREVIOUS SEARCH
	myData.user_id = "";
	myData.location = "";
	//BRING BACK pageCounter to 0
	pageCounter = 0;
	//DOWNLOAD THE SEARCH INFORMATION:
	myData.load("http://localhost/Test/phpAndMysql/flash%20user%20admin%201.4/login.php");
	myData.action = "searchInfo";
	myData.onLoad = function(succes) {
		if (succes) {
			//
			for (var i = 0; i<this.cant; i++) {
				_root["txtName"+i].text = this["user_id"+i];
				_root["txtEmail"+i].text = this["email"+i];
				_root["txtLocation"+i].text = this["location"+i];
			}
		} else {
			trace("Error loading data");
		}
		//Check if there are less than 4 results,if there is one with no value searchNext = true disables btnNext
		if (txtName0.text == "") {
			searchNext = true;
		} else {
			searchNext = false;
		}
		if (txtName1.text == "") {
			searchNext = true;
		} else {
			searchNext = false;
		}
		if (txtName2.text == "") {
			searchNext = true;
		} else {
			searchNext = false;
		}
		if (txtName3.text == "") {
			searchNext = true;
		} else {
			searchNext = false;
		}
		if (myData.user_id4 == undefined) {
			searchNext = true;
		} else {
			searchNext = false;
		}
		trace("user_id4: "+myData.user_id4);
		trace(txtName3.text);
		trace(searchNext);
	};
	myData.user_id = txtName.text;
	myData.location = txtLocation.text;
	myData.sendAndLoad("http://localhost/Test/phpAndMysql/flash%20user%20admin%201.4/login.php", myData, "POST");
}
};

 

PHP CODE:

 

if ($action == "searchInfo")
{

$location = "";
$user_id = "";
//retreive data from flash
$location=$_POST['location'];
$user_id=$_POST['user_id'];

        $connect = mysql_connect("localhost", "root", ""); 
        mysql_select_db("learning", $connect); 
        $result = mysql_query("SELECT user_id, email, location FROM tbl_auth_user where location = '$location' OR user_id = '$user_id'"); 
        $cant = 0; 
        while($row=mysql_fetch_array($result)){ 
            echo "user_id$cant=$row[user_id]&email$cant=$row[email]&location$cant=$row[location]&"; 
            $cant++; 
        } 
        echo "cant=$cant"; 

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.