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>";
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

how to get different value in second view of webdynpro?
hello guys,

In ABAP webdynpro I am trying to create one application having two views.

default SAP userid
hi,, I just like to know if it is ok to use the default SAP user id (SAP*)?

PHP hyperlinks generator
Hi

I need some help to get this done using php:


1 - I have few hyperlinks say 500

Strange HTML Tag?
I recently noticed some odd HTML appear in some of the websites I host. Not all of them are run on a

How can i steam a video on my PHP site? (non YouTube)
Basically I have a PHP site and don't want to give page rank to YouTube. I just want to stream a bas

Asset Transfer from One plant to another within same company code
Hi,

Please advise how to transfer one asset from one plant to another plant within same c

IS this code correct
The reason i ask is everything underneath it appears to be alink as well, tis blimmin annoying

str_replace help
I am thinking str_replace is my only option to filter outputs from my database to convert them to sa

calendar dates and hours compare problem
i have a calendar in wordpress, everything works great except that i can make 2 meetings at the same

Checking if variable is 0 as opposed to NULL/Empty...
I'm trying to write some code that will retrieve a user's access level from my database and if it do

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