By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,406 Members | 1,504 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,406 IT Pros & Developers. It's quick & easy.

Filter function help

P: n/a
Hi. I need help with a filtering function that I can't get to whatever
I try. I have this output that I need to filter:

<tr>
<td class="box_content" align="center">3,259</td>
<td class="box_content"><a
href="/user.php?id=3259">RandomName1</a></td>
<td class="box_content" align="center">4,239,298</td>
<td class="box_content" align="center">4,676</td>
<td class="box_content" align="center">94</td>
<td class="box_content" align="center"><img src="/online.gif"
alt="Online"></td>
</tr>
<tr>
<td class="box_content" align="center">3,260</td>
<td class="box_content"><a
href="/user.php?id=3260">RandomName2</a></td>
<td class="box_content" align="center">6,394,273</td>
<td class="box_content" align="center">5,762</td>
<td class="box_content" align="center">94</td>
<td class="box_content" align="center"><img src="/online.gif"
alt="Online"></td>
</tr>
<tr>
<td class="box_content" align="center">3,261</td>
<td class="box_content"><a
href="/user.php?id=3261">RandomName3</a></td>
<td class="box_content" align="center">8,422,858</td>
<td class="box_content" align="center">15,700</td>
<td class="box_content" align="center">94</td>
<td class="box_content" align="center"><img src="/online.gif"
alt="Online"></td>
</tr>

I need to extract only the rows that matches a value in the second
column bigger than 8,000,000 and the print only that rows. The given
example is just a random one. The actual file to process is bigger and
is changing everytime the filter function is called.

Can you help me out, please? I`ll mail you a beer! I promise :)

Thanks!

Jul 17 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
NRGY,
I need to extract only the rows that matches a value in the second
column bigger than 8,000,000 and the print only that rows. The given
example is just a random one. The actual file to process is bigger and
is changing everytime the filter function is called.

You might want to define your question better.

ex. We have no clue what you mean by what the rows are and what you are
trying to filter and percisely what needs filtering.

Mike
Jul 17 '05 #2

P: n/a
Mike,

The rows are defined by <tr> and </tr> (so everything from a opening
<tr> to a closing </tr> is a row). A column is marked by <td> and
</td>. You should see the HTML marking.

Let me know if you feel me now.

Thank you.

Regards

Jul 17 '05 #3

P: n/a
In article <11**********************@z14g2000cwz.googlegroups .com>,
"NRGY" <nr**@acasa.ro> wrote:
Mike,

The rows are defined by <tr> and </tr> (so everything from a opening
<tr> to a closing </tr> is a row). A column is marked by <td> and
</td>. You should see the HTML marking.

Let me know if you feel me now.

Thank you.

Regards


You just reduced your chances of getting an answer here :o)

I think what he meant was that this is a php newsgroup, you've asked a
question about filtering which implies use of php or MySQL and you've
mentioned rows and columns which also alludes to MySQL. You then
present a big load of HTML.

Is this HTML being generated by PHP? Is the data in the table cells
taken from a MySQL table?

Can upload your php file with a phps extension and give us the URL?

--
Andy Jacobs
www.redcatmedia.net
Intelligent Websites For Intelligent Business People
Jul 17 '05 #4

P: n/a
Andy, I have posted here because here is the comp.lang.PHP group. And
what I need is a PHP filter function. So I don't see why you're picking
on the file to be filtered.

Jul 17 '05 #5

P: n/a
NRGY wrote:
Andy, I have posted here because here is the comp.lang.PHP group. And
what I need is a PHP filter function. So I don't see why you're picking
on the file to be filtered.


Sorry, I agree with Andy. I'm not sure what you're trying to do, either.

For instance - are you trying to read in the HTML you posted? Or are
you trying to generate output similar to the posted HTML, only with
different results? If so, whats the source?

Please be more clear with your question, and you'll get answers.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 17 '05 #6

P: n/a
> Andy, I have posted here because here is the comp.lang.PHP group. And
what I need is a PHP filter function. So I don't see why you're picking
on the file to be filtered.


What Andy said was exactly as I ment it.
For instance you have a data output normally from a database using php.
We have no clue as to how this data is generated, what you are using
it for, what the possible data types are, the list keeps going.

What you presented is this data talking about extracting data from rows
and columns. Are you processing just the html files from a webpage?
You most likely require regular expressions.

Mike
Jul 17 '05 #7

P: n/a
Guys, guys... That's the file that needs to be filtered for results
bigger than 8,000,000. Why you brought up databases and such? It is a
HTML page fetched by a socket connection. The output is similar to my
initial posting. Only that I don't want to output all of it - I want to
display only the values that exceed 8,000,000. In the case I gave as an
example the filtering function will grab only:
<tr>
<td class="box_content" align="center">3,261</td>
<td class="box_content"><a
href="/user.php?id=3261">RandomName3</a></td>
<td class="box_content" align="center">8,422,858</td>
<td class="box_content" align="center">15,700</td>
<td class="box_content" align="center">94</td>
<td class="box_content" align="center"><img src="/online.gif"
alt="Online"></td>
</tr>

So why all the fuss about databases and such when all I've asked help
for was a function to filter out the result and display accordingly?

Jul 17 '05 #8

P: n/a
NRGY wrote:
Guys, guys... That's the file that needs to be filtered for results
bigger than 8,000,000. Why you brought up databases and such? It is a
HTML page fetched by a socket connection. The output is similar to my
initial posting. Only that I don't want to output all of it - I want to
display only the values that exceed 8,000,000. In the case I gave as an
example the filtering function will grab only:
<tr>
<td class="box_content" align="center">3,261</td>
<td class="box_content"><a
href="/user.php?id=3261">RandomName3</a></td>
<td class="box_content" align="center">8,422,858</td>
<td class="box_content" align="center">15,700</td>
<td class="box_content" align="center">94</td>
<td class="box_content" align="center"><img src="/online.gif"
alt="Online"></td>
</tr>

So why all the fuss about databases and such when all I've asked help
for was a function to filter out the result and display accordingly?


If you would have been clear about that at the outset, there wouldn't
have been any confusion.

The reason for the "fuss about databases..." is that most pages like
this are generated by databases - and it's much easier to filter at the
database level than later.

Now that there's something concrete to work on, we can take a look.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 17 '05 #9

P: n/a
My thoughts:
<tr>
<td class="box_content" align="center">3,261</td>
<td class="box_content"><a
href="/user.php?id=3261">RandomName3</a></td>
<td class="box_content" align="center">8,422,858</td>
<td class="box_content" align="center">15,700</td>
<td class="box_content" align="center">94</td>
<td class="box_content" align="center"><img src="/online.gif"
alt="Online"></td>
</tr>


Write a regular expression. First that takes apart the <tr></tr> and
separates them into rows, one that separates the column data.

Then for each part of the column array check for a number exceeding
8,000,000, then if one is found keep that data, otherwise unset that
portion of the array.

When all filtering is done. Display the results by running through the
array.

Although I do not have a regular expression written for this, I would
suggest while writing it take a peak at http://www.regexplib.com
Mike
Jul 17 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.