Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Open the connection
- $con = mysql_connect("localhost","user","password")
- or die('No connection could be established: ' . mysql_error());
- // Select the database
- mysql_select_db("db", $con);
- //in our html file, there is an id submitted which we are using here
- $result = mysql_query("SELECT * from tablename where id = '".$_POST['chooseId']."'")
- or die ("MySQL-Error: " . mysql_error());
- // Here we fill our data into an array
- while($row = mysql_fetch_array($result))
- {
- // "First"=>$row['First'] means you will be able to show the first row of your record by referencing
- data.First later in your jQuery script
- $data = array ("First"=>$row['First'],"Second"=>$row['Second']);
- // We encode our array as JSON, as it is easier to process
- $jsondata = json_encode($data);
- }
- // Finally we return the data
- echo "$jsondata";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement