A bit rough and ready but I think this is kind of what you asked for: ** THIS IS UNTESTED CODE ** <?php $user_array = array(); $form_input = $_GET['namesearch']; $sql = "SELECT id, name FROM user WHERE name LIKE '%$form_input%' ORDER BY id"; $result = mysql_query($sql) or die ("Query failed: " . mysql_error()); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $id = $row['id']; $name = $row['name']; $user_array[$id] = $name; // Or simply $user_array[] = $name }
...some code... foreach ($user_array as $id2 => $name2) { echo "$id2 $name2 <br/>"; } ...some code... // Determine a valid value for $x and then: $name3 = $user_array[$x]; ?> HTH Graham -----Original Message----- From: Niklas Ojala [mailto:[EMAIL PROTECTED] Sent: 29 September 2004 10:04 To: [EMAIL PROTECTED] Subject: [PHP] PHP Data cache ideas/solutions Hello I am kind of new to this news thing, but here goes. I am looking for a class or some samples that would read a table from mysql and store it in an array variable, so that it will be avilable to other parts of the page without having to get it from the database again. So I would like to only get the table once per page load but I must be able to filter the table to get the data that I want. I am looking for some similar code to get me started or other ideas on how to make less queries to the database. /Niklas Ojala -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php