Hi communities, I'm having a problem with a for loop in PHP. I need to read all the rows in a MySql table. At the moment I can only transfer one row with the Json to be able to use it in my app. I'm probably wrong with the syntax in PHP. Could you help me?
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
{
$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);
?>
B4X:
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