Just starting out? Need help? Post your questions and find answers here.
Efo74
 
Posts: 16
Joined: Sat Mar 24, 2018 9:58 am

Write TextGadget text from php

by Efo74 Mon Apr 15, 2019 6:39 pm

hello, is there an example on how write textgadget text from php code ? Thank you for the support. What I want is write mysql database with php INSERT, than get latest insert id, and write this id into a textgadget ... possible ?
JCV
 
Posts: 10
Joined: Wed Apr 17, 2019 6:08 am

Re: Write TextGadget text from php

by JCV Wed Apr 17, 2019 9:24 am

Hi Efo,

I used JSON and HTTPRequest to do this combine php + sb.
BTW, I'm new in SB. i'll still on trial version and I started last week. :D


Code: Select all
Procedure HttpGetEvent(Success, Result$, UserData)
  Protected material_request_record.material_request_query_result
  Protected record_no.i, start_time.i, process_time.i
 
  If Success
        If ParseJSON(0, Result$)
          ExtractJSONStructure(JSONValue(0), @material_request_record,  material_request_query_result)
          FreeJSON(0)
        Else
          Debug JSONErrorMessage()
        EndIf
       
      ClearGadgetItems(lst_material_request_status)
      record_no = 0
      Protected days_left.s
      ForEach material_request_record\Result()
        AddGadgetItem(lst_material_request_status, record_no, material_request_record\Result()\mat_req_ID + Chr(10) + material_request_record\Result()\UserName + Chr(10) + material_request_record\Result()\installation_bldg)
        record_no + 1
    Else
      Debug "HTTPRequest(): Error"
    EndIf
EndProcedure
 
Procedure get_material_request_list()
  Protected request.s, request_result.s, Filter, HttpRequest
  Protected NewMap Header.s()
 
  If CreateJSON(0)
    Filter = SetJSONObject(JSONValue(0))
    SetJSONString(AddJSONMember(Filter, "UserName"), "ALL")
    SetJSONString(AddJSONMember(Filter, "AnelID"), "")
    SetJSONString(AddJSONMember(Filter, "Approved"), "")
    SetJSONString(AddJSONMember(Filter, "StatusType"), "")
    request = ComposeJSON(0)
    Debug request
    FreeJSON(0)
  EndIf
 
  Header("Content-Type") = "application/json"
  HTTPRequest(#PB_HTTP_Post, "get_material_list.php", request, @HttpGetEvent(), 0, Header())
EndProcedure
Efo74
 
Posts: 16
Joined: Sat Mar 24, 2018 9:58 am

Re: Write TextGadget text from php

by Efo74 Wed Apr 17, 2019 7:47 pm

Thanks for your help, now I have to study your code :shock:
JCV
 
Posts: 10
Joined: Wed Apr 17, 2019 6:08 am

Re: Write TextGadget text from php

by JCV Thu Apr 18, 2019 5:14 am

Hi, heres my sample of screenshot to give you idea. I already reached 800lines of code so I'll be purchasing soon to explore sb.
It looks fun and easy but need some tweaking to accomplish some task.
Thanks to all who share their tips and code here in forum.


Image
Return to Coding Questions

Who is online

Users browsing this forum: No registered users and 6 guests