Gilberto Romero
Gilberto Romero

Reputation: 13

Showing PHP in a PhoneGap based App

I'm trying to show the results of the php in my app, when I test it outside of the app, it works fine, and I have tried many solutions out there to load it with js, ajax, etc. but can't get it to work. Any ideas?

The php gets data from MySql database

-----select.php------

<?php
$con=mysqli_connect("localhost","localhost","","test");
// Check connection
if (mysqli_connect_errno())
{
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM Persons");

/*while($row = mysqli_fetch_array($result))
{
    echo $row['FirstName'] . " " . $row['LastName'];
    echo "<br />";
}*/

echo "<table border='1'>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>";

while($row = mysqli_fetch_array($result))
{
    echo "<tr>";
    echo "<td>" . $row['FirstName'] . "</td>";
    echo "<td>" . $row['LastName'] . "</td>";
    echo "<td>" . $row['Age'] . "</td>";
    echo "</tr>";
}

echo "</table>";
mysqli_close($con);
?>

Upvotes: 0

Views: 1696

Answers (2)

Jorge Y. C. Rodriguez
Jorge Y. C. Rodriguez

Reputation: 3449

Phone gap does not support php, so will be good, if you want non static content... if you have a API which it will provide the content for you application. epiphany it is a really good open source framework created by Jaisen. This will give you an good start to create a good API for it. You can also learn about Zend Frameworks which it is more robust for big applications.

Upvotes: 0

user835223
user835223

Reputation:

Phonegap doesn't have any concept of PHP, you are unable to run PHP in a PhoneGap application. You will need to make AJAX requests from your application to your server for interaction.

The reason it works fine out of the app, is that you're probably running it in the browser straight on the server.

Take a look at jQuery if you're new to it all, especially $.ajax().

Upvotes: 1

Related Questions