按优先级更改链接 - PHP / HTML
Changing links by priority - PHP / HTML
我目前正在做一个学校项目,感谢您的帮助。
HTML代码:
<a href="change-1.php">LINK 1</a>
<a href="change-2.php">LINK 2</a>
<a href="change-3.php">LINK 3</a>
现在,由于我对 PHP 还比较陌生,我需要了解从这里开始或哪些主题与我的解决方案相关。我已经在这里和 google 搜索了论坛,但不幸的是,没有找到任何符合我需要的东西。
我需要的是一个 PHP-代码,它包含 6 个 href Link 并且每个 Link 都有一个优先级。因此,每次有人在 html 文件上单击 "LINK 1" 时,他都会被定向到 PHP-文件 "change-1.php",其中六个 href Links 之一被激活。
PHP 代码 "change-1.php":
<?php
if (condition) {
echo "http://www.someotherwebsite-1.com";
}
elseif (condition) {
echo "http://www.someotherwebsite-2.com";
}
elseif (condition) {
echo "http://www.someotherwebsite-3.com";
}
elseif (condition) {
echo "http://www.someotherwebsite-4.com";
}
elseif (condition) {
echo "http://www.someotherwebsite-5.com";
}
elseif (condition) {
echo "http://www.someotherwebsite-6.com";
}
?>
也许这应该有所帮助
<a href="change.php?change=1">LINK 1</a>
<a href="change.php?change=2">LINK 2</a>
<a href="change.php?change=3">LINK 3</a>
只需创建一个 change.php
文件
//to get change
<?php
if ($_GET['change'] == 1) {
echo "http://www.someotherwebsite-1.com";
}
elseif ($_GET['change'] == 2) {
echo "http://www.someotherwebsite-2.com";
}
elseif ($_GET['change'] == 3) {
echo "http://www.someotherwebsite-3.com";
}
elseif ($_GET['change'] == 4) {
echo "http://www.someotherwebsite-4.com";
}
elseif ($_GET['change'] == 5) {
echo "http://www.someotherwebsite-5.com";
}
elseif ($_GET['change'] == 6) {
echo "http://www.someotherwebsite-6.com";
}
?>
现在这是基本思路。您可以随心所欲地操作数据。
希望你明白了。
我目前正在做一个学校项目,感谢您的帮助。
HTML代码:
<a href="change-1.php">LINK 1</a>
<a href="change-2.php">LINK 2</a>
<a href="change-3.php">LINK 3</a>
现在,由于我对 PHP 还比较陌生,我需要了解从这里开始或哪些主题与我的解决方案相关。我已经在这里和 google 搜索了论坛,但不幸的是,没有找到任何符合我需要的东西。
我需要的是一个 PHP-代码,它包含 6 个 href Link 并且每个 Link 都有一个优先级。因此,每次有人在 html 文件上单击 "LINK 1" 时,他都会被定向到 PHP-文件 "change-1.php",其中六个 href Links 之一被激活。
PHP 代码 "change-1.php":
<?php
if (condition) {
echo "http://www.someotherwebsite-1.com";
}
elseif (condition) {
echo "http://www.someotherwebsite-2.com";
}
elseif (condition) {
echo "http://www.someotherwebsite-3.com";
}
elseif (condition) {
echo "http://www.someotherwebsite-4.com";
}
elseif (condition) {
echo "http://www.someotherwebsite-5.com";
}
elseif (condition) {
echo "http://www.someotherwebsite-6.com";
}
?>
也许这应该有所帮助
<a href="change.php?change=1">LINK 1</a>
<a href="change.php?change=2">LINK 2</a>
<a href="change.php?change=3">LINK 3</a>
只需创建一个 change.php
文件
//to get change
<?php
if ($_GET['change'] == 1) {
echo "http://www.someotherwebsite-1.com";
}
elseif ($_GET['change'] == 2) {
echo "http://www.someotherwebsite-2.com";
}
elseif ($_GET['change'] == 3) {
echo "http://www.someotherwebsite-3.com";
}
elseif ($_GET['change'] == 4) {
echo "http://www.someotherwebsite-4.com";
}
elseif ($_GET['change'] == 5) {
echo "http://www.someotherwebsite-5.com";
}
elseif ($_GET['change'] == 6) {
echo "http://www.someotherwebsite-6.com";
}
?>
现在这是基本思路。您可以随心所欲地操作数据。
希望你明白了。