TEENFRONT Posted October 7, 2006 Share Posted October 7, 2006 Heyi have a mail script ( standard mail() ) it sends to a few hundred members ( not spam ) I loop through each row grabbing useremail and mailing it.I tried echoing $email Sent <br /> for each loop.. but it just loaded the page in one big go...how to i get it to echo something each time a row has been looped and the mail has been sent? Cheers! Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 7, 2006 Share Posted October 7, 2006 i dont know if it is possable to count throw the loop while processing i looked it up on google no luck.It's very intreasting quistion.mysql_num_rows only shows the current count for all so how do you count the processing of the loop? for example the user wants to count and echo the emails that are passing throw the loop but i dont seem to have any information on counting the process of the loop as it loops? Quote Link to comment Share on other sites More sharing options...
tleisher Posted October 7, 2006 Share Posted October 7, 2006 You can do it with Javascript and the DOM, it's not something that PHP can do it on it's own... PHP is a preprocessing language (IE: It processes before the server is finished)You could add a javascript line to your code that calls a function, say, email()... then it might look like this:[code]function email(email, username){ var myVar = document.getElementById("email"); var txt = document.createTextNode("Successfully emailed " + username + " at the email " + email + "!"); myVar.appendChild(txt);}[/code]Then have:<div id="email"></div> in your HTML and it should show up there. I'm somewhat new to javascript, but if you look up Javascript, the DOM, and appendChild() you'll find what you need.Lastly in you're PHP code just call the function, giving it the username and email in your while loop.. so at the end of the loop after the email has been sent do the following:echo "email(".$email.",".$username.");";that should call email(email, username); and start the function. Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 7, 2006 Share Posted October 7, 2006 lets get this stright becouse php is processing the information of the loop then that information can only bee seen with javasript as the loop is now only viewable client side?thanks. Quote Link to comment Share on other sites More sharing options...
tleisher Posted October 7, 2006 Share Posted October 7, 2006 Hmm, you know that might not even work because the entire while loop will be finished by the time the page loads, so you wont see things appear on screen you'll just see them on there already. The only way to do this may be through AJAX. Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 7, 2006 Share Posted October 7, 2006 it will work with javascript but i think you might have to use sleep() also. Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 7, 2006 Share Posted October 7, 2006 the code i am provideing will only count the submitting emails but works grate.sorry your have to alter the code as you need it but a good start.ok got it all going good luck.you have to copy and past from the link ok.The forum didnt let me post it here ok.http://freesingles.ath.cx/email.incany comments welcomed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.