phillypro 03-11-2011, 12:53 AM <?php
while($row = mysql_fetch_array($result))
{
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => $theconkeys['conkey'],
'consumer_secret' => $theconkeys['consecret'],
'user_token' => $row['token'],
'user_secret' => $row['secret'],
));
}
?> how do i limit this while loop.... im lost
oesxyl 03-11-2011, 01:06 AM <?php
while($row = mysql_fetch_array($result))
{
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => $theconkeys['conkey'],
'consumer_secret' => $theconkeys['consecret'],
'user_token' => $row['token'],
'user_secret' => $row['secret'],
));
}
?> how do i limit this while loop.... im lost
what do you mean by 'limit'?
best regards
bullant 03-11-2011, 01:26 AM If you know how many iterations the while loop will go through, then another option is to use a FOR loop instead.
Otherwise, another option is to put a test condition inside the while loop and if it returns a specified value during an iteration, break out of the while loop.
oesxyl 03-11-2011, 01:33 AM If you know how many iterations the while loop will go through, then another option is to use a FOR loop instead.
Otherwise, another option is to put a test condition inside the while loop and if it returns a specified value during an iteration, break out of the while loop.
why to fetch a lot of data from mysql instead of use 'limit 1' in query? :)
btw, we don't realy know what op means by 'limit', maybe he/she want to limit data to some oauth secret/private keys or something else, :)
best regards
phillypro 03-11-2011, 01:59 AM Sorry i was so unclear fellas
basically
I have a database....full of names
i load all the rows of the table and define it as a variable
then i use the while loop to run commands on each table row ...till it reaches the end
what i want to do...is somehow work in a function where i can specify how many tables rows get loaded into the variable seems the more appropriate question
phillypro 03-11-2011, 02:03 AM <?php
require_once('inc/twitterOAuth.php');
require_once('inc/tmhOAuth.php');
require_once('connector.php');
$result = mysql_query("SELECT * FROM twitter");
$follow=$_POST['follow'];
echo '<b class="progress_title">In Progress </b><div class="results">'; ?>
<?php
while($row = mysql_fetch_array($result))
{
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => $theconkeys['conkey'],
'consumer_secret' => $theconkeys['consecret'],
'user_token' => $row['token'],
'user_secret' => $row['secret'],
));
echo '@'.$row['name'];
echo '<br />';
}
?>
<?php echo '</div>';
echo '<form method="post">
<input type="button" value="End Process"
onclick="window.close()">
</form>';
mysql_close($con);
?>
this is my current code
also...you think theres any way to time delay the loop?....add a couple seconds before it processes the next tabel row?
venegal 03-11-2011, 02:06 AM also...you think theres any way to time delay the loop?....add a couple seconds before it processes the next tabel row?
Wha? Why would you want to do *that*?
phillypro 03-11-2011, 02:10 AM because certain actions need 5 seconds or so inbetween to look realistic...you dont wanna flood something in milliseconds
bullant 03-11-2011, 02:11 AM why to fetch a lot of data from mysql instead of use 'limit 1' in query? :)
btw, we don't realy know what op means by 'limit', maybe he/she want to limit data to some oauth secret/private keys or something else, :)
best regards
yep, you answered your own question because we're not sure what the op means by limit.
I described some options and you offered an additional one :)
venegal 03-11-2011, 02:27 AM because certain actions need 5 seconds or so inbetween to look realistic...you dont wanna flood something in milliseconds
What do you mean, "look realistic"? This is PHP. Your browser won't see *any* output, before PHP has finished doing *everything*. So, if you were to introduce a 5 second delay for every row, all you would accomplish would be making the user wait forever before finally getting the page — all at once.
nobackseat88 03-11-2011, 03:10 AM What do you mean, "look realistic"? This is PHP. Your browser won't see *any* output, before PHP has finished doing *everything*. So, if you were to introduce a 5 second delay for every row, all you would accomplish would be making the user wait forever before finally getting the page — all at once.
Not quite... you can use sleep() to do the delay, but use flush() before each sleep() so that it instantly sends the output to the browser.
NBS
venegal 03-11-2011, 03:25 AM This is the wrong way to influence client side behaviour. Apart from the fact that the server side script shouldn't have to care about that sort of stuff, just read the manual entry for flush() to see what can all go wrong.
nobackseat88 03-11-2011, 09:35 PM This is the wrong way to influence client side behaviour. Apart from the fact that the server side script shouldn't have to care about that sort of stuff, just read the manual entry for flush() to see what can all go wrong.
As with any function, of course particular aspects of it can go wrong; I was simply pointing out a potential approach to use, at the original poster's discretion.
NBS
|
|