473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

display problem

I have this script which checks multiple domains for a link back to my site:

function backlinkCheck($siteurl, $recip) {
$arrText = @file($siteurl);
for ($i=0; $i<count($arrText); $i++) {
$text = $text . $arrText[$i];
}
if (eregi($recip, $text)) {
return true;
} else {
return false;
}
}

The problem is that It displays true or false only after it went through the
whole list.
Id like it to display each site after they are done. Anyone can tell me how
to do this?

--
Yang
Jul 17 '05 #1
6 1639
Yang Li Ke wrote:
I have this script which checks multiple domains for a link back to my site:

function backlinkCheck($siteurl, $recip) {
$arrText = @file($siteurl);
for ($i=0; $i<count($arrText); $i++) {
$text = $text . $arrText[$i];
}
if (eregi($recip, $text)) {
return true;
} else {
return false;
}
}

The problem is that It displays true or false only after it went through the
whole list.
Id like it to display each site after they are done. Anyone can tell me how
to do this?


Calling return stops the function and gives control back to the calling
function or script and the loop would stop so no you couldn't for
example return on one then carry on itterating through the list.

~Cameron
Jul 17 '05 #2
Yang Li Ke wrote:

I have this script which checks multiple domains for a link back to my site:

function backlinkCheck($siteurl, $recip) {
$arrText = @file($siteurl);
for ($i=0; $i<count($arrText); $i++) {
$text = $text . $arrText[$i];
}
if (eregi($recip, $text)) {
return true;
} else {
return false;
}
}

The problem is that It displays true or false only after it went through the
whole list.
Id like it to display each site after they are done. Anyone can tell me how
to do this?

--
Yang


This should work as long as $recip will always be on one line, which should be
the case if you're just looking for your domain.

function backlinkCheck($siteurl, $recip) {
$arrText = @file($siteurl);
foreach ($arrText as $text) {
if (eregi($recip, $text))
return true;
}
return false;
}

You also might want to look up foreach, join(), and the ".=" operator for the
future. They aren't needed here any more, but could have made your code a bit
more efficient/readable. You might also want to add some error handling (try
entering a bogus url and see what happens).

Regards,
Shawn
--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com
Jul 17 '05 #3
ok but in my main page I call this function like this

while($line = mysql_fetch_object(db_list_of_sites)){
echo backlinkCheck($line->url, $mysite->url);
}

so the problem is that it doesnt echo the result after each
site. it echo the results only at end when the whole while
is done !

Thanx for you help.
--
Yang

"Cameron" <fo*@bar.invalid> wrote in message
news:bv**********@news5.svr.pol.co.uk...
Yang Li Ke wrote:
I have this script which checks multiple domains for a link back to my site:
function backlinkCheck($siteurl, $recip) {
$arrText = @file($siteurl);
for ($i=0; $i<count($arrText); $i++) {
$text = $text . $arrText[$i];
}
if (eregi($recip, $text)) {
return true;
} else {
return false;
}
}

The problem is that It displays true or false only after it went through the whole list.
Id like it to display each site after they are done. Anyone can tell me how to do this?


Calling return stops the function and gives control back to the calling
function or script and the loop would stop so no you couldn't for
example return on one then carry on itterating through the list.

~Cameron

Jul 17 '05 #4
Yang Li Ke wrote:

ok but in my main page I call this function like this

while($line = mysql_fetch_object(db_list_of_sites)){
echo backlinkCheck($line->url, $mysite->url);
}

so the problem is that it doesnt echo the result after each
site. it echo the results only at end when the whole while
is done !


You should probably have a "$" on db_list_of_sites. This should have produced
an error - I'd suggest turning on error_reporting() if you didn't see it. It
can really help to debug.
while($line = mysql_fetch_object($db_list_of_sites)){
echo backlinkCheck($line->url, $mysite->url);
}

Regards,
Shawn
--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com
Jul 17 '05 #5
You need to 'flush' the output to the browser after each iteration,
check out the following example for some ideas. The usleep call is
there so that you have enough of a delay between each 'flush' to see
the example work.
for( $i=0; $i<100; $i++ ) {
echo $i;
flush();
ob_flush();
usleep(50000);
}
Jul 17 '05 #6
Thanx a lot!

Thats exactly what i was looking for!

--
"Josh Lopez" <jo********@cox.net> wrote in message
news:1d**************************@posting.google.c om...
You need to 'flush' the output to the browser after each iteration,
check out the following example for some ideas. The usleep call is
there so that you have enough of a delay between each 'flush' to see
the example work.
for( $i=0; $i<100; $i++ ) {
echo $i;
flush();
ob_flush();
usleep(50000);
}

Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Agency | last post by:
I'm still working on the bpm counter. I need to have at least 2 displays that are not static. One would be a clock/running time and the other would should the current beat count. How would I...
5
by: David Greenwood | last post by:
I posted this under 'microsoft.public.sqlserver.client' but got no reply. Any help with this problem would be greatly appreciated --------------------- I developed a database under SQL Server...
13
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
3
by: shreddie | last post by:
Could anyone assist with the following problem? I'm using JavaScript to hide/show table rows depending on the option selected in radio buttons. The script works fine in IE but in Firefox the...
2
by: s.chelliah | last post by:
We have an input field which allows the user to enter a string of (up to 62) ASCII printable characters. We have a need to allow the user to be able to specify any sequence of characters he/she...
2
by: ruby_bestcoder | last post by:
Hi Im having problem in firefox with display:none/block. I have essentially 3 li elements. In each element there are a few nested div:s. Clicking on one of the divs, makes another div to...
7
by: Janis | last post by:
I try to understand what could be the source of a problem with displaying and hiding rows of tables using display:block/none. I've read selfhtml but could not find any hint about that. Any...
15
by: cssExp | last post by:
hello, Rather than going on a wild explanation on what's the the problem, it'll be much quicker and easier if i let you look at it yourself, so I'll post my page source (actual contents taken out,...
10
by: dkyadav80 | last post by:
<html> /// here what shoud be java script for: ->when script run then not display all input text field only display selection field. ->when user select other value for institute only this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.