Results 1 to 13 of 13
  1. #1
    Join Date
    Mar 2014
    Posts
    44

    Unanswered: I need help with this PHP + ORACLE code

    I keep getting error with this. I want to implement the value inside the meter tag bar but i dont know how to fix this and this is so frustrating.

    I know i need to pull the value from the db and send the html variable into the meter tag.

    Please help me.....

    PHP Code:

    $fab_query 
    'SELECT REV_DATE, HEAD_MARK, QTY, 
           BLASTING, PRIMER, INTERM, PAINT_FINISHING FROM MASTER_DRAWING'
    ;
    $fab_parse oci_parse ($conn$fab_query);  
    oci_execute($fab_parseOCI_DEFAULT);

    $qty  OCI_PARSE($conn'select qty from fabrication');
    oci_execute($qty);

    while ((
    $row oci_fetch_array($fab_parseOCI_ASSOC)) != false
    {
         echo 
    "<tr>\n";
         foreach (
    $row as $item
         {        
              
              
    //echo "  <td>".($item !== null ? htmlentities($item, ENT_QUOTES):" ")."    ITEM RECURRENCE HERE</td>\n";
              
    echo "  <td>".($item['qty']);
              if (
    is_numeric($item['qty'])){
                  
    $item['qty'] = 'value';
                  echo 
    '/'.$item['qty'].'<meter value=10 min="2" max="value"> </meter>';
              } else {
                  echo 
    ' ';
              }
         }
        echo 
    '<td><a href="edit.php?">Edit | </a><a href="delete_paint.php?"> Delete</a></td>';
        echo 
    "</tr>\n";


  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    And the error you are getting is?

    Im surprised there is no WHERE clause on the SELECT statement
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Mar 2014
    Posts
    44
    Quote Originally Posted by healdem View Post
    And the error you are getting is?

    Im surprised there is no WHERE clause on the SELECT statement
    I keep getting array to string conversion error.

    The idea is i want to implement the meter progress in which,
    1. The minimum value is the value from each correspond value
    2. The maximum value is the quantity i each row.

    So by comparing these values, i can get the progress bar in each element of the table.

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    according to:-
    PHP: oci_fetch_array - Manual

    PHP Code:
    $fab_query 'SELECT REV_DATE, HEAD_MARK, QTY,  
           BLASTING, PRIMER, INTERM, PAINT_FINISHING FROM MASTER_DRAWING'

    $fab_parse oci_parse ($conn$fab_query);   
    oci_execute($fab_parseOCI_DEFAULT); 

    $qty  OCI_PARSE($conn'select qty from fabrication'); 
    oci_execute($qty); 

    while ((
    $row oci_fetch_array($fab_parseOCI_BOTH)) != false
    {  
    //insert your html code as required
       
    if ( is_null($row['qty'])
       { 
    //then for now
          
    echo "qty is NULL:";  
       } else
       {
          echo 
    "value of qty is:" $row['qty'];
    // or
    //    echo "value of qty is:" . $row[2];
       
    }

    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Mar 2014
    Posts
    44
    Quote Originally Posted by healdem View Post
    according to:-
    PHP: oci_fetch_array - Manual

    PHP Code:
    $fab_query 'SELECT REV_DATE, HEAD_MARK, QTY,  
           BLASTING, PRIMER, INTERM, PAINT_FINISHING FROM MASTER_DRAWING'

    $fab_parse oci_parse ($conn$fab_query);   
    oci_execute($fab_parseOCI_DEFAULT); 

    $qty  OCI_PARSE($conn'select qty from fabrication'); 
    oci_execute($qty); 

    while ((
    $row oci_fetch_array($fab_parseOCI_BOTH)) != false
    {  
    //insert your html code as required
       
    if ( is_null($row['qty'])
       { 
    //then for now
          
    echo "qty is NULL:";  
       } else
       {
          echo 
    "value of qty is:" $row['qty'];
    // or
    //    echo "value of qty is:" . $row[2];
       
    }

    its still doesnt work

    Notice: Undefined index: qty in C:\xampp\htdocs\WeltesInformationCenter\fab_progre ss.php on line 61
    QTY IS NULL
    Notice: Undefined index: qty in C:\xampp\htdocs\WeltesInformationCenter\fab_progre ss.php on line 61
    QTY IS NULL
    Notice: Undefined index: qty in C:\xampp\htdocs\WeltesInformationCenter\fab_progre ss.php on line 61

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    and line 61 is?

    if guessing you need to replace

    PHP Code:
    $row['qty'
    with
    PHP Code:
    $row['QTY'
    or

    with the ordinal position in the select
    so thats going to be
    PHP Code:
    $row[2
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    Mar 2014
    Posts
    44
    Quote Originally Posted by healdem View Post
    and line 61 is?

    if guessing you need to replace

    PHP Code:
    $row['qty'
    with
    PHP Code:
    $row['QTY'
    or

    with the ordinal position in the select
    so thats going to be
    PHP Code:
    $row[2
    Thanks healdem,
    I will give you the full code listing

    PHP Code:
      $fab_query 'SELECT REV_DATE, HEAD_MARK, QTY, CUTTING, ASSEMBLY,
           WELDING, DRILLING, FINISHING FROM MASTER_DRAWING'
    ;
       
    $fab_parse oci_parse ($conn$fab_query);  
       
    oci_execute($fab_parseOCI_DEFAULT);
       
        echo 
    "<table border='1'>\n";
        
    $ncols oci_num_fields($fab_parse);
        echo 
    "<tr>\n";
        for (
    $i 1$i <= $ncols; ++$i) {
        
    // COLUMN RECURRENCE
        
    $colname oci_field_name($fab_parse$i);
        echo 
    "  <th><b>".htmlentities($colnameENT_QUOTES)."</b></th>\n";
    }
    echo 
    "</tr>\n";

    while ((
    $row oci_fetch_array($fab_parseOCI_BOTH)) != false
    {    

         echo 
    "<tr>\n";
         foreach (
    $row as $item
         {        
              
    //echo "  <td>".($item !== null ? htmlentities($item, ENT_QUOTES):" ")."    ITEM RECURRENCE HERE</td>\n";
              
    echo "  <td>".($item);
              if (
    is_numeric($item)){
                  echo 
    progressBar($item/$row['QTY']);
              } else {
                  echo 
    ' ';
              }
         }
        echo 
    "</tr>\n";
    }
    echo 
    "</table>\n";
    ?> 

  8. #8
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Quote Originally Posted by chrishutagalung View Post
    Thanks healdem,
    I will give you the full code listing
    why?
    the full code lisitng is useless at trying to identify what is line 61
    even assuming that the code posted is the full code I don't have the inclination to count 61 lines to identify the line the error was thrown on. if you can't be bothered to identify the line why should anyone else?

    ..after all its a problem in your code on your project.

    right now prove your code works at its most simple
    don't build the table

    based on your code I'd expect the problem is going to be in the
    PHP Code:
    foreach ($row as $item
    block. that whole section looks dubious. thats why I suggested the simpler code in my previous post.. prove the data is there then start getting fancy.
    I'd rather be riding on the Tiger 800 or the Norton

  9. #9
    Join Date
    Mar 2014
    Posts
    44
    Quote Originally Posted by healdem View Post
    why?
    the full code lisitng is useless at trying to identify what is line 61
    even assuming that the code posted is the full code I don't have the inclination to count 61 lines to identify the line the error was thrown on. if you can't be bothered to identify the line why should anyone else?

    ..after all its a problem in your code on your project.

    right now prove your code works at its most simple
    don't build the table

    based on your code I'd expect the problem is going to be in the
    PHP Code:
    foreach ($row as $item
    block. that whole section looks dubious. thats why I suggested the simpler code in my previous post.. prove the data is there then start getting fancy.
    Hi Healdem,

    I am sorry not being clear about that. I will describe the problem with example.

    So I have the fabrication data

    ItemID Total QTY Welding_Prog Painting_Progress

    ME20 5 2 2
    ME31 4 2 3
    ME25 4 2 2

    So the situation is I couldnt get the basic understanding how we compare the elements. I want to put progress bar in each row in both welding_prog and painting_prog column. In order to get the row, I need to compare lets say for welding progress ME20 I am gonna have to compare 2 with 5 so (2/5)*100%= 40%. I am so frustrated how to get the basic idea with the query and the PHP code.

    I hope you understand what i mean. and I am really sorry for not being clear

  10. #10
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    nothing in what you are saying truly ties up. It maybe that you are struggling to express yourself in English, which isn't really that much of an issue, but Im not hearing a consistent clear thought process. and that I suspect is one of the reasons why your are struggling here

    what is progressbar? its not a native PHP function that Im aware of

    taking a guess
    you want to calculate the %'e complete at various stages. lets assume form your SQL statement
    Code:
    SELECT
     REV_DATE, HEAD_MARK, QTY, CUTTING, ASSEMBLY, WELDING, DRILLING, FINISHING
     FROM MASTER_DRAWING
    you want to compare the QTY to the values in CUTTING, ASSEMBLY, WELDING, DRILLING & FINISHING
    ...now you can do the calculation in the query or the PHP script.. its not that important

    Code:
    SELECT 
    REV_DATE, HEAD_MARK, QTY, CUTTING, ASSEMBLY, WELDING, DRILLING, FINISHING,
     CUTTING / QTY as PCUTTING, ASSEMBLY / QTY as PASSEMBLY,
     WELDING / QTY as PWELDING, DRILLING  / QTY as PDRILLNG, 
    FINISHING / QTY as PFINISHING
     FROM MASTER_DRAWING
    or just pull the data into your PHP script and do the work there
    using
    Code:
    SELECT 
    REV_DATE, HEAD_MARK, QTY, CUTTING, ASSEMBLY, WELDING, DRILLING, FINISHING
     FROM MASTER_DRAWING
    [/code]
    PHP Code:
    while (($row oci_fetch_array($fab_parseOCI_BOTH)) != false)  
    {   echo 
    "<tr>\n"
        echo 
    "<td>".$row[3] /$row[2]."</td>"//cutting / qty
        
    echo "<td>".$row[4] /$row[2]."</td>"// Assembly / qty
        
    echo "<td>".$row[5] /$row[2]."</td>"// Welding / qty
        
    echo "<td>".$row[6] /$row[2]."</td>"// Drilling / qty
    ....and so on
        
    echo "</tr>\n"

    actually if I was doing this with PHP I'd probably write a function that took two parameters and returned the proportion, that function would do range checking data validation ad so on

    but my strong advice is don't put this data into a table (just yet). make certain the maths is right,, make certain the data is right then once you've proved that go on to format it in an HTML table.

    almost certainly my guess is going to be wrong as we dont' really have a clue what you design is, what your requirement is.
    it could be assembly is actually a drawing or part number


    are you still gettign the NULL error?
    be cionsistent with your case
    if the column is defined as qty then use qty, if its defiend as QTY always refer to it as QTY in SQL or the associative array
    Last edited by healdem; 03-20-14 at 15:05.
    I'd rather be riding on the Tiger 800 or the Norton

  11. #11
    Join Date
    Mar 2014
    Posts
    44
    Quote Originally Posted by healdem View Post
    nothing in what you are saying truly ties up. It maybe that you are struggling to express yourself in English, which isn't really that much of an issue, but Im not hearing a consistent clear thought process. and that I suspect is one of the reasons why your are struggling here

    what is progressbar? its not a native PHP function that Im aware of

    taking a guess
    you want to calculate the %'e complete at various stages. lets assume form your SQL statement
    Code:
    SELECT
     REV_DATE, HEAD_MARK, QTY, CUTTING, ASSEMBLY, WELDING, DRILLING, FINISHING
     FROM MASTER_DRAWING
    you want to compare the QTY to the values in CUTTING, ASSEMBLY, WELDING, DRILLING & FINISHING
    ...now you can do the calculation in the query or the PHP script.. its not that important

    Code:
    SELECT 
    REV_DATE, HEAD_MARK, QTY, CUTTING, ASSEMBLY, WELDING, DRILLING, FINISHING,
     CUTTING / QTY as PCUTTING, ASSEMBLY / QTY as PASSEMBLY,
     WELDING / QTY as PWELDING, DRILLING  / QTY as PDRILLNG, 
    FINISHING / QTY as PFINISHING
     FROM MASTER_DRAWING
    or just pull the data into your PHP script and do the work there
    using
    Code:
    SELECT 
    REV_DATE, HEAD_MARK, QTY, CUTTING, ASSEMBLY, WELDING, DRILLING, FINISHING
     FROM MASTER_DRAWING
    [/code]
    PHP Code:
    while (($row oci_fetch_array($fab_parseOCI_BOTH)) != false)  
    {   echo 
    "<tr>\n"
        echo 
    "<td>".$row[3] /$row[2]."</td>"//cutting / qty
        
    echo "<td>".$row[4] /$row[2]."</td>"// Assembly / qty
        
    echo "<td>".$row[5] /$row[2]."</td>"// Welding / qty
        
    echo "<td>".$row[6] /$row[2]."</td>"// Drilling / qty
    ....and so on
        
    echo "</tr>\n"

    actually if I was doing this with PHP I'd probably write a function that took two parameters and returned the proportion, that function would do range checking data validation ad so on

    but my strong advice is don't put this data into a table (just yet). make certain the maths is right,, make certain the data is right then once you've proved that go on to format it in an HTML table.

    almost certainly my guess is going to be wrong as we dont' really have a clue what you design is, what your requirement is.
    it could be assembly is actually a drawing or part number


    are you still gettign the NULL error?
    be cionsistent with your case
    if the column is defined as qty then use qty, if its defiend as QTY always refer to it as QTY in SQL or the associative array

    thank you for your suggestion healdem. I know i made a mistake by going backward. I am thinking to start over with the right method. Can you suggest me how to do with the function approach ?

  12. #12
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    ...probably something like this, which is untested 'air' code

    PHP Code:
    function CalcProportion ($Dividend$Divisor$ReturnonInvalid)
    {   
    //function CalcProportion
        //CALCulates the PROPORTION of the first number ($Dividend) by the second ($Dividor)
        //returns a value ($Quotient) in the range 0 to x.xx
        //if invalid values are provided then quotient, the return value is as per $ReturnonInvalid. so you can set the value to be whatever you need
        //OK so what checks can we do...
        //both the Dividend and Divisor must be numeric
        
    if (is_numeric($Dividend) && is_numeric($Divisor))
        {   
    //then both values were numeric. so do our calculation
            //just in case the user has supplied negative numbers
            
    $Quotient abs($Dividend) / $abs($Divisor);
        }   else    
    //we had invalid data
        
    {   $Quotient $ReturnonInvalid.; //set our default return value;
        
    }
    }

    function 
    CalcPercent ($Dividend$Divisor$ReturnOnInvalid)
    {   
    //function CalcPercent
        //CALCulates the PERCENTage of the first number ($Dividend) of the second ($Dividor)
        //returns a value ($Quotient) in the range 0 to xxx.xxx
        //if invalid values are provided then quotient, the return value is as per $ReturnonInvalid. so you can set the value to be whatever you need
        // all we do is call CalcProportion and multiply the returned value by 100 assuming its numeric
       
    $Quotient CalcProportion ($Dividend$Divisor$ReturnonInvalid);
       if (
    is_numeric($Quotient))
       {  
    $Quotient $Quotient 100;
       }  else
       {  
    $Quotient $ReturnonInvalid;
       }

    I'd rather be riding on the Tiger 800 or the Norton

  13. #13
    Join Date
    Mar 2014
    Posts
    44
    Quote Originally Posted by healdem View Post
    ...probably something like this, which is untested 'air' code

    PHP Code:
    function CalcProportion ($Dividend$Divisor$ReturnonInvalid)
    {   
    //function CalcProportion
        //CALCulates the PROPORTION of the first number ($Dividend) by the second ($Dividor)
        //returns a value ($Quotient) in the range 0 to x.xx
        //if invalid values are provided then quotient, the return value is as per $ReturnonInvalid. so you can set the value to be whatever you need
        //OK so what checks can we do...
        //both the Dividend and Divisor must be numeric
        
    if (is_numeric($Dividend) && is_numeric($Divisor))
        {   
    //then both values were numeric. so do our calculation
            //just in case the user has supplied negative numbers
            
    $Quotient abs($Dividend) / $abs($Divisor);
        }   else    
    //we had invalid data
        
    {   $Quotient $ReturnonInvalid.; //set our default return value;
        
    }
    }

    function 
    CalcPercent ($Dividend$Divisor$ReturnOnInvalid)
    {   
    //function CalcPercent
        //CALCulates the PERCENTage of the first number ($Dividend) of the second ($Dividor)
        //returns a value ($Quotient) in the range 0 to xxx.xxx
        //if invalid values are provided then quotient, the return value is as per $ReturnonInvalid. so you can set the value to be whatever you need
        // all we do is call CalcProportion and multiply the returned value by 100 assuming its numeric
       
    $Quotient CalcProportion ($Dividend$Divisor$ReturnonInvalid);
       if (
    is_numeric($Quotient))
       {  
    $Quotient $Quotient 100;
       }  else
       {  
    $Quotient $ReturnonInvalid;
       }

    Thank you so much healdem I could get them working..

Tags for this Thread

Posting Permissions

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