Jump to content

Took tooooooo long to load.....?


ok

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';
         ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.