Jump to content

Recommended Posts

thank you in advance.

 

these codes below took tooooo long to load,

		<?php
		//0000-00-00 00:00:00
		//Fill invited_by column in USERS table.
		include 'opendb.php';


		//get all unique invited_by
			$query = "SELECT DISTINCT invited_by FROM users WHERE invited_by!='' ORDER BY invited_by ASC";
			$result=mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error());

			$i=0;
			while($row = mysql_fetch_array($result)) {
				$referer[$i] = $row['invited_by'];		
				#echo "<b>referer: </b>". $referer[$i];
				#echo "<br>";
				$i++;
			}

			if(!empty($referer)) {
				$i=0;
				$j++;
				$c=count($referer);
				while($i<$c) {
					$query = "SELECT * FROM users WHERE user_name='$referer[$j]' ORDER BY user_name ASC";
					$result=mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error());

					$i=0;
					while($row = mysql_fetch_array($result)) {
						$user_name = $row['user_name'];		
						$email = $row['email'];		
						echo "{$user_name} ". $email;
						echo "\n";
						$i++;
					}
				$j++;
				}
			}

		include 'closedb.php';
		?>

 

 

can you tell me what's causing the problem?

 

note: i tested the other codes and it works fine, the mere problem is the codes above.

 

thank you.

 

Link to comment
https://forums.phpfreaks.com/topic/136049-took-tooooooo-long-to-load/
Share on other sites

why not like this mate.....

 

        <?php
       
         include 'opendb.php';
         
            $query2 = "SELECT DISTINCT invited_by FROM users WHERE invited_by!='' ORDER BY invited_by ASC";
            $result2=mysql_query($query2) or die("Problem with the query: $query2 on line " . __LINE__ . '<br>' . mysql_error());
             
            while($row2 = mysql_fetch_assoc($result2)) {
         
            $query3 = "SELECT * FROM users WHERE user_name='".$row2['invited_by']."' ORDER BY user_name ASC";
            $result3=mysql_query($query3) or die("Problem with the query: $query3 on line " . __LINE__ . '<br>' . mysql_error());
            
            
            while($row = mysql_fetch_assoc($result3)) {
              
                     $user_name = $row['user_name'];      
                     $email = $row['email'];      
                     echo "{$user_name} ". $email;
                     echo "\n";
                     
            }   
             }
         
         include 'closedb.php';
         ?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.