Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 简单URL路由_Php_Html_Mysql - Fatal编程技术网

Php 简单URL路由

Php 简单URL路由,php,html,mysql,Php,Html,Mysql,在我的索引页上,我列出了数据库中的所有帖子 <?php //include functions include 'functions.php'; //READ $stmt = $pdo->prepare('SELECT * FROM post'); //query $stmt->execute(); $contacts = $stmt->fetchAll(PDO::FETCH_ASSOC); ?> HTML 当我点击一篇文章的图

在我的索引页上,我列出了数据库中的所有帖子

<?php

//include functions
include 'functions.php';

//READ
$stmt = $pdo->prepare('SELECT * FROM post');
            //query
$stmt->execute();
$contacts = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>

HTML


当我点击一篇文章的图片时,我希望被重定向到一个页面(read.php),在那里我可以阅读该文章

<a class="links" href="read.php?id=<?php echo $_GET['id] ?>">
    <img src="IMG/Immagine 1.png" alt="immagine 1"></a>

当我点击图片时,我实际上被重定向到read.php,但是URL没有打印ID,在页面中我看不到关于标题、类别和文本的信息。
我做错了什么?

什么是$id你在哪里设置它不应该是$contact['id']不要用“noob问题”来说话。我们都有问题。这将是
href=“read.php?id=”
,然后显然在read.php中使用
$\u GET['id']
来按id进行查询
<a class="links" href="read.php?id=<?php echo $_GET['id] ?>">
    <img src="IMG/Immagine 1.png" alt="immagine 1"></a>