Jump to content

[SOLVED] query for array? help me


nrsh_ram

Recommended Posts

good morning to all...

im newbie to php n mysql..

 

i have problem...in database under "mentor1" have 2mentees "mentee1 n mentee2"

so i want the system show the all mentee..

i have tried,but its only show mentee1 only, how to make it loop to show all mentee?

 

$cur_login = $_SESSION["username"];
$conn= db_connect();
$aa=0;	

$query = "select  mentee, username_mentee from mentormentee where username_mentor = '$cur_login'";
$result = $conn->query($query);

if($result->num_rows >0){ 
$row = mysqli_fetch_assoc($result);  

$m_mentee= $row["mentee"];
$m_username= $row["username_mentee"];

}

 

the table

<table width="567" border="0" align="center">
      <tr>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td width="109" bgcolor="#FFD9D9"><div align="center">No</div></td>
        <td width="111" bgcolor="#FFD9D9">Name</td>
        <td bgcolor="#FFD9D9" width="149"><div align="center">Id</div></td>
        <td bgcolor="#FFD9D9" width="182"><div align="center">Major</div></td>
      </tr>
      <tr>
  <?php
		while ($row = mysqli_fetch_assoc($result)){ 
		$aa = $aa + 1;
		?>	
		        <td><?php echo $aa; ?> </td>
        <td><?php echo $m_mentee; ?> </td>
        <td><?php echo $m_username; ?> </td>
        <td> </td>
      </tr><?php } ?>
    </table>

Link to comment
Share on other sites

* Not tested *

You don't need this stuff in the top PHP part:

 

if($result->num_rows >0){
$row = mysqli_fetch_assoc($result); 

$m_mentee= $row["mentee"];
$m_username= $row["username_mentee"];

}

 

and you should change this part to something like:

 

              while ($row = mysqli_fetch_assoc($result)){ 
         $aa += 1;
         ?>   
                  
         
         
         
      

Link to comment
Share on other sites

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.