nrsh_ram Posted February 4, 2009 Share Posted February 4, 2009 hi to all... i want knw, lets say my sytem show all name of mentees..can i put the link to each mentee? Quote Link to comment https://forums.phpfreaks.com/topic/143830-generate-the-link/ Share on other sites More sharing options...
Maq Posted February 4, 2009 Share Posted February 4, 2009 Need more detail like: Where does the mentee come from? What are you trying to do? Here's a skeleton: $mentee = "mentee001" ?> Mentee: Quote Link to comment https://forums.phpfreaks.com/topic/143830-generate-the-link/#findComment-754673 Share on other sites More sharing options...
nrsh_ram Posted February 4, 2009 Author Share Posted February 4, 2009 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 }?> Quote Link to comment https://forums.phpfreaks.com/topic/143830-generate-the-link/#findComment-754696 Share on other sites More sharing options...
trq Posted February 4, 2009 Share Posted February 4, 2009 Where exactly do you want the link to point too? <td><a href="#"><?php echo $row['mentee']; ?></a> </td> Quote Link to comment https://forums.phpfreaks.com/topic/143830-generate-the-link/#findComment-754713 Share on other sites More sharing options...
nrsh_ram Posted February 4, 2009 Author Share Posted February 4, 2009 i want when we click on mentee name its open theirs profile... Quote Link to comment https://forums.phpfreaks.com/topic/143830-generate-the-link/#findComment-754722 Share on other sites More sharing options...
trq Posted February 4, 2009 Share Posted February 4, 2009 Then your link might look like.... <td><a href="profile.php?mentee=<?php echo $row['mentee']; ?>"><?php echo $row['mentee']; ?></a> </td> From there you need to create profile.php to handle the profile page. Quote Link to comment https://forums.phpfreaks.com/topic/143830-generate-the-link/#findComment-754728 Share on other sites More sharing options...
nrsh_ram Posted February 5, 2009 Author Share Posted February 5, 2009 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']"); Quote Link to comment https://forums.phpfreaks.com/topic/143830-generate-the-link/#findComment-755070 Share on other sites More sharing options...
nrsh_ram Posted February 5, 2009 Author Share Posted February 5, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/143830-generate-the-link/#findComment-755081 Share on other sites More sharing options...
Maq Posted February 5, 2009 Share Posted February 5, 2009 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']; Quote Link to comment https://forums.phpfreaks.com/topic/143830-generate-the-link/#findComment-755203 Share on other sites More sharing options...
nrsh_ram Posted February 5, 2009 Author Share Posted February 5, 2009 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> Quote Link to comment https://forums.phpfreaks.com/topic/143830-generate-the-link/#findComment-755303 Share on other sites More sharing options...
Maq Posted February 5, 2009 Share Posted February 5, 2009 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... Quote Link to comment https://forums.phpfreaks.com/topic/143830-generate-the-link/#findComment-755316 Share on other sites More sharing options...
nrsh_ram Posted February 5, 2009 Author Share Posted February 5, 2009 where to i put echo query1? Quote Link to comment https://forums.phpfreaks.com/topic/143830-generate-the-link/#findComment-755345 Share on other sites More sharing options...
Maq Posted February 5, 2009 Share Posted February 5, 2009 $query1 = "SELECT * FROM mentee_personal_details where mentee_id = '$m_mentee'"; echo $query1; $result1 = $conn->query($query1); Quote Link to comment https://forums.phpfreaks.com/topic/143830-generate-the-link/#findComment-755371 Share on other sites More sharing options...
nrsh_ram Posted February 5, 2009 Author Share Posted February 5, 2009 when i run it, its show the select mentee name like this: SELECT * FROM mentee_personal_details where mentee_id = 'siti' but its still return "0" and wrong output.. its not the correct mentee_id. plz guide me, where i have to change? Quote Link to comment https://forums.phpfreaks.com/topic/143830-generate-the-link/#findComment-755425 Share on other sites More sharing options...
nrsh_ram Posted February 6, 2009 Author Share Posted February 6, 2009 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... Quote Link to comment https://forums.phpfreaks.com/topic/143830-generate-the-link/#findComment-755736 Share on other sites More sharing options...
Maq Posted February 6, 2009 Share Posted February 6, 2009 actually i want mentee_id=username_mentee That's what you have (although, mentee_id equaling the username is weird...): SELECT * FROM mentee_personal_details where mentee_id = 'siti' Quote Link to comment https://forums.phpfreaks.com/topic/143830-generate-the-link/#findComment-755947 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.