<?php
$databasehost = "localhost";
$databasename = "xxxxxx";
$databaseusername ="xxxxxx";
$databasepassword = "xxxxxxx";
$con = mysqli_connect($databasehost,$databaseusername,$databasepassword,$databasename) or die(mysqli_error($con));
mysqli_select_db($con,$databasename) or die(mysqli_error());
mysqli_query($con,"SET CHARACTER SET utf8");
mysqli_query($con,"SET NAMES 'utf8'");
mysqli_set_charset ($con , "utf8");
$query = file_get_contents("php://input");
$sth = mysqli_query($con, $query);
if (mysqli_errno($con)) {
header("HTTP/1.1 500 Internal Server Error");
echo $query.'\n';
echo mysqli_error($con);
}
else
{
$result = mysql_query("select Post FROM Comande");
$RowCount = mysql_fetch_all($result); //Total size recovery
$result2 = mysql_query("select Post FROM Comande");
$RowCount2 = mysql_fetch_all($result2);
$rows2 =array($RowCount2) ;
for ($i = 0; $i <= $RowCount; ++$i)
{
$rows2[$i]
$res = json_encode($rows2,True);
echo $res;
mysqli_free_result($sth);
}
}
mysqli_close($con);
?>
public Sub GetAllPost_Command
ExecuteRemoteQueryGetAll("SELECT Post FROM Comande", GetAllPost)
End Sub
Sub ExecuteRemoteQueryGetAll(Query As String, JobName As String)
Dim job As HttpJob
job.Initialize(JobName, Me)
job.PostString("https://www.xxxxxxxxxxxxx.com/Client/Scriptxxxxxxxxx.php", Query)
End Sub
<?php
$databasehost = "localhost";
$databasename = "xxxxxx";
$databaseusername ="xxxxxx";
$databasepassword = "xxxxxxx";
$con = mysqli_connect($databasehost,$databaseusername,$databasepassword,$databasename) or die(mysqli_error($con));
mysqli_select_db($con,$databasename) or die(mysqli_error());
mysqli_query($con,"SET CHARACTER SET utf8");
mysqli_query($con,"SET NAMES 'utf8'");
mysqli_set_charset ($con , "utf8");
$query = file_get_contents("php://input");
$sth = mysqli_query($con, $query);
if (mysqli_errno($con)) {
header("HTTP/1.1 500 Internal Server Error");
echo $query.'\n';
echo mysqli_error($con);
}
else
{
$sth = mysqli_query("select Post FROM Comande");
$rows = array();
while($r = mysqli_fetch_assoc($sth)) {
$rows[] = $r;
}
print json_encode($rows);
}
mysqli_close($con);
?>
Sub JobDone(Job As HttpJob)
If Job.Success Then
Dim res As String
res = Job.GetString
Dim parser As JSONParser
parser.Initialize(res)
Select Job.JobName
Case GetAllPost
Dim List1 As List
List1.Initialize
List1 = parser.NextArray 'returns a list with maps
For i = 0 To List1.Size - 1
Log(List1.Get(i))
Next
Case Process_Data
ParallelTime = DateTime.Time(DateTime.Now)
Dim ListCountRow As List
Dim ListCommand As ListCommand
ListPostServer.Clear
ListCountRow.Initialize
ListCountRow.Clear
Dim List As List
List.Initialize
List = parser.NextArray 'returns a list with maps
If List.Size>0 And List.Size>NrID Then
ListCountNewPost=List
For i = 0 To List.Size - 1
Dim m As Map
m=CreateMap("ID":NrID,"PostTime":PostTime,"Post":Post,"NrAntipasti":NrAnt,"NrSalat":NrSalat,"NrPizze":NrPizze,"NrPaste":NrPaste,"NrCarne":NrCarne,"NrPesce":NrPesce)
m=List.Get(i)
ListCountRow.Add(i)
ListCommand.PostTime=m.Get("PostTime")
ListCommand.NrAnt=m.Get("NrAntipasti")
ListCommand.NrSal=m.Get("NrSalat")
ListCommand.NrPizze=m.Get("NrPizze")
ListCommand.NrPaste=m.Get("NrPaste")
ListCommand.NrCarne=m.Get("NrCarne")
ListCommand.NrPesce=m.Get("NrPesce")
ListCommand.NrID= m.Get("ID")
ListCountNewPost.Add(m.Get("ID"))
'Log(ListCommand.NrID&CRLF&ListCommand.NrAnt&CRLF&ListCommand.NrSal&CRLF&ListCommand.NrPizze&CRLF&ListCommand.NrPaste&CRLF&ListCommand.NrCarne&CRLF&ListCommand.NrCarne&CRLF&ListCommand.NrPesce)
Next
ListPostServer.Add(m.Get("Post"))
PostTime=ListCommand.PostTime
intAnt=ListCommand.NrAnt
Intsal=ListCommand.NrSal
Intpast=ListCommand.NrPaste
intCar=ListCommand.NrCarne
IntPesce=ListCommand.NrPesce
For i=0 To ListPostServer.Size-1
CustomListComande.Add(CreateListItemComanda(ListPostServer.Get(i),49%y,46%x),ListPostServer.Get(i))
Next
NrID=NrID+1
intb=intb+1
BTNotifica1.Text=intb
BTNotifica2.Text=intb
Log(CRLF&"Response from server2: " & res)
End If
End Select
Else
Log(Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
Sub GetAllPost_inServer (JsonString As String) As ResumableSub
Dim j As HttpJob
j.Initialize("", Me)
j.PostString(Servername & ScriptGetAllPost, JsonString)
Wait For (j) JobDoneGetAll (j As HttpJob)
Log(j.GetString)
Dim Result As String = j.GetString
j.Release
Return Result
End Sub
public Sub GetAllPost_Command
ExecuteRemoteQueryGetAll("SELECT Post FROM Comande", GetAllPost)
End Sub
Sub ExecuteRemoteQueryGetAll(Query As String, JobName As String)
Dim job As HttpJob
job.Initialize(JobName, Me)
job.PostString("https://www.xxxxxxxx.com/Client/Scriptxxxxxx.php", Query)
End Sub
ThisTry this:
PHP:<?php $databasehost = "localhost"; $databasename = "xxxxxx"; $databaseusername ="xxxxxx"; $databasepassword = "xxxxxxx"; $con = mysqli_connect($databasehost,$databaseusername,$databasepassword,$databasename) or die(mysqli_error($con)); mysqli_select_db($con,$databasename) or die(mysqli_error()); mysqli_query($con,"SET CHARACTER SET utf8"); mysqli_query($con,"SET NAMES 'utf8'"); mysqli_set_charset ($con , "utf8"); $query = file_get_contents("php://input"); $sth = mysqli_query($con, $query); if (mysqli_errno($con)) { header("HTTP/1.1 500 Internal Server Error"); echo $query.'\n'; echo mysqli_error($con); } else { $sth = mysqli_query("select Post FROM Comande"); $rows = array(); while($r = mysqli_fetch_assoc($sth)) { $rows[] = $r; } print json_encode($rows); } mysqli_close($con); ?>
while($r = mysqli_fetch_assoc($sth)) {
$rows[] = $r;
}
while($r = mysqli_fetch_assoc($sth)) {
array_push($rows,$r);
}
<?php
$databasehost = "localhost";
$databasename = "xxxxxx";
$databaseusername ="xxxxxx";
$databasepassword = "xxxxxxx";
$con = mysqli_connect($databasehost,$databaseusername,$databasepassword,$databasename) or die(mysqli_error($con));
mysqli_select_db($con,$databasename) or die(mysqli_error());
mysqli_query($con,"SET CHARACTER SET utf8");
mysqli_query($con,"SET NAMES 'utf8'");
mysqli_set_charset ($con , "utf8");
$query = file_get_contents("php://input");
$sth = mysqli_query($con, $query);
if (mysqli_errno($con)) {
header("HTTP/1.1 500 Internal Server Error");
echo $query.'\n';
echo mysqli_error($con);
}
else
{
$sth = mysqli_query("SELECT Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday FROM tablename");
$rows = array();
while($r = mysqli_fetch_assoc($sth)) {
array_push($rows,$r);
}
print json_encode($rows);
}
mysqli_close($con);
?>
Sub populate_table()
Dim j As HttpJob
j.Initialize("j",Me)
j.Download("http://your_php_code_url")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
B4XTable1.Clear
B4XTable1.AddColumn("Monday",B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("Tuesday",B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("Wednesday",B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("Thursday",B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("Friday",B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("Saturday",B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("Sunday ",B4XTable1.COLUMN_TYPE_TEXT)
Dim Data As List
Data.Initialize
Dim parser As JSONParser
parser.Initialize(j.GetString)
Dim root As List = parser.NextArray
For Each colroot As Map In root
Dim row(7) As Object
row(0) = colroot.Get("Monday")
row(1) = colroot.Get("Thursday")
row(2) = colroot.Get("Friday")
row(3) = colroot.Get("Sunday")
row(4) = colroot.Get("Wednesday")
row(5) = colroot.Get("Tuesday")
row(6) = colroot.Get("Saturday")
Data.Add(row)
Next
B4XTable1.SetData(Data)
End If
End Sub
Dim myRoot As List = parser.NextArray
For Each colroot As Map In myRoot
Dim row(7) As Object
row(0) = colroot.Get("Monday")
row(1) = colroot.Get("Thursday")
row(2) = colroot.Get("Friday")
row(3) = colroot.Get("Sunday")
row(4) = colroot.Get("Wednesday")
row(5) = colroot.Get("Tuesday")
row(6) = colroot.Get("Saturday")
Data.Add(row)
Next
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?