Hello all,
I have a large database that I would like to query but I would like to exclude a large number of records. I am wondering if the query is the place to do this, since using multiple 'WHERE field1 !=' or 'WHERE field1 NOT LIKE '% would get a bit messy.
So, I started thinking arrays. I could run the query and get all records based on other criteria. I could then set up an array based on the content in the field names 'hname' and display only what I do want to display. Eventually, there would be about 40 unique values in 'hname' that I would like to include.
When I display the data, I could run through the array using a foreach loop and display only the rows with the value in the array for 'hname'.
$query = "SELECT * FROM documents";
$result = mysql_query($query) or
die (mysql_error());
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$include = array("Jim", "Bob", "Sam", "Jerry");
$hname = $row['hname'];
foreach ($hname as $include) {
$staff = $include;
}
echo "<tr><td width='10%'>" . $staff . "</td>";
}
When I open this page, I get a long listing of:
Warning: Invalid argument supplied for foreach() in /disk2/www/othersites/counturls1.php on line 31
Then all the data follows, including data that I don't want.
I am somewhat new to arrays, so this is all an experiment. Your help is most appreciated.