In PHP I often read a bunch of key pairs from a SQL table and load up variables using somethng like;
This is particularly useful for filling in Report Templates.
Is there any way to dynamically create and assign a value to something like a sequentially numbered bunch of buttons. I have a handheld POS system with 14 buttons to a page and they are dynamically loaded from a sqlite DB when a page loads or changes. Right now I have effectively got the same code repeated 14 times, which is cumbersome.
Obviously I could easily loop through the List lstID, but how can I set 14 buttons text attributes such as btnPOS0, btnPOS1...btnPOS13 using a loop and my Lists?
Thanks,
Kev
PHP WHILE:
while ($rw = mysqli_fetch_array($rs, MYSQLI_ASSOC)) {
foreach($rw as $key=>$val){
${$key} = $val;
}
}
Is there any way to dynamically create and assign a value to something like a sequentially numbered bunch of buttons. I have a handheld POS system with 14 buttons to a page and they are dynamically loaded from a sqlite DB when a page loads or changes. Right now I have effectively got the same code repeated 14 times, which is cumbersome.
B4X:
If lstID.Get(0) > 0 Then
btnPOS0.Tag = lstID.Get(0)
btnPOS0.Text = lstItem.Get(0)&CRLF&"$"&NumberFormat2(lstPrice.Get(0),1,2,2,False)
Else
btnPOS0.Visible = False
End If
If lstID.Get(1) > 0 Then
btnPOS1.Tag = lstID.Get(1)
btnPOS1.Text = lstItem.Get(1)&CRLF&"$"&NumberFormat2(lstPrice.Get(1),1,2,2,False)
Else
btnPOS1.Visible = False
End If
...
If lstID.Get(13) > 0 Then
btnPOS13.Tag = lstID.Get(13)
btnPOS13.Text = lstItem.Get(13)&CRLF&"$"&NumberFormat2(lstPrice.Get(13),1,2,2,False)
Else
btnPOS13.Visible = False
End If
Thanks,
Kev