class Controller
{
// code....
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// сюда-бы проверку через фильтра $_POST["str"] прогнать...
setcookie("str", $_POST["str"], time() + 9999999);
$_COOKIE["str"] = $_POST["str"];
header("Location:/" . $_POST["str"] . '/');
}
header('Content-type:text/html; charset=UTF-8');
ob_start();
class Viber
{
private $url_api = "https://chatapi.viber.com/pa/";
private $token = "";
public function message_post
(
$from, // ID администратора Public Account.
array $sender, // Данные отправителя.
$text // Текст.
)
{
$data['from'] = $from;
$data['sender'] = $sender;
$data['type'] = 'text';
$data['text'] = $text;
return $this->call_api('post', $data);
}
private function call_api($method, $data)
{
$url = $this->url_api.$method;
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\nX-Viber-Auth-Token: ".$this->token."\r\n",
'method' => 'POST',
'content' => json_encode($data)
)
);
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
return json_decode($response);
}
}
$Viber = new Viber();
$Viber->message_post(
'01234567890A=',
[
'name' => 'Admin', // Имя отправителя. Максимум символов 28.
'avatar' => 'http://avatar.example.com' // Ссылка на аватарку. Максимальный размер 100кб.
],
'Test'
);
$arr = array (
1 => '{"id":1,"company_name":null,"v":"1232","description":"dfg","name":"ghdg","money":"567","Preview_image":"123"}',
2 => '{"id":2,"company_name":null,"v":"1232","description":"dfg","name":"ghdg","money":"567","Preview_image":"123"}',
3 => '{"id":3,"company_name":null,"v":"1232","description":"dfg","name":"ghdg","money":"12","Preview_image":"123"}');
foreach ($arr as $v) {
# code...
list($id, $company_name,$v) = explode(',', $v);
//echo $id,'<br>';
$company_name = explode(':',$company_name);
$v = explode(':',$v);
echo $company_name[1];
echo $v[1],'<br>';
echo "===<br>";
}
<a href="index.php?cat=1">
<a href="index.php?cat=2">
<a href="index.php?cat=3">
$id_cat = $_GET['cat']; // сюда попадет id категории предположим цыфра 3
// делаем запрос
// Вывести все из таблице videos где id = 3 ну и сортировка ORDER BY `id` DESC LIMIT 5
$sql = "SELECT * FROM `videos` WHERE id=$id_cat ORDER BY `id` DESC LIMIT 5";
$videos = mysqli_query($connection, $sql);