Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2010
    Posts
    136

    Unanswered: Displaying Autogenerate number after click Button

    Hi..

    I encountered problem in displaying joborder number or JO_No inside while loop.

    I want to happen is only JO_No will display after I click the Approved button and it will only appear on the row where the Approved button was click.

    Now in my code the JO_No was display automatically in the row of JO_No .

    here is my code:

    PHP Code:
    <?php
        error_reporting
    (0);
      
    date_default_timezone_set("Asia/Singapore"); //set the time zone  
    $con mysql_connect('localhost''root','');

    if (!
    $con) {
        echo 
    'failed';
        die();
    }

    mysql_select_db("mes"$con);
    $Date_Shelve =date('Y-m-d H:i:s');  


    ?>
    <html>
    <head>
    <title>Job Order</title> 
    <link rel="stylesheet" type="text/css" href="kanban.css" />    
    </head>
    <body>


    <div id="SR_date">
    <label>Date :</label>
    <input type="text" name="Date_Shelve" id="Date_Shelve" value="<?php echo $Date_Shelve?>" size="16" readonly="readonly" style="border: none;">    
    </div>

    <div id="kanban_table"> 
    <table width="auto">
    <th> JO No.</th>
    <th> ETD </th>
    <th> PO No. </th>
    <th> SKU Code </th>
    <th> Description </th>
    <th> PO Req </th>
    <th> Requirements </th>
    <th> Priority</th>

    <?php

    $sql 
    "SELECT ETD, PO_No, SKUCode, Description, POReq 
    FROM sales_order"
    ;
    $res_so mysql_query($sql$con);

    $Approved = isset($_POST['priority']);
    if (
    $Approved)
    {
        
    $PO_No $_POST['PO_No'];
    //----I want to display only the jo_number after click the approved button and it only display on the row where I click the approved button---
        
    $sql "SELECT jo_number FROM job_order ORDER BY jo_date DESC LIMIT 1";
            
    $result mysql_query($sql$con);
            
            if (!
    $result) {
                echo 
    'failed'
                die();
            }
            
    $total mysql_num_rows($result);
            if (
    $total <= 0) {
                
    $currentSRNum 1;
                 
    $currentYear  = (int)(date('y'));
                
    $currentMonth = (int)(date('m'));
                
    $currentDay = (int)(date('d'));
               
                
    $currentSRYMD substr($row['jo_number'], 06);
                
    $currentYMD date("ymd");
                if (
    $currentYMD $currentSRYMD
                {  
                    
    $currentSRNum 1;
                } 
                else 
                {  
                    
    $currentSRNum += 1;
                }     
                 
            } 
            else {
    //----------------------------------------
                
    $row mysql_fetch_assoc($result);
                
                
    $currentSRNum = (int)(substr($row['jo_number'],0,3));
                
                
    $currentSRYear  = (int)(substr($row['jo_number'],2,2));
                
    $currentSRMonth = (int)(substr($row['jo_number'],0,2));
                
    $currentSRNum = (int)(substr($row['jo_number'],6,4));

                
    $currentYear  = (int)(date('y'));
                
    $currentMonth = (int)(date('m'));
                
    $currentDay = (int)(date('d'));
               
                
    $currentSRYMD substr($row['jo_number'], 06);
                
    $currentYMD date("ymd");
                if (
    $currentYMD $currentSRYMD
                {  
                    
    $currentSRNum 1;
                } 
                else 
                {  
                    
    $currentSRNum += 1;
                }                                           
            }
             
            
    $yearMonth date('ymd');    
            
    $currentSR $currentYMD sprintf("%04d"$currentSRNum); //JO_No
    }


    while(
    $row mysql_fetch_assoc($res_so)){
    echo 
    "<form name='joborder_form' action='' method='post'>";
    $PO_No $row['PO_No'];  
    echo 
    "<tr>
    <td><input type='text' name='JO_No' id='JO_No' value='
    $currentSR' style='border:none;width:auto;' size='10'></td>
    <td><input type='text' name='ETD' id='ETD' value='
    $row[ETD]' style='border:none;width:auto;' size='10'></td> 
    <td><input type='text' name='PO_No' id='PO_No' value='
    $row[PO_No]' style='border:none;' size='30'></td>
    <td><input type='text' name='SKUCode' id='SKUCode' value='
    $row[SKUCode]' style='border:none;' size='15'></td>
    <td><input type='text' name='Description' id='Description' value='
    $row[Description]' style='border:none;' size='35'></td>
    <td><input type='text' name='POReq' id='POReq' value='
    $row[POReq]' style='border:none;width:auto;' size='10'></td> 
    <td>&nbsp;</td>
    <td><input type='submit' name='priority' value='Approved' id='priority'></td>
    </tr>"
    ;
    echo 
    "</form>";
    }
    ?>

    </table>
    </div>

    </body>
    </html>
    I attach the sample image of my form.

    Any help is highly appreciated

    Thank you
    Attached Files Attached Files
    Last edited by newphpcoder; 04-20-12 at 00:03.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    once again, i don't understand why you post questions like this in the mysql forum

    you obviously have a php programming issue
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    PHP forum is here.
    PHP - dBforums

Posting Permissions

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