Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderator: amosbatto

Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
By Marvin

I have a grid named GDOrder used to record Sales, where:
Qty | Desc | Price

I need to copy it to another grid say, ITEMDesc where for each item a unique identification code needs to be inserted.

Example - GDOrder
2 Laptop $3,000
3 Printer $1,500

Item is expanded in ITEMDesc
# | Desc | Price | UID
Row1 Laptop $3,000 xxxx-xxxx-xxxx
Row2 Laptop $3,000 xxxx-xxxx-xxxx
Row3 Printer $1,500 xxxx-xxxx-xxxx
Row4 Printer $1,500 xxxx-xxxx-xxxx
Row5 Printer $1,500 xxxx-xxxx-xxxx

Help much appreciated.
User avatar
By amosbatto
You didn't explain how the unique ID numbers are being obtained, so I will give you an example using auto-incrementing IDs:
Code: Select all
@=ITEMDesc = array(); //create an empty grid

if (is_array(@=GDOrder)) {
   $rowNo = 1;
   $id = rand(0, 1000);

   foreach (@=GDOrder as $aOrder) {
      $quantity = $aOrder['Qty'];

      for ($i=1; $i <= $quantity; $i++) {
           @=ITEMDesc[ $rowNo ] = array(
              "No" => $rowNo,
              "Desc" => $aOrder['Desc'],
              "Price" => $aOrder['Price'],
              "UID" => $id + $rowNo 
Make sure that the grid variables and the IDs in the grid fields are spelled exactly as listed in the above code.
By Marvin
Dear Sir Amosbatto,

You are a legend. It works!!! Thanks.

I just removed the auto-generating ID since the keys are actually provided by outside suppliers.
I shall keep it in mind for future use.
No puedo acceder al diseñador por https.

Tengo el mismo problema. ¿Ha habido alguna[…]

I am trying to add custom font "Ubuntu-Medium[…]

Hi, I suggest you use the operator role with the[…]

Hello, Have you tried with this link: https://sou[…]