Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Posts
    713
    Thanks
    165
    Thanked 0 Times in 0 Posts

    Problem in a href location from php code to html code

    Good day!

    On my old code I mixed html and php code in <a href> now I need to separate my php code to html code.

    I don't know how can I get the id without using php in my <a href>

    this is my old code for the link of Edit and Delete
    PHP Code:
        <td><a href = 'edit.php?id=<?php echo $emp_id?>'>Edit</a> <a href='delete.php?id=<?php echo $emp_id?>' onClick="return confirm('Are you sure you want to delete?')">Delete</a></td>
    As you can see I used php code to echo the Emp_ID now i need to change into html code.

    this is my new machine1.php
    PHP Code:
    <?php
    error_reporting
    (E_ERROR E_WARNING E_PARSE);
    include(
    'includes/config.sender.php');
    include(
    'includes/template.inc');


    /*Sorting of Data*/
     
    $sort "ASC";
      
    $data_sort "Emp_ID";
      
      if(isset(
    $_GET['sorting']))
        {
            if(
    $_GET['sorting'] == 'ASC'){
                
    $sort "DESC";
            }
            else{
                
    $sort "ASC";
            }
        }
        
        
        if (isset(
    $_GET['field_name'])) {
            if(
    $_GET['field_name']  == 'Emp_ID'){
                
    $data_sort "Emp_ID";
            }
            elseif(
    $_GET['field_name'] == 'Last_Name'){
                
    $data_sort "Last_Name";
            }
            elseif(
    $_GET['field_name'] == 'First_Name'){
                
    $data_sort "First_Name";
            }
            elseif(
    $_GET['field_name'] == 'Birthday'){
                
    $data_sort "Birthday";
            }
        }


        
        
    /*Pagination, Sorting and Limit*/

    if (isset($_GET['pageno'])) {
       
    $pageno $_GET['pageno'];
    } else {
       
    $pageno 1;



    $sql_select "SELECT COUNT(*) as numrows 
                    FROM  
                        machine_problem_rhoda"

    $result $_DB->opendb($sql_select); 

    if(isset(
    $result[0]['numrows'])) //check if result returned a numrows
    {
       
    $numrows = (int)$result[0]['numrows'];     //typecast, to clearify the value range.
    }
    else
    {
       
    $numrows 0;//or false - 
    }


    $rows_per_page 5;
    $lastpage      ceil($numrows/$rows_per_page);

    $pageno = (int)$pageno;
    if (
    $pageno $lastpage) {
       
    $pageno $lastpage;

    if (
    $pageno 1) {
       
    $pageno 1;


    $limit 'LIMIT ' .($pageno 1) * $rows_per_page .',' .$rows_per_page;



    $sql_select "SELECT
                        Emp_ID,
                        Last_Name,
                        First_Name,
                        Birthday
                    FROM
                        machine_problem_rhoda
                    ORDER BY $data_sort $sort $limit
                    "
    ;
    $rows $_DB->opendb($sql_select);

    $tpl = new Template('.''keep');
    $tpl->set_file(array('handle' => 'html/machine1.html'));

    $tpl->set_block('handle''block_list''tag_list');
    foreach(
    $rows as $row) {
        
    $tpl->set_var(array('id'=> $row['Emp_ID'],
                            
    'lastname' => $row['Last_Name'],
                            
    'firstname' => $row['First_Name'],
                            
    'birthday' => $row['Birthday'],
                            
    'sorting' => $sort
        
    ));
        
    $tpl->parse('tag_list''block_list'true);
    }

    $tpl->parse('handle', array('handle'));
    $tpl->p('handle');
    ?>
        
    <?php

     
    if(isset($_GET['sorting']))
        {
            if(
    $_GET['sorting'] == 'ASC'){
                
    $sort "ASC";
            }
            else{
                
    $sort "DESC";
            }
        }
                    
    if (
    $pageno == 1) {
       echo 
    " FIRST PREV ";
    } else {
     
    ?>
     <a href="machine1.php?pageno=1&field_name=<?php echo $data_sort?>&sorting=<?php echo $sort?>">FIRST</a>
    <?php
       $prevpage 
    $pageno-1;
    ?>
       <a href="machine1.php?pageno=<?php echo $prevpage;?>&field_name=<?php echo $data_sort?>&sorting=<?php echo $sort?>">PREV</a>
     
    <?php
    }
    echo 
    " ( Page $pageno of $lastpage ) ";

    if (
    $pageno == $lastpage) {
       echo 
    " NEXT LAST ";
    } else {
       
    $nextpage $pageno+1;

     
    ?>
     
        <a href="machine1.php?pageno=<?php echo $nextpage?>&field_name=<?php echo $data_sort?>&sorting=<?php echo $sort?>">NEXT</a>
           <a href="machine1.php?pageno=<?php echo $lastpage?>&field_name=<?php echo $data_sort?>&sorting=<?php echo $sort?>">LAST</a> 
     <?php
    }

    ?>
    and this is my machine.html
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Machine 1</title>
    </head>
    
    <body>
    
    <table border="1" cellpadding="1" cellspacing="1">
    	
        <tr>
        	<td><a href="machine1.php?sorting={sorting}&field_name=Emp_ID">Employee Id</a></td>
        	<td><a href="machine1.php?sorting={sorting}&field_name=Last_Name">Last Name</a></td>
            <td><a href="machine1.php?sorting={sorting}&field_name=First_Name">First Name</a></td>
            <td><a href="machine1.php?sorting={sorting}&field_name=Birthday">Birthday</a></td>
            <td>Option</td>
        </tr>
    
        
    	<!-- BEGIN block_list -->
    	<tr>
    		<td>{id}</td>
    		<td>{lastname}</td>
    		<td>{firstname}</td>
    		<td>{birthday}</td>
            <td><a href = 'edit.php?id=<?php echo $emp_id; ?>'>Edit</a> <a href='delete.php?id=<?php echo $emp_id; ?>' onClick="return confirm('Are you sure you want to delete?')">Delete</a></td>
    	</tr>
    	<!-- END block_list -->
    </table>
    
     <A HREF="javascript:void(0)" onClick="window.open('add.php','welcome','width=300,height=200')">
    <input type="button" name="add" value="ADD"> </A>&nbsp;&nbsp;
    </body>
    </html>
    and this is my edit.php where the id was declare to check what data will be edit.
    PHP Code:

    <?php
    error_reporting
    (E_ERROR E_WARNING E_PARSE);
    include(
    'includes/config.sender.php');
    include(
    'includes/template.inc');


    $id=$_GET['id'];

    $sql_select "SELECT
                        Emp_ID,
                        Last_Name,
                        First_Name,
                        Birthday
                   FROM
                        machine_problem_rhoda
                   WHERE 
                           Emp_ID = $id"
    ;
                   
    $info $_DB->opendb($sql_select);

    //$data_p = mysql_query("SELECT * FROM tbl_machine1 WHERE Emp_ID = $id") or die(mysql_error());
    //while($info = mysql_fetch_array( $data_p ))
    //{
        
    $emp_id $info['Emp_ID'];
        
    $lname $info['Last_Name'];
        
    $fname $info['First_Name'];
        
    $bday $info['Birthday'];
        
        
    $date date('d-m-Y'strtotime($bday));
    //}
        
    if(isset($_POST['update'])){
    $id=$_GET['id'];    
    $Lname=$_POST['Last_Name'];
    $Fname=$_POST['First_Name'];
    $bday=$_POST['date'];
    $date date('Y-m-d'strtotime($bday));



    $Lname addslashes_gpc($Lname);
    $Fname addslashes_gpc($Fname);
    $date addslashes_gpc($date);


    $sql_update "UPDATE machine_problem_rhoda SET 
                        Last_Name = '"
    .$Lname."',
                        First_Name = '"
    .$Fname."',
                        Birthday = '"
    .$date."'
                 WHERE Emp_ID = '"
    .$id."'";

    //mysql_query("UPDATE tbl_machine1 SET Last_Name = '".$Lname."', First_Name = '".$Fname."', Birthday = '".$date."' WHERE Emp_ID = '".$id."' ");
    header ('Location:machine1.php');
    }

    $tpl = new Template('.''keep');
    $tpl->set_file(array('handle' => 'html/edit.html'));

    $tpl->parse('handle', array('handle'));
    $tpl->p('handle');
    ?>
    I don't know how can I set_var or how can I call the variable in my <a href> to check what should be edit.I am new in template,function and separating php and html.

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,327
    Thanks
    60
    Thanked 525 Times in 512 Posts
    Blog Entries
    4
    You haven't even replied to your other thread asking for help and you've already come up with your 3rd problematic thread today.

    Also by the way you keep posting your topics here and on sitepoint it seems that you are not even trying to fix or debug your code but just prefer to make it someone elses problem instead.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #3
    Regular Coder
    Join Date
    Aug 2010
    Posts
    713
    Thanks
    165
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by tangoforce View Post
    You haven't even replied to your other thread asking for help and you've already come up with your 3rd problematic thread today.

    Also by the way you keep posting your topics here and on sitepoint it seems that you are not even trying to fix or debug your code but just prefer to make it someone elses problem instead.
    I'm sorry, i hope you understand that I am new in php and I'm not good in logic and also I am new in using function which is from other programmer.

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,327
    Thanks
    60
    Thanked 525 Times in 512 Posts
    Blog Entries
    4
    I've provided you with very simple steps yet you fail to read them and understand them properly.

    In your previous topic I clearly showed you what line i wanted the print_r result from and you twice gave me a print_r of the wrong variable. Now you refuse to even answer it.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #5
    Regular Coder
    Join Date
    Aug 2010
    Posts
    713
    Thanks
    165
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by tangoforce View Post
    What is the actual problem? - In your last thread (about the login) you claim on codingforums that you have to use a different function. You refused to provide a print_r of the variable but here on sitepoint you claimed the SQL was not working which is a completely different problem - yet identical code.

    I see you have also posted this topic on codingforums too.

    Will this one also have two seperate issues - one for each site?
    Sorry, I was really confused about coding using function, and I tried to experiment. That's why theres a time that my response in different forums is different.

    now I tried to fix my problem and I found out that the id that I set as variable was not read.

    PHP Code:
    $id $_GET['id']; 
    I add code in my ser_var for the id that I used to check if what ID that the user wants to edit or delete.

    here is my revised machine1.php
    PHP Code:
    <?php

    error_reporting
    (E_ERROR E_WARNING E_PARSE);
    include(
    'includes/config.sender.php');
    include(
    'includes/template.inc');


    /*Sorting of Data*/
     
    $sort "ASC";
      
    $data_sort "Emp_ID";
      
      if(isset(
    $_GET['sorting']))
        {
            if(
    $_GET['sorting'] == 'ASC'){
                
    $sort "DESC";
            }
            else{
                
    $sort "ASC";
            }
        }
        
        
        if (isset(
    $_GET['field_name'])) {
            if(
    $_GET['field_name']  == 'Emp_ID'){
                
    $data_sort "Emp_ID";
            }
            elseif(
    $_GET['field_name'] == 'Last_Name'){
                
    $data_sort "Last_Name";
            }
            elseif(
    $_GET['field_name'] == 'First_Name'){
                
    $data_sort "First_Name";
            }
            elseif(
    $_GET['field_name'] == 'Birthday'){
                
    $data_sort "Birthday";
            }
        }


        
        
    /*Pagination, Sorting and Limit*/

    if (isset($_GET['pageno'])) {
       
    $pageno $_GET['pageno'];
    } else {
       
    $pageno 1;



    $sql_select "SELECT COUNT(*) as numrows 
                    FROM  
                        machine_problem_rhoda"

    $result $_DB->opendb($sql_select); 

    if(isset(
    $result[0]['numrows'])) //check if result returned a numrows
    {
       
    $numrows = (int)$result[0]['numrows'];     //typecast, to clearify the value range.
    }
    else
    {
       
    $numrows 0;//or false - 
    }


    $rows_per_page 5;
    $lastpage      ceil($numrows/$rows_per_page);

    $pageno = (int)$pageno;
    if (
    $pageno $lastpage) {
       
    $pageno $lastpage;

    if (
    $pageno 1) {
       
    $pageno 1;


    $limit 'LIMIT ' .($pageno 1) * $rows_per_page .',' .$rows_per_page;



    $sql_select "SELECT
                        Emp_ID,
                        Last_Name,
                        First_Name,
                        Birthday
                    FROM
                        machine_problem_rhoda
                    ORDER BY $data_sort $sort $limit
                    "
    ;
    $rows $_DB->opendb($sql_select);

    $tpl = new Template('.''keep');
    $tpl->set_file(array('handle' => 'html/machine1.html'));


    $tpl->set_block('handle''block_list''tag_list');
    foreach(
    $rows as $row) {
        
    $tpl->set_var(array('emp_id'=> $row['Emp_ID'],
                            
    'lastname' => $row['Last_Name'],
                            
    'firstname' => $row['First_Name'],
                            
    'birthday' => $row['Birthday'],
                            
    'sorting' => $sort,
                            [
    COLOR="Blue"]'id' => $id[/COLOR]
        ));
        
    $tpl->parse('tag_list''block_list'true);
    }

    $tpl->parse('handle', array('handle'));
    $tpl->p('handle');


    ?>
        <!--</table>-->
        

    <?php

     
    if(isset($_GET['sorting']))
        {
            if(
    $_GET['sorting'] == 'ASC'){
                
    $sort "ASC";
            }
            else{
                
    $sort "DESC";
            }
        }
                    
    if (
    $pageno == 1) {
       echo 
    " FIRST PREV ";
    } else {
     
    ?>
     <a href="machine1.php?pageno=1&field_name=<?php echo $data_sort?>&sorting=<?php echo $sort?>">FIRST</a>
    <?php
       $prevpage 
    $pageno-1;
    ?>
       <a href="machine1.php?pageno=<?php echo $prevpage;?>&field_name=<?php echo $data_sort?>&sorting=<?php echo $sort?>">PREV</a>
     
    <?php
    }
    echo 
    " ( Page $pageno of $lastpage ) ";

    if (
    $pageno == $lastpage) {
       echo 
    " NEXT LAST ";
    } else {
       
    $nextpage $pageno+1;

     
    ?>
     
        <a href="machine1.php?pageno=<?php echo $nextpage?>&field_name=<?php echo $data_sort?>&sorting=<?php echo $sort?>">NEXT</a>
           <a href="machine1.php?pageno=<?php echo $lastpage?>&field_name=<?php echo $data_sort?>&sorting=<?php echo $sort?>">LAST</a> 
     <?php
    }

    ?>
    and this is my revised machine1.html
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Machine 1</title>
    </head>
    
    <body>
    
    <table border="1" cellpadding="1" cellspacing="1">
    	
        <tr>
        	<td><a href="machine1.php?sorting={sorting}&field_name=Emp_ID">Employee Id</a></td>
        	<td><a href="machine1.php?sorting={sorting}&field_name=Last_Name">Last Name</a></td>
            <td><a href="machine1.php?sorting={sorting}&field_name=First_Name">First Name</a></td>
            <td><a href="machine1.php?sorting={sorting}&field_name=Birthday">Birthday</a></td>
            <td>Option</td>
        </tr>
    
        
    	<!-- BEGIN block_list -->
    	<tr>
    		<td>{emp_id}</td>
    		<td>{lastname}</td>
    		<td>{firstname}</td>
    		<td>{birthday}</td>
            <td><a href = 'edit.php?id={id} ?>'>Edit</a> <a href='delete.php?id={id}' onClick="return confirm('Are you sure you want to delete?')">Delete</a></td>
    	</tr>
    	<!-- END block_list -->
    </table>
    
     <A HREF="javascript:void(0)" onClick="window.open('add.php','welcome','width=300,height=200')">
    <input type="button" name="add" value="ADD"> </A>&nbsp;&nbsp;
    </body>
    </html>
    and this is my edit.php
    PHP Code:

    <?php
    error_reporting
    (E_ERROR E_WARNING E_PARSE);
    include(
    'includes/config.sender.php');
    include(
    'includes/template.inc');


    [
    COLOR="Blue"]$id=$_GET['id'];


    /*the output of this code is SELECT
                        Emp_ID,
                        Last_Name,
                        First_Name,
                        Birthday
                   FROM
                        machine_problem_rhoda
                   WHERE 
                           Emp_ID =  ?> it did not read the id, this is my problem*/

    $sql_select "SELECT
                        Emp_ID,
                        Last_Name,
                        First_Name,
                        Birthday
                   FROM
                        machine_problem_rhoda
                   WHERE 
                           Emp_ID = $id"
    ;
                   
    $info $_DB->opendb($sql_select);[/COLOR]


        
    $emp_id $info['Emp_ID'];
        
    $lname $info['Last_Name'];
        
    $fname $info['First_Name'];
        
    $bday $info['Birthday'];
        
        
    $date date('d-m-Y'strtotime($bday));

    if(isset(
    $_POST['update'])){
    [
    b]$id=$_GET['id'];[/b]    
    $Lname=$_POST['Last_Name'];
    $Fname=$_POST['First_Name'];
    $bday=$_POST['date'];
    $date date('Y-m-d'strtotime($bday));



    $Lname addslashes_gpc($Lname);
    $Fname addslashes_gpc($Fname);
    $date addslashes_gpc($date);



    $sql_update "UPDATE machine_problem_rhoda SET 
                        Last_Name = '"
    .$Lname."',
                        First_Name = '"
    .$Fname."',
                        Birthday = '"
    .$date."'
                 WHERE Emp_ID = '"
    .$id."'";

    header ('Location:machine1.php');
    }

    $tpl = new Template('.''keep');
    $tpl->set_file(array('handle' => 'html/edit.html'));

    $tpl->parse('handle', array('handle'));
    $tpl->p('handle');
    ?>
    when I click the edit link this is the output:

    SELECT
    Emp_ID,
    Last_Name,
    First_Name,
    Birthday
    FROM
    machine_problem_rhoda
    WHERE
    Emp_ID = ?>
    query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?>' at line 9

  • #6
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,327
    Thanks
    60
    Thanked 525 Times in 512 Posts
    Blog Entries
    4
    Exactly the same reply as on sitepoint. Completely irrelevant to what i last said.

    Quote Originally Posted by newphpcoder View Post
    Sorry, I was really confused about coding using function, and I tried to experiment. That's why theres a time that my response in different forums is different.

    now I tried to fix my problem and I found out that the id that I set as variable was not read.

    PHP Code:
    $id $_GET['id']; 
    I add code in my ser_var for the id that I used to check if what ID that the user wants to edit or delete.

    here is my revised machine1.php
    PHP Code:
    <?php

    error_reporting
    (E_ERROR E_WARNING E_PARSE);
    include(
    'includes/config.sender.php');
    include(
    'includes/template.inc');


    /*Sorting of Data*/
     
    $sort "ASC";
      
    $data_sort "Emp_ID";
      
      if(isset(
    $_GET['sorting']))
        {
            if(
    $_GET['sorting'] == 'ASC'){
                
    $sort "DESC";
            }
            else{
                
    $sort "ASC";
            }
        }
        
        
        if (isset(
    $_GET['field_name'])) {
            if(
    $_GET['field_name']  == 'Emp_ID'){
                
    $data_sort "Emp_ID";
            }
            elseif(
    $_GET['field_name'] == 'Last_Name'){
                
    $data_sort "Last_Name";
            }
            elseif(
    $_GET['field_name'] == 'First_Name'){
                
    $data_sort "First_Name";
            }
            elseif(
    $_GET['field_name'] == 'Birthday'){
                
    $data_sort "Birthday";
            }
        }


        
        
    /*Pagination, Sorting and Limit*/

    if (isset($_GET['pageno'])) {
       
    $pageno $_GET['pageno'];
    } else {
       
    $pageno 1;



    $sql_select "SELECT COUNT(*) as numrows 
                    FROM  
                        machine_problem_rhoda"

    $result $_DB->opendb($sql_select); 

    if(isset(
    $result[0]['numrows'])) //check if result returned a numrows
    {
       
    $numrows = (int)$result[0]['numrows'];     //typecast, to clearify the value range.
    }
    else
    {
       
    $numrows 0;//or false - 
    }


    $rows_per_page 5;
    $lastpage      ceil($numrows/$rows_per_page);

    $pageno = (int)$pageno;
    if (
    $pageno $lastpage) {
       
    $pageno $lastpage;

    if (
    $pageno 1) {
       
    $pageno 1;


    $limit 'LIMIT ' .($pageno 1) * $rows_per_page .',' .$rows_per_page;



    $sql_select "SELECT
                        Emp_ID,
                        Last_Name,
                        First_Name,
                        Birthday
                    FROM
                        machine_problem_rhoda
                    ORDER BY $data_sort $sort $limit
                    "
    ;
    $rows $_DB->opendb($sql_select);

    $tpl = new Template('.''keep');
    $tpl->set_file(array('handle' => 'html/machine1.html'));


    $tpl->set_block('handle''block_list''tag_list');
    foreach(
    $rows as $row) {
        
    $tpl->set_var(array('emp_id'=> $row['Emp_ID'],
                            
    'lastname' => $row['Last_Name'],
                            
    'firstname' => $row['First_Name'],
                            
    'birthday' => $row['Birthday'],
                            
    'sorting' => $sort,
                            [
    COLOR="Blue"]'id' => $id[/COLOR]
        ));
        
    $tpl->parse('tag_list''block_list'true);
    }

    $tpl->parse('handle', array('handle'));
    $tpl->p('handle');


    ?>
        <!--</table>-->
        

    <?php

     
    if(isset($_GET['sorting']))
        {
            if(
    $_GET['sorting'] == 'ASC'){
                
    $sort "ASC";
            }
            else{
                
    $sort "DESC";
            }
        }
                    
    if (
    $pageno == 1) {
       echo 
    " FIRST PREV ";
    } else {
     
    ?>
     <a href="machine1.php?pageno=1&field_name=<?php echo $data_sort?>&sorting=<?php echo $sort?>">FIRST</a>
    <?php
       $prevpage 
    $pageno-1;
    ?>
       <a href="machine1.php?pageno=<?php echo $prevpage;?>&field_name=<?php echo $data_sort?>&sorting=<?php echo $sort?>">PREV</a>
     
    <?php
    }
    echo 
    " ( Page $pageno of $lastpage ) ";

    if (
    $pageno == $lastpage) {
       echo 
    " NEXT LAST ";
    } else {
       
    $nextpage $pageno+1;

     
    ?>
     
        <a href="machine1.php?pageno=<?php echo $nextpage?>&field_name=<?php echo $data_sort?>&sorting=<?php echo $sort?>">NEXT</a>
           <a href="machine1.php?pageno=<?php echo $lastpage?>&field_name=<?php echo $data_sort?>&sorting=<?php echo $sort?>">LAST</a> 
     <?php
    }

    ?>
    and this is my revised machine1.html
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Machine 1</title>
    </head>
    
    <body>
    
    <table border="1" cellpadding="1" cellspacing="1">
    	
        <tr>
        	<td><a href="machine1.php?sorting={sorting}&field_name=Emp_ID">Employee Id</a></td>
        	<td><a href="machine1.php?sorting={sorting}&field_name=Last_Name">Last Name</a></td>
            <td><a href="machine1.php?sorting={sorting}&field_name=First_Name">First Name</a></td>
            <td><a href="machine1.php?sorting={sorting}&field_name=Birthday">Birthday</a></td>
            <td>Option</td>
        </tr>
    
        
    	<!-- BEGIN block_list -->
    	<tr>
    		<td>{emp_id}</td>
    		<td>{lastname}</td>
    		<td>{firstname}</td>
    		<td>{birthday}</td>
            <td><a href = 'edit.php?id={id} ?>'>Edit</a> <a href='delete.php?id={id}' onClick="return confirm('Are you sure you want to delete?')">Delete</a></td>
    	</tr>
    	<!-- END block_list -->
    </table>
    
     <A HREF="javascript:void(0)" onClick="window.open('add.php','welcome','width=300,height=200')">
    <input type="button" name="add" value="ADD"> </A>&nbsp;&nbsp;
    </body>
    </html>
    and this is my edit.php
    PHP Code:

    <?php
    error_reporting
    (E_ERROR E_WARNING E_PARSE);
    include(
    'includes/config.sender.php');
    include(
    'includes/template.inc');


    [
    COLOR="Blue"]$id=$_GET['id'];


    /*the output of this code is SELECT
                        Emp_ID,
                        Last_Name,
                        First_Name,
                        Birthday
                   FROM
                        machine_problem_rhoda
                   WHERE 
                           Emp_ID =  ?> it did not read the id, this is my problem*/

    $sql_select "SELECT
                        Emp_ID,
                        Last_Name,
                        First_Name,
                        Birthday
                   FROM
                        machine_problem_rhoda
                   WHERE 
                           Emp_ID = $id"
    ;
                   
    $info $_DB->opendb($sql_select);[/COLOR]


        
    $emp_id $info['Emp_ID'];
        
    $lname $info['Last_Name'];
        
    $fname $info['First_Name'];
        
    $bday $info['Birthday'];
        
        
    $date date('d-m-Y'strtotime($bday));

    if(isset(
    $_POST['update'])){
    [
    b]$id=$_GET['id'];[/b]    
    $Lname=$_POST['Last_Name'];
    $Fname=$_POST['First_Name'];
    $bday=$_POST['date'];
    $date date('Y-m-d'strtotime($bday));



    $Lname addslashes_gpc($Lname);
    $Fname addslashes_gpc($Fname);
    $date addslashes_gpc($date);



    $sql_update "UPDATE machine_problem_rhoda SET 
                        Last_Name = '"
    .$Lname."',
                        First_Name = '"
    .$Fname."',
                        Birthday = '"
    .$date."'
                 WHERE Emp_ID = '"
    .$id."'";

    header ('Location:machine1.php');
    }

    $tpl = new Template('.''keep');
    $tpl->set_file(array('handle' => 'html/edit.html'));

    $tpl->parse('handle', array('handle'));
    $tpl->p('handle');
    ?>
    when I click the edit link this is the output:

    SELECT
    Emp_ID,
    Last_Name,
    First_Name,
    Birthday
    FROM
    machine_problem_rhoda
    WHERE
    Emp_ID = ?>
    query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?>' at line 9
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •