Jump to content

generate the link


nrsh_ram

Recommended Posts

if my coding is like this...how to do the link?

<?php
require_once('include/session.php');
require_once('include/user_auth_fns.php');
require_once('include/db_fns.php');

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

$aa=0;
$query = "SELECT mm.mentee, mm.username_mentee, mp.major ".
"FROM mentormentee mm LEFT JOIN mentee_personal_details mp ".
   "ON mp.mentee_id = mm.username_mentee ".
        "WHERE mm.username_mentor = '$cur_login' AND mp.mentee_id = mm.username_mentee";   


  $result = $conn->query($query); 
  
?>

 

 

<?php
  
		while ($row = mysqli_fetch_assoc($result)){ 
		$aa = $aa + 1;
		?>
        <td><?php echo $aa ?> </td>
        <td><?php echo $row['mentee']; ?> </td>
        <td><?php echo $row['username_mentee']; ?> </td>
        <td><?php echo $row['major']; ?> </td>
      </tr><?php }?>

Link to comment
Share on other sites

i do like this.

<td><a href="view_profile.php?mentee=<?php echo $row['mentee']; ?>"><?php echo $row['mentee']; ?></a> </td>

 

view_profile.php what shall i do?

like this?

$result = mysql_query("SELECT * FROM mentee_personal_details where mentee_id = $row['mentee']");

Link to comment
Share on other sites

all.php

 
<?php
require_once('include/session.php');
require_once('include/user_auth_fns.php');
require_once('include/db_fns.php');

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

$aa=0;
$query = "SELECT mm.mentee, mm.username_mentee, mp.major ".
"FROM mentormentee mm LEFT JOIN mentee_personal_details mp ".
   "ON mp.mentee_id = mm.username_mentee ".
        "WHERE mm.username_mentor = '$cur_login' AND mp.mentee_id = mm.username_mentee";   


  $result = $conn->query($query); 
  
?>



<?php
  
		while ($row = mysqli_fetch_assoc($result)){ 
		$aa = $aa + 1;
		?>
        <td><?php echo $aa ?> </td>
        <td><a href="view_profile.php?mentee=<?php echo $row['mentee']; ?>"><?php echo $row['mentee']; ?></a> </td>
        <td><?php echo $row['username_mentee']; ?> </td>
        <td><?php echo $row['major']; ?> </td>
      </tr><?php }?>

 

 

 

view_profile.php

<?php
require_once('include/session.php');
require_once('include/user_auth_fns.php');
require_once('include/db_fns.php');

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

$aa=0;
$query = "SELECT mm.mentee, mm.username_mentee, mp.major ".
"FROM mentormentee mm LEFT JOIN mentee_personal_details mp ".
   "ON mp.mentee_id = mm.username_mentee ". 
        "WHERE mm.username_mentor = '$cur_login' AND mp.mentee_id = mm.username_mentee";   
$result = $conn->query($query);

  $row = mysqli_fetch_assoc($result);{
   $m_mentee = $row['mentee'];
  }
  
  $query1 = "SELECT * FROM mentee_personal_details where mentee_id = '$m_mentee'";
   $result1 = $conn->query($query1);
   
$row = mysqli_fetch_assoc($result1);{
            $mentee_id            =  $row["mentee_id"]; 
		 $s_fullname           =  $row["fullname"];
		$s_postal_address1    = $row["postal_address1"];
		$s_postal_address2	  = $row["postal_address2"];
            $s_postal_address3	  = $row["postal_address3"];
            $s_postal_zip 		  = $row["postal_zip"];
            $s_post_telephone 	  = $row["post_telephone"];
            $s_degree 			  = $row["degree"];
		$s_major              = $row["major"];
            $s_race 			  = $row["race"];
            $s_marital_status 	  = $row["marital_status"];
		$s_hobbies            = $row["hobbies"];
            $s_permanent_address1 = $row["permanent_address1"];
            $s_permanent_address2 = $row["permanent_address2"];
            $s_permanent_address3 = $row["permanent_address3"];
            $s_per_zip 			  = $row["per_zip"];
            $s_per_telephone	  = $row["per_telephone"];	

  } 
?>

 

<td><?php echo $mentee_id; ?><font face="Verdana" size="2"> </font></td>

 

no errors but, the mentee_id its read "0"...wrong output..

plz help me

Link to comment
Share on other sites

You need to grab the value from the URL.  Right now you're using the value from the first query rather than he one he clicked on.  Add this line here:

 

$m_mentee = $_GET['mentee'];
$query1 = "SELECT * FROM mentee_personal_details where mentee_id = '$m_mentee'";
$result1 = $conn->query($query1);

 

Also, this piece of code is wrong...

 

  $row = mysqli_fetch_assoc($result);{
   $m_mentee = $row['mentee'];
  }

 

should be:

 

$row = mysqli_fetch_assoc($result);
$m_mentee = $row['mentee'];

Link to comment
Share on other sites

i changed is as u said.....

 

no errors, but the output is wrong...

here i post the whole view_profile.php

<?php
require_once('include/session.php');
require_once('include/user_auth_fns.php');
require_once('include/db_fns.php');

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

$aa=0;
$query = "SELECT mm.mentee, mm.username_mentee, mp.major ".
"FROM mentormentee mm LEFT JOIN mentee_personal_details mp ".
   "ON mp.mentee_id = mm.username_mentee ". 
        "WHERE mm.username_mentor = '$cur_login' AND mp.mentee_id = mm.username_mentee";   
$result = $conn->query($query);

$row = mysqli_fetch_assoc($result);
$m_mentee = $row['mentee'];

$m_mentee = $_GET['mentee'];

$query1 = "SELECT * FROM mentee_personal_details where mentee_id = '$m_mentee'";
$result1 = $conn->query($query1);

   
$row1 = mysqli_fetch_assoc($result1);{
            $mentee_id            = $row1["mentee_id"]; 
 $s_fullname           =  $row1["fullname"];
$s_postal_address1    = $row1["postal_address1"];
$s_postal_address2	  = $row1["postal_address2"];
        $s_postal_address3	  = $row1["postal_address3"];
        $s_postal_zip 		  = $row1["postal_zip"];
         $s_post_telephone 	  = $row1["post_telephone"];
         $s_degree 			  = $row1["degree"];
$s_major              = $row1["major"];
          $s_race 			  = $row1["race"];
          $s_marital_status 	  = $row1["marital_status"];
$s_hobbies            = $row1["hobbies"];
            $s_permanent_address1 = $row1["permanent_address1"];
            $s_permanent_address2 = $row1["permanent_address2"];
            $s_permanent_address3 = $row1["permanent_address3"];
            $s_per_zip 			  = $row1["per_zip"];
            $s_per_telephone	  = $row1["per_telephone"];	

  } 
?>


                  <td width="142" align="left"><font class="label" face="Verdana" 
      size="2">Student ID </font></td>
                  <td><font class="label" face="Verdana" size="2">:</font></td>
                  <td><?php echo  $mentee_id;  ?><font face="Verdana" size="2"> </font></td>
                  <td > </td>
                  <td> </td>
                  <td> </td>
                </tr>
                <tr valign="top">
                  <td height="26" align="left" ><font class="label" face="Verdana" 
      size="2"><span class="style3">*</span></font></td>
                  <td height="26" align="left" ><font class="label" face="Verdana" 
      size="2">Name</font></td>
                  <td width="8"><font class="label" face="Verdana" size="2">:</font></td>
                  <td width="298"><?php echo $fullname; ?><font face="Verdana" size="2"></font></td>
                  <td align="left" width="151"> </td>
                  <td width="7"> </td>
                  <td width="273"> </td>
                </tr>
                <tr valign="top">
                  <td height="24" align="left"><font face="Verdana" size="2"><font 
      class="label"><span class="style3">*</span></font></font></td>
                  <td height="24" align="left"><font face="Verdana" size="2"><font 
      class="label">Postal address</font></font></td>
                  <td><font face="Verdana" size="2">:</font></td>
                  <td><?php echo $row['postal_address1']; ?> </td>
                  <td align="left"><font face="Verdana" size="2"><font 
      class="label">Permanent address</font></font></td>
                  <td><font class="label" face="Verdana" size="2">:</font></td>
                  <td><?php echo $s_permanent_address1; ?> </td>
                </tr>
                <tr valign="top">
                  <td height="24" colspan="2" align="left"> </td>
                  <td> </td>
                  <td><?php echo $s_postal_address2; ?> </td>
                  <td align="left"> </td>
                  <td> </td>
                  <td><?php echo $s_permanent_address2; ?> </td>
                </tr>
                <tr valign="top">
                  <td height="24" colspan="2" align="left"> </td>
                  <td> </td>
                  <td><?php echo $s_postal_address3; ?> </td>
                  <td align="left"> </td>
                  <td> </td>
                  <td><?php echo $s_permanent_address3; ?> </td>
                </tr>
                <tr valign="top">
                  <td height="26" align="left"><font face="Verdana" size="2"><font 
      class="label"><span class="style3">*</span></font></font></td>
                  <td height="26" align="left"><font face="Verdana" size="2"><font 
      class="label">Postcode</font></font></td>
                  <td><font face="Verdana" size="2">:</font></td>
                  <td><?php echo $s_postal_zip; ?> </td>
                  <td align="left"><font face="Verdana" size="2"><font 
      class="label">Postcode</font></font></td>
                  <td><font class="label" face="Verdana" size="2">:</font></td>
                  <td><?php echo $s_per_zip; ?> </td>
                </tr>
                <tr valign="top">
                  <td height="26" align="left"><font face="Verdana" size="2"><font 
      class="label"><span class="style3">*</span></font></font></td>
                  <td height="26" align="left"><font face="Verdana" size="2"><font 
      class="label">Telephone</font></font></td>
                  <td> </td>
                  <td><?php echo $s_post_telephone; ?><font face="Verdana" size="2"> </font></td>
                  <td align="left"><font face="Verdana" size="2"><font 
      class="label">Telephone</font></font></td>
                  <td><font class="label" face="Verdana" size="2">:</font></td>
                  <td><?php echo $s_per_telephone; ?> </td>
                </tr>
                <tr valign="top">
                  <td height="26" align="left"> </td>
                  <td height="26" align="left"><font face="Verdana" size="2"><font 
      class="label">Degree</font></font></td>
                  <td><font class="label" face="Verdana" size="2">:</font></td>
                  <td><?php echo $s_degree; ?> </td>
                  <td align="left"> </td>
                  <td> </td>
                  <td> </td>
                </tr>
                <tr valign="top">
                  <td height="26" align="left"> </td>
                  <td height="26" align="left"><font face="Verdana" size="2"><font 
      class="label">Major</font></font></td>
                  <td><font class="label" face="Verdana" size="2">:</font></td>
                  <td><?php echo $s_major; ?> </td>
                  <td align="left"> </td>
                  <td> </td>
                  <td> </td>
                </tr>
                <tr valign="top">
                  <td height="26" align="left"> </td>
                  <td height="26" align="left"><font face="Verdana" size="2"><font 
      class="label">Race</font></font></td>
                  <td><font class="label" face="Verdana" size="2">:</font></td>
                  <td><font face="Verdana">
			  
			  <!--<select name="department" id="department">
            <option selected><?php echo $row["department"]; ?></option>
            <option>ISC</option>
            <option>MSG</option>
            <option>ENT</option>
        </select>-->
	<option selected><?php echo $s_race; ?></option>
                    <!--<select name="race" class="selectbox10" id="race">
                  
                      <option value="MALAY">MALAY</option>
                      <option value="CHINESE">CHINESE</option>
                      <option value="INDIAN">INDIAN</option>
                      <option value="BUMIPUTRA SABAH">BUMIPUTRA SABAH</option>
                      <option value="BUMIPUTRA SARAWAK">BUMIPUTRA SARAWAK</option>
                      <option value="OTHERS">OTHERS</option>
                    </select>-->
                  </font><font face="Verdana" 
      size="2"> </font></td>
                  <td align="left"> </td>
                  <td> </td>
                  <td> </td>
                </tr>
                <tr valign="top">
                  <td height="26" align="left"> </td>
                  <td height="26" align="left"><font face="Verdana" size="2"><font 
      class="label">Marital status</font></font></td>
                  <td><font face="Verdana" size="2">:</font></td>
                  <td><font face="Verdana">
			  <option selected><?php echo $s_marital_status; ?></option>
                    <!--<select name="marital_status" class="selectbox11" id="marital_status">
                      <option value="Single" selected="selected">Single</option>
                      <option value="Married">Married</option>
                    </select>-->
                  </font><font face="Verdana" 
      size="2"> </font></td>
                  <td align="left"> </td>
                  <td> </td>
                  <td> </td>
                </tr>
                <tr valign="top">
                  <td height="26" align="left"> </td>
                  <td height="26" align="left"><font face="Verdana" size="2"><font 
      class="label">Hobbies</font></font></td>
                  <td><font face="Verdana" size="2">:</font></td>
                  <td><?php echo $s_hobbies; ?> </td>
                  <td align="left"> </td>
                  <td> </td>
                  <td> </td>
                </tr>
            </table></td>
        </tr>
      </table>
      </div>
      
    </form>


Link to comment
Share on other sites

 

 

When you click on this link from your "all.php" do the correct variables get set in your URL?

 

You can also echo $query1  to make sure it's asking for the right info.  Other than that it looks good, unless I'm missing something...

Link to comment
Share on other sites

i have check the query and database, have problem there.

 

all.php

<?php
require_once('include/session.php');
require_once('include/user_auth_fns.php');
require_once('include/db_fns.php');

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

$aa=0;
$query = "SELECT mm.mentee, mm.username_mentee, mp.major ".
"FROM mentormentee mm LEFT JOIN mentee_personal_details mp ".
   "ON mp.mentee_id = mm.username_mentee ".
        "WHERE mm.username_mentor = '$cur_login' AND mp.mentee_id = mm.username_mentee";   


  $result = $conn->query($query); 
  
?>


<?php
  
		while ($row = mysqli_fetch_assoc($result)){ 
		$aa = $aa + 1;
		?>
        <td><?php echo $aa ?> </td>
        <td><a href="view_profile.php?mentee=<?php echo $row['mentee']; ?>"><?php echo $row['mentee']; ?></a> </td>
        <td><?php echo $row['username_mentee']; ?> </td>
        <td><?php echo $row['major']; ?> </td>
      </tr><?php }?>

 

 

view_profile.php

<?php
require_once('include/session.php');
require_once('include/user_auth_fns.php');
require_once('include/db_fns.php');

$cur_login = $_SESSION["username"];
$conn= db_connect();
$m_mentee =  $_GET['mentee'];

$query1 = "SELECT * FROM mentee_personal_details where mentee_id = '$m_mentee'";
echo $query1;
$result1 = $conn->query($query1);
/*  $query1 = "SELECT * FROM mentee_personal_details where mentee_id = '$m_mentee'";
   $result1 = $conn->query($query1); */
   
$row1 = mysqli_fetch_assoc($result1);{
            $mentee_id            =  $row1["mentee_id"]; 
		 $s_fullname           =  $row1["fullname"];
		$s_postal_address1    = $row1["postal_address1"];
		$s_postal_address2	  = $row1["postal_address2"];
            $s_postal_address3	  = $row1["postal_address3"];
            $s_postal_zip 		  = $row1["postal_zip"];
            $s_post_telephone 	  = $row1["post_telephone"];
            $s_degree 			  = $row1["degree"];
		$s_major              = $row1["major"];
            $s_race 			  = $row1["race"];
            $s_marital_status 	  = $row1["marital_status"];
		$s_hobbies            = $row1["hobbies"];
            $s_permanent_address1 = $row1["permanent_address1"];
            $s_permanent_address2 = $row1["permanent_address2"];
            $s_permanent_address3 = $row1["permanent_address3"];
            $s_per_zip 			  = $row1["per_zip"];
            $s_per_telephone	  = $row1["per_telephone"];	

  } 


?>
<td><?php echo  $mentee_id;   ?><font face="Verdana" size="2"> </font></td>

 

here in my database, for each mentee have mentee_id, where username_mentee == mentee_id

now in my query i have call the mentee, and get mentee.

actually i want mentee_id=username_mentee

 

what shall i do?

where i have to change it?

 

plz guide me...

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.