Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //connection information
- $host = "localhost";
- $user = "videolan_vl";
- $password = "*";
- $database = "videolan_vl";
- function sqlnez($value)
- {
- // stripslashes
- if (get_magic_quotes_gpc()) {
- $value = stripslashes($value);
- }
- // if not int
- if (!is_numeric($value)) {
- $value = "'" . mysql_real_escape_string($value) . "'";
- }
- return $value;
- }
- $server = mysql_connect($host, $user, $password);
- $connection = mysql_select_db($database, $server);
- if(isset($_GET['id'])) {
- $query = mysql_query("SELECT * FROM tags WHERE lany_id=".sqlnez($_GET['id'])."");
- $json = "({ tags:[";
- for ($x = 0, $numrows = mysql_num_rows($query); $x < $numrows; $x++) {
- $row = mysql_fetch_assoc($query);
- $json .= "{tag:'" . $row["tag"] . "'}";
- if ($x < mysql_num_rows($query) -1)
- $json .= ",";
- else
- $json .= "]})";
- }
- }
- else {
- $query = mysql_query("SELECT * FROM tags GROUP BY tag") or die ("HIBA! Nem sikerült az SQL valamiért.");
- $json = "({ tags:[";
- for ($x = 0, $numrows = mysql_num_rows($query); $x < $numrows; $x++) {
- $row = mysql_fetch_assoc($query);
- $json .= "{tag:'" . $row["tag"] . "',count:'" . $row["count"] . "'}";
- if ($x < mysql_num_rows($query) -1)
- $json .= ",";
- else
- $json .= "]})";
- }
- }
- $response = $_GET["callback"] . $json;
- echo utf8_encode($response);
- mysql_close($server);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement