Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7417075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:37:38+00:00 2026-05-29T07:37:38+00:00

This would helps me a lot to understand how does loop works Let say

  • 0

This would helps me a lot to understand how does loop works

Let say i’ve database table my_table (id,words) and here is example of database

INSERT INTO `my_table` VALUES (1,'hello manal');
INSERT INTO `my_table` VALUES (2,'nice manal');
INSERT INTO `my_table` VALUES (3,'pretty manal');

now imagine for 100,000 entries (huge) and i want to replce the word manal to jack and giving me results every line changed one by one

i’ll use

$conn = mysql_connect('localhost','USER','PASS') or die(mysql_error());
mysql_select_db('my_table',$conn);

$sql = "SELECT * from my_table";
$result = mysql_query($sql,$conn);

while ($row = mysql_fetch_array($result)){

$old = $row['words'];
$id = $row['id'];

$new="jack";
$new = str_replace("manal", "$new", $old);
echo $new;

}

The loop
by that code it will works all at once which is impossible to my hosting server to apply all so i want to make it as loop ! i mean it will change the 1st database line then gives me the results echo $new; then change the 2nd database line then gives the results echo $new; and so on with no stop till last line.

so my important part is getting the results one by one ~thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:37:39+00:00Added an answer on May 29, 2026 at 7:37 am

    The problem will be that your output is being buffered which is why you see all the results at the same time (at the end of the execution of the script).

    You could add ob_flush(); flush(); within the loop before echo $new; an see if that helps. Regardless, the above example is going to execute pretty quickly so it isn’t exactly going to be easily readable!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Any help here would be greatly appreciated. I have this table hospital Nurse |
Please help this would be my last problem in dealing with access database with
I would appreciate any help on this issue. Lets say I want to load
I handle commands inside a RoutedCommand class that implements RoutedUICommand. This would help me
I have a problem finding references to this subject and would appreciate some help.
I am new to writing SQL and would greatly appreciate help on this problem.
i would like a simple help... i have a url like this: example.com/profile.php?id= &
I just cannot get this to work, would appreciate if someone can help. So
First, I would to thank everyone for all the help they provide via this
This would be a question for anyone who has code in the App_Code folder

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.