Page 1 of 1

get the value of hyperlink and display details

Posted: Sun Jan 09, 2011 11:05 pm
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

Re: get the value of hyperlink and display details

Posted: Mon Jan 10, 2011 12:56 am
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.

Re: get the value of hyperlink and display details

Posted: Mon Jan 10, 2011 1:53 am
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

Re: get the value of hyperlink and display details

Posted: Mon Jan 10, 2011 1:54 am
by Benjamin
:arrow: Use

Code: Select all

 tags when posting code in the forums.

Re: get the value of hyperlink and display details

Posted: Mon Jan 10, 2011 2:48 am
by ravikishore
And how to pass the employee id to another form to view the particular employee details

Re: get the value of hyperlink and display details

Posted: Mon Jan 10, 2011 3:26 am
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.

Re: get the value of hyperlink and display details

Posted: Mon Jan 10, 2011 4:20 am
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'

Re: get the value of hyperlink and display details

Posted: Mon Jan 10, 2011 4:42 am
by ravikishore
Thanks alot... I figured it out....It helped me alot