Okay, I figured out that the issue is not due to the PHP code, but by the query I'm using against the MySQL DB... What I need to know is how to structure the code where the query is based off of fields filled in by the user. I would like to structure the query where if the user provides a value for vendorNumber, and leaves the rest of the fields blank, the query would be "select * from changeLog where vendorNumber = '$vendorNumber';" The current query, when run in MySQL Control Center, gives the same behavior as on the website. Would I have to write this portion of the code in javascript, or some other client side scripting language to get the dynamic query built? Thanks, Mike Hilty "John W. Holmes" <holmes072000@charter.net> wrote in message 002b01c2cd7a$2a86d9a0$7c02a8c0@coconut">news:002b01c2cd7a$2a86d9a0$7c02a8c0@coconut... > > I am a novice PHP dev having a strange issue with > mysql_fetch_array. > > For some reason, it is keeping data from previous queries in the > array, > > and > > displaying it in the web page. > > My development platform is Win2k SP2, Apache 1.3.23, PHP 4.3.0, > > MySQL-MAX 3.23.47-nt. > > Here is the code that I am using: > > > > <?php > > // open database connection > > $connection = mysql_connect(localhost, username, password) or die > ("Unable > > to > > connect!"); > > > > // select database > > mysql_select_db(vendorNameChange) or die ("Unable to select > database!"); > > > > // generate and execute query > > $query = "select * from changelog where changedBy = '$changedBy' or > > vendorNumber = '$vendorNumber' > > or oldName like '$oldName' or newName like '$newName' or > newVendorNumber = > > '$newVendorNumber'"; > > $result = mysql_query($query) or die ("Error in query: $query. " . > > mysql_error()); > > > > if ($row = mysql_fetch_array($result)) { > > > > do { > > print "<b><u>Old vendor number</u>: </b>"; > > print $row["vendorNumber"]; > > print "<br>"; > > <snip> > > </snip> > > } while($row = mysql_fetch_array($result)); > > > > } else {print "Sorry, no records were found!";} > > > > // close database connection > > mysql_close($connection); > > > > ?> > > > > I am looking for a way to initialize the array, and display only > the > > data returned from the current query on the page. Any help with this > > would > > be greatly appreciated. > > $row = array(); > > will initialize the $row variable to an empty array. Or you can use > unset($row) to just get rid of it entirely. > > The problem isn't with mysql_query(), it's just that $row is retaining > data from a previous loop in your script. > > ---John W. Holmes... > > PHP Architect - A monthly magazine for PHP Professionals. Get your copy > today. http://www.phparch.com/ > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php