get the value of hyperlink and display details

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ravikishore
Forum Newbie
Posts: 7
Joined: Sun Jan 09, 2011 10:59 pm

get the value of hyperlink and display details

Post by ravikishore »

iam displaying list of details of employees from database... which displays limited data on the first page. I have created a hyperlink to the employee name. when user clicks on the particular employee name, it will displays all the details of the corresponding employee... Kindly know me how to figure this out. Below is the code wat i have done.Kindly suggest.

Code: Select all

<?php
									$user_name = "root";
									$pass_word = "";
									$database = "testbase";
									$server = "localhost";

									$db_handle = mysql_connect($server, $user_name, $pass_word,$database);
									$db_found = mysql_select_db($database, $db_handle);

									 $SQL = "select * from expenses";

									 $result = mysql_query($SQL);
									?>
									
									<?php
									for ($j=0; $j<count($result);$j++) {
										$db_field=$result[$j][1];
									$cssClass = ($j%2) ? 'even' : 'odd'; ?>

								<?php
									 while ($db_field = mysql_fetch_assoc($result)) 
									 {
										 ?>
										 <tr class="<?php echo $cssClass;?>" >
										 <td class="center">
										
										 </td>
										 <td align="center" >
										 <?php echo $db_field['fromloc'] ?>
										 </td>
										 <td align="center">
										 <a href="http://www.google.com"><?php  echo $db_field['toloc'] ?></a>
										 </td>
										 <td align="center">
										 <?php echo $db_field['travelmode'] ?>
										 </td>
										 <td align="center">
										 <?php echo $db_field['travelstartdate'] ?>
										 </td>
										 <td align="center">
										 <?php echo $db_field['travelenddate'] ?>
										 </td>
										 <td align="center">
										 <?php echo $db_field['costcenter'] ?>
										 </td>
										 <td align="center">
										 <?php echo $db_field['project'] ?>
										 </td>
										 <td align="center">
										 <?php echo $db_field['purpose']?>
										 </td>
										 <td align="center">
										 <?php echo $db_field['currency'] ?>
										 </td>
										 <!-- <td align="center">
										 <?php echo $db_field['paymenttype']?>
										 </td> -->
										 <td align="center">
										 <?php echo $db_field['advancerequirement']?>
										 </td>
										 </tr>
									  
							<?php
Last edited by Benjamin on Sun Jan 09, 2011 11:59 pm, edited 1 time in total.
Reason: Added [syntax=php] tags.
ravikishore
Forum Newbie
Posts: 7
Joined: Sun Jan 09, 2011 10:59 pm

Re: get the value of hyperlink and display details

Post by ravikishore »

yes, we are developing employee expenses application. we will be having 2 forms. first form displays all the employees expense requests(this will show only few details i.e., employee id, employee name, expense amount etc.). when the approver clicks on the particular employee name (hyperlink will be activated to employee names) it opens a new form which shows complete details of the particular employee. All the data is being retrieved from the database.
So, on clicking on particular employee name, how to retrieve the complete details of the particular employee in another form??
kindly let me know.
ravikishore
Forum Newbie
Posts: 7
Joined: Sun Jan 09, 2011 10:59 pm

Re: get the value of hyperlink and display details

Post by ravikishore »

Can you explain me in detail how to pass employee id on clicking employee id. my code is as below. can you suggest me changes based on my code??

Code: Select all

<?php
                                                                        $user_name = "root";
                                                                        $pass_word = "";
                                                                        $database = "testbase";
                                                                        $server = "localhost";

                                                                        $db_handle = mysql_connect($server, $user_name, $pass_word,$database);
                                                                        $db_found = mysql_select_db($database, $db_handle);

                                                                         $SQL = "select * from expenses";

                                                                         $result = mysql_query($SQL);
                                                                        ?>
                                                                       
                                                                        <?php
                                                                        for ($j=0; $j<count($result);$j++) {
                                                                                $db_field=$result[$j][1];
                                                                        $cssClass = ($j%2) ? 'even' : 'odd'; ?>

                                                                <?php
                                                                         while ($db_field = mysql_fetch_assoc($result))
                                                                         {
                                                                                 ?>
                                                                                 <tr class="<?php echo $cssClass;?>" >
                                                                                 <td class="center">
                                                                               
                                                                                 </td>
                                                                                 <td align="center" >
                                                                                 <?php echo $db_field['fromloc'] ?>
                                                                                 </td>
                                                                                 <td align="center">
                                                                                 <a href="http://www.google.com"><?php  echo $db_field['toloc'] ?></a>
                                                                                 </td>
                                                                                 <td align="center">
                                                                                 <?php echo $db_field['travelmode'] ?>
                                                                                 </td>
                                                                                 <td align="center">
                                                                                 <?php echo $db_field['travelstartdate'] ?>
                                                                                 </td>
                                                                                 <td align="center">
                                                                                 <?php echo $db_field['travelenddate'] ?>
                                                                                 </td>
                                                                                 <td align="center">
                                                                                 <?php echo $db_field['costcenter'] ?>
                                                                                 </td>
                                                                                 <td align="center">
                                                                                 <?php echo $db_field['project'] ?>
                                                                                 </td>
                                                                                 <td align="center">
                                                                                 <?php echo $db_field['purpose']?>
                                                                                 </td>
                                                                                 <td align="center">
                                                                                 <?php echo $db_field['currency'] ?>
                                                                                 </td>
                                                                                 <!-- <td align="center">
                                                                                 <?php echo $db_field['paymenttype']?>
                                                                                 </td> -->
                                                                                 <td align="center">
                                                                                 <?php echo $db_field['advancerequirement']?>
                                                                                 </td>
                                                                                 </tr>
                                                                         
                                                        <?php
Last edited by Benjamin on Mon Jan 10, 2011 1:54 am, edited 1 time in total.
Reason: Added [syntax=php] tags.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: get the value of hyperlink and display details

Post by Benjamin »

:arrow: Use

Code: Select all

 tags when posting code in the forums.
ravikishore
Forum Newbie
Posts: 7
Joined: Sun Jan 09, 2011 10:59 pm

Re: get the value of hyperlink and display details

Post by ravikishore »

And how to pass the employee id to another form to view the particular employee details
ravikishore
Forum Newbie
Posts: 7
Joined: Sun Jan 09, 2011 10:59 pm

Re: get the value of hyperlink and display details

Post by ravikishore »

iam even getting the employee id from the database. here, you have taken the employee id manually. But there will be huge list that will be displaying. so how to capture the particular employee id.
i have created the link to the employee name as below.

Code: Select all

<a href='empadvancerequestdetails.php'><?php echo $db_field['emp_firstname'] ?></a>
So For the above code, how can i pass the employee id, which i need to retrieve from the database.
Last edited by Benjamin on Mon Jan 10, 2011 3:43 am, edited 1 time in total.
Reason: Added [syntax=php] tags.
ravikishore
Forum Newbie
Posts: 7
Joined: Sun Jan 09, 2011 10:59 pm

Re: get the value of hyperlink and display details

Post by ravikishore »

On Clicking on the corresponding link, when employeedetails.php form opens, iam getting the below error.
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'
ravikishore
Forum Newbie
Posts: 7
Joined: Sun Jan 09, 2011 10:59 pm

Re: get the value of hyperlink and display details

Post by ravikishore »

Thanks alot... I figured it out....It helped me alot
Post Reply