Jump to content

problem in changing data using onclick


newphpbees

Recommended Posts

Hi

 

I have a queries to display data in my template file, and i encountered problem in onclick EMP_ID

 

here is my query:

<?php
include 'config.php';

$currentEmpID = $_SESSION['empID'];

$sql = "SELECT  em.EMP_ID, s.EMP_NO, s.SSSLoan, s.SSSAmor FROM $PAYROLL.sssloan s, $ADODB_DB.employment em WHERE em.EMP_NO= s.EMP_NO AND em.EMP_ID = '$currentEmpID'";
$rsloan = $conn2->Execute($sql);
                                                    
$LOAN = trim($rsloan->fields['SSSLoan']);
$AMOR = trim($rsloan->fields['SSSAmor']);

$smarty->assign('LOAN', $LOAN);
$smarty->assign('AMOR', $AMOR);

$sql = "SELECT s.EMP_NO, p.EMP_ID, p.SSS, CONCAT(LNAME, ', ',  FNAME, ' ', MI, '.') AS FULLNAME, s.SSSLoan, s.SSSAmor, s.DATE_PROCESS FROM $ADODB_DB.PERSONAL p, $ADODB_DB.employment em, $PAYROLL.sssloan s WHERE s.EMP_NO = em.EMP_NO AND p.EMP_ID = '$currentEmpID' AND em.EMP_ID = '$currentEmpID'";

$rs = $conn2->GetAll($sql);

$smarty->assign('getsss', $rs); 
?>

 

and here is the template code:

// this data will change if the EMP_ID was click
<input type="text" name="LOAN" value="{$LOAN}" size="9"> 
<input type="text" name="AMOR" value="{$AMOR}" size="9">

{section name=att loop=$getsss} 
  <tr>
    <td colspan="4" style="background: #e2e2e2" readonly="readonly">{$getsss[att].SSS}</td>
    <td colspan="4" style="background: #e2e2e2" readonly="readonly" onclick="changeEmployee1('{$getsss[att].EMP_ID}')">{$getsss[att].EMP_NO}</td>
    <!--<td colspan="4" style="background: #e2e2e2" readonly="readonly"><a href="SSSgetdata.php?queryEmpID={$getsss[att].EMP_ID}">{$getsss[att].EMP_NO}</td>  -->
    <td colspan="15" style="background: #e2e2e2" readonly="readonly">{$getsss[att].FULLNAME}</td>   
    <td colspan="4" style="background: #e2e2e2" readonly="readonly">{$getsss[att].SSSLoan}</td>
    <td colspan="4" style="background: #e2e2e2" readonly="readonly">{$getsss[att].SSSAmor}</td>
    <td colspan="4" style="background: #e2e2e2" readonly="readonly">{$getsss[att].DATE_PROCESS}</td>
   
    
  </tr>
{sectionelse}   
  <tr><td colspan="1">No DATA</td></tr>
{/section} 

 

My problem is in onclick,the data loan and amor was not change when i click EMP_ID.

 

Thank you

Link to comment
Share on other sites

function changeEmployee1(queryID) {
//alert(queryID);
window.location = "SSSgetdata.php?queryEmpID=" + queryID;
}

 

<?php
session_start();

$queryStr = trim($_GET["queryEmpID"]);

$_SESSION['empID'] = $queryStr; 

session_write_close();
header("Location:SSSLoan.php");
exit();
?>

 

he gets the emp id...before it works but now that I change my query, it was not work..

 

Thank you

Link to comment
Share on other sites

I tried to check if the EMP_ID is has data.

 

{section name=att loop=$getsss} 
  <tr>
    <td colspan="4" style="background: #e2e2e2" readonly="readonly">{$getsss[att].SSS}</td>
    <td colspan="4" style="background: #e2e2e2" readonly="readonly" onclick="changeEmployee1('{$getsss[att].EMP_ID}')">{$getsss[att].EMP_NO}</td>
    <!--<td colspan="4" style="background: #e2e2e2" readonly="readonly"><a href="SSSgetdata.php?queryEmpID={$getsss[att].EMP_ID}">{$getsss[att].EMP_NO}</td>  -->
    <td colspan="15" style="background: #e2e2e2" readonly="readonly">{$getsss[att].FULLNAME}</td>   
    <td colspan="4" style="background: #e2e2e2" readonly="readonly">{$getsss[att].SSSLoan}</td>
    <td colspan="4" style="background: #e2e2e2" readonly="readonly">{$getsss[att].SSSAmor}</td>
    <td colspan="4" style="background: #e2e2e2" readonly="readonly">{$getsss[att].DATE_PROCESS}</td>
   
       
  {$getsss[att].EMP_ID}  
   
    
  </tr>
{sectionelse}   
  <tr><td colspan="1">No DATA</td></tr>
{/section}

As you can i try to displayed:

  {$getsss[att].EMP_ID} 

 

and i found out it produce 3 EMP_ID:

 

000009

000009

000009

 

because i have 3 data from that employee.. when i click one data from the list the EMP_ID still three :confused:

 

 

Thank you

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.