Jump to content

Connect database mySQL to phaser


Gee
 Share

Recommended Posts

I'm newbie at phaser and I need to connect database to my game.

My game menu is created with format html and php, and my game is created with phaser.

I need to passing an id which user choose from menu to game with this code :

<a class = "btn_song" href = "GamePlay.php?id=<?=$row['id']?>">

And in my game, I've written php code like this :

<?PHP
	$id = $_GET['id'];
	$query = "select * from song where no = ".$id;
?>

but it's wrong. I think it's because phaser didn't support php. I've read that I should use JSON or AJAX, but I still can solve it.

How to solve this?

Link to comment
Share on other sites

Phaser is a front-end technology, as such, it wont kill php, if you were intent on working that way.

You're confusing how php generates pages and how you supply data to the client.

Take Phaser out of the equation and try to get your code to work in a page with nothing else in it. I think you are confusing where PHP (and possibly also where JS) runs.  I wouldnt even worry about the Phaser bit for now, you need to do a bit of research on how PHP builds HTML and how it can be used to supply data from a data source.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...