Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
CREATE TABLE IF NOT EXISTS `games` (
`id` bigint(255) NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
`url`text NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=1;
<?
$username = "username";
$pass = "password";
$host = "localhost";
$db = "database";
$conn = mysql_connect($host, $username, $pass);
mysql_select_db($db, $conn);
?>
<form method="post" action="">
Име на играта <br /><input name="name" type="text" size="30" /><br />
URL до играта <br /><input name="url" type="text" size="30" />
<br /><br />
<input name="submit" type="submit" value="Добави" />
</form>
<?php
include("config.php");
if($_POST['submit'])
{
$name = htmlspecialchars(addslashes($_POST['name']));
$url = htmlspecialchars(addslashes($_POST['url']));
if(empty($name) || empty($url))
{
echo 'Има празно поле';
}
else
{
$sql = mysql_query("INSERT into `games` (`id`,`name`,`url`) VALUES ('','$name','$url')") or die(mysql_error());
if($sql) { echo "Играта е добавена"; }
}
}
?>
<?php
include("config.php");
$sql = mysql_query("SELECT * from `games`");
while($row = mysql_fetch_array($sql)) {
$id = $row['id'];
$name = $row['name'];
echo '<a href="playgame.php?id='.$id.'" />'.$name.'</a><br />';
}
?>
<?php
include("config.php");
$id = htmlspecialchars($_GET['id']);
$sql = mysql_query("SELECT * from `games` WHERE `id`='$id'");
while($row = mysql_fetch_array($sql)) {
$name = $row['name'];
$url = $row['url'];
echo '<h1>'.$name.'</h1><br /><embed src="'.$url.'" width="480" height="400">';
}
?>