Php Query request to mySQL
//php query requests to mySQL
<?php
$link = mysql_connect(“localhost”, “username”, “password”);
mysql_select_db(“music”, $link);
$genreID = 4;
$query = “SELECT g.name, a.name, a.albumName”;
$query .= ” FROM albums a, genre g”;
$query .= ” WHERE a.genreID=g.id”;
$query .= ” AND g.id=” . $genreID;
$result = mysql_query($query);
$response = “resp=loaded\n”;
$index = 0;
while($row = mysql_fetch_array($result)) {
$response .= “&artist” . $index . “=” . $row['artist'];
$response .= “&albums” . $index . “=” . $row['albumName'];
$response .= “&genre” . $index . “=” . $row['name']. “\n”;
$index++;
}
$response .= “&total=” . $index;
print $response;
?>
<?php
$link = mysql_connect(“localhost”, “username”, “password”);
mysql_select_db(“music”, $link);
$genreID = 4;
$query = “SELECT g.name, a.name, a.albumName”;
$query .= ” FROM albums a, genre g”;
$query .= ” WHERE a.genreID=g.id”;
$query .= ” AND g.id=” . $genreID;
$result = mysql_query($query);
$response = “resp=loaded\n”;
$index = 0;
while($row = mysql_fetch_array($result)) {
$response .= “&artist” . $index . “=” . $row['artist'];
$response .= “&albums” . $index . “=” . $row['albumName'];
$response .= “&genre” . $index . “=” . $row['name']. “\n”;
$index++;
}
$response .= “&total=” . $index;
print $response;
?>