Filtering an Array Based on Value


Posted on 16th Feb 2014 07:03 pm by admin

I have a very simple script set up that pulls data from a database and is output using this code:

Code: Print "<table border cellpadding=3>";
Print "<th>sku</th><th>status</th><th>name</th>";
Did you know?Explore Trending and Topic pages for more stories like this.
while($info = mysql_fetch_array( $data ))
{
Print "<tr>";
Print "<td>".$info['sku'] . "</td> ";
Print "<td>".$info['status'] . "</td> ";
Print "<td>".$info['name'] . " </td></tr>";
}
Print "</table>";
However, I would like to only output rows that meet certain criteria. More specifically, I only want to show rows in which the 'status' field contains the text value "Out of stock" at any position within the field. (e.g. some fields say "Out of stock. On order.")

Any help with this will be greatly appreciated.

And here's a sample of what the table output currently looks like:
2250In stock.Product One2251In stock. On order.Product Two2252Out of stock. On order.Product Three2253Out of stock.Product Four
No comments posted yet

Your Answer:

Login to answer
285 Like 42 Dislike
Previous forums Next forums
Other forums

selection tool on raster image
Hi!
I have to implement in my app a selection tool which lets users to select region of any shape

ScriptManager History and Opera Issue
I am having an issue in opera with the ScriptManager. I have a ScriptManager on a page with history

More pug propaganda.
http://www.youtube.com/watch?v=8Kkrmubsgf8

The commercial is definitely worth watching pug aw

Bandwidth monitoring?
Hi guys,

I need a little information I have written a php app and I occurred to that I need

validating url
im trying to validate url's sent to me by a form
the url's im collecting are for placing banners

image upload, resize THEN submit form
Ok so I have a form that requires the user to upload an image, and then do something with that image

Just wondering what you think about my site
I am new to phpfreaks i just seen this form and thought it would be cool to see what other thought a

License Issue - service type user
Hi,

I would like to understand the following issue regarding sap license.
I wish to

Check before inserting in DB ???
This is my code
---------------
if ( $_POST ['Submit'])
{{
$username = $_POST ['usernm

mysql_query returning boolean instead of mysql ressource
Hi,

I seem to have a weird issue with the php command mysql_query. I pass 2 arguments the que

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash