Welcome, Guest. Please login or register.
Did you miss your activation email?
05/22/12, 06:13
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  Server side Scripting and Database Support
| |-+  MySQL, PostgreSQL, MS SQL, Access (Moderators: Flash-db, Musicman, Ronald Wernecke, Jorge Solis, Andries Seutens)
| | |-+  search not out writing previous results... pull my hair out.
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: search not out writing previous results... pull my hair out.  (Read 3492 times)
brentc73
Server what's that
*
Posts: 16


View Profile WWW
« on: 10/03/08, 20:22 »

Me again...

I created a flash/mysql/php photo search engine (tweaking code I found on this site), when I do the initial search the results are perect. If I do another search and there are fewer results than the first search the older result will show along with the new ones... hope this makes sense.

Example: search "a" and 10 photos show up, then search term "b" and 5 photo show up plus the 5 photos from search "a".

I need the search to only show the current search results... and I cannot figure it out.

Php code
Code:

<?
//Database Connectivity Variables//
$host = "website.com";
$dbuser = "username";
$dbpass = "passwprd";
$dbname = "database";
$table = "Flashsearch";
//Create a connection to the MySQL Database//
$connection = @mysql_connect($host,$dbuser,$dbpass) or die("Couldn't Connect.");
$db = @mysql_select_db($dbname, $connection) or die("Sorry, I could not select the requested Database ");
//SQL Querys
$Fname =  $_POST['search'];
$sql = "SELECT * FROM Flashimages where Fname like '%$Fname%' ORDER BY Fname ASC";
$result = @mysql_query($sql, $connection) or die("Couldn't execute query.");
$count = 0;
while($row=mysql_fetch_array($result)){
echo "Fname$count=$row[Fname]&Furl$count=$row[Furl]&Fimage$count=$row[Fimage]&";
$count++;
}
echo "count=$count";
?>

and the AS

Code:
stop();
bar._visible = false;
search.tabIndex = 1;
var receiveData_lv:LoadVars = new LoadVars();
var formValidated:Boolean;
var errorMessages:Array = new Array();
receiveData_lv.ref = this;
receiveData_lv.onLoad = function(success) {
if (this.count == 0) {
message0_txt.text = "No entries found";
trace("No entries found");
}
if (this.count>=4) {
this._parent.mores._visible = false;
trace("true");
}
if (success) {
for (var i = 0; i<this.count; i++) {
this.ref["news"+i].text = this["Fname"+i];
trace(this.ref["news"+i]);
this.ref["c"+i].loadMovie(this["Fimage"+i]);
bar._visible = false;
this.ref["b"+i].uri = this["Furl"+i];
delete (this["Fname"+i]);
this.ref["b"+i].onRelease = function() {
getURL(this.uri, "iframemain");

};
}
}
};
submit_btn.onRollOver = function() {
this.gotoAndStop(2);
error1.text = "";
};
submit_btn.onRollOut = function() {
this.gotoAndStop(1);

};
function sendIt() {
//this clears the error text field if they have been populate previously
clearTextFields();
errorMessages.length = 0;
//empty the array so next time the submit button is clicked the array is not already populated
formValidated = checkForm();
if (formValidated) {
//the form is valid and so now we can send details to our PHP file
//populate LoadVars object with the field values
var sendData_lv:LoadVars = new LoadVars();
sendData_lv.search = search.text;
var unnew = new Date().getTime();
//trace(sendData_lv.email);
//trace("valid");
sendData_lv.sendAndLoad("http://www.website.com/New/search_thumbs.php?unnew="+unnew, receiveData_lv, "POST");
} else {
//populate textfields with the error messages
for (var i = 0; i<errorMessages.length; i++) {
this["message"+i+"_txt"].text = errorMessages[i];
trace(errorMessages[i]);
}
}
}
function checkForm():Boolean {
//check whether the name field is empty
if (search.text == "") {
errorMessages.push("Please enter a search term!");
}
if (search.text.length<0) {
errorMessages.push("Search must have a minimum of 1 letters");
}
//if at this point the array is empty i.e has length 0, then this in effect means the form has passed all checks                                               
if (errorMessages.length == 0) {
return true;
} else {
return false;
}
}
function clearTextFields():Void {
for (var i = 0; i<errorMessages.length; i++) {
this["message"+i+"_txt"].text = "";
}
}
submit_btn.onRelease = function() {
sendIt();
bar._visible = true;
};
keyListener = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(Key.ENTER)) {
sendIt();
}
};
Key.addListener(keyListener);

Any help would be apprecaited.
« Last Edit: 10/04/08, 15:08 by brentc73 » Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #1 on: 10/05/08, 18:20 »

Prior to populate your textfields, you should clean it. Seems you're not creating the textfields on the fly byt just filling with the results. So when the user perform a new search, preiously to send the data to the PHP script, use a loop to clean all your textfields

Jorge
Logged

brentc73
Server what's that
*
Posts: 16


View Profile WWW
« Reply #2 on: 10/06/08, 17:01 »

Hi Jorge,

No sure how to do what you suggested, could you give me hint?

Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #3 on: 10/07/08, 05:38 »

Suppose you have ten textfields, currently you're populating like this:

if (success) {
	
	
for (var 
0i<this.counti++) {
	
	
	
this.ref["news"+i].text this["Fname"+i];
                        ....

Now prior to populate, you should clean. How many textfields do you have? 10? then

receiveData_lv.onLoad = function(success) {
    for (var 
0i<10i++) {
	
	
	
this.ref["news"+i].text ""

And the same for each of your textfields

Jorge
Logged

brentc73
Server what's that
*
Posts: 16


View Profile WWW
« Reply #4 on: 10/15/08, 15:35 »

Thank you very much.
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
anything