我有一个HTML表单字段$_POST["url"],其中包含一些URL字符串作为值.示例值为:
https://example.com/test/1234?email=xyz@test.com https://example.com/test/1234?basic=2&email=xyz2@test.com https://example.com/test/1234?email=xyz3@test.com https://example.com/test/1234?email=xyz4@test.com&testin=123 https://example.com/test/the-page-here/1234?someurl=key&email=xyz5@test.com
等等
如何email从这些URL /值中仅获取参数?
请注意,我没有从浏览器地址栏中获取这些字符串.
我想从URL获取值,以便通过ID从数据库中选择数据.我想要id的价值.
例如,如果我打开,www.example.com/index.php?id=12
我想获得数据库中id = 12的值.
如果我www.example.com/index.php?id=7
在数据库中打开获取其id = 7的值,依此类推.
我有一些代码:
$results = mysql_query("SELECT * FROM next WHERE id=$id");
while ($row = mysql_fetch_array($results))
{
$url = $row['url'];
echo $url;
}
Run Code Online (Sandbox Code Playgroud) 我需要在容器中加载一个文件,但是使用一个参数 - 首先从数据库中获取一些数据:
$('#story').load('test.php');
Run Code Online (Sandbox Code Playgroud)
test.php的
$st = $db->query("select * from users where id = " . $id);
... processing variables... load the finished content
Run Code Online (Sandbox Code Playgroud)
在这里,我需要$id从客户端.可能吗?
如果 URL 是https://www.mohsin.com?main=17&street=71,那么获取“main”和“street”值的 PHP 代码是什么?
我期待用 PHP 编写的代码行。
提前致谢