[英]A href link to PHP file in PHP echo doesn't work
I have created a table called menu and two of its columns are menu_option and menu_content. 我创建了一个名为menu的表,它的两列是menu_option和menu_content。 What I want to do is, after I click on a menu_option to go to a separate .php file i created, which is supposed to show in a div the menu_content.
我要做的是,在单击menu_option转到我创建的单独的.php文件后,该文件应该在div中显示menu_content。
I still haven't figured out why when I click on it, it tells me that the object cannot be found. 我仍然不知道为什么当我单击它时会告诉我找不到该对象。
<?php
$res=mysql_query("SELECT * FROM menu");
while($row=mysql_fetch_array($res)){
echo "<ul>";
echo "<li>";
echo "<a href=\"menucontent.php\">";
echo $row['menu_option'];
echo '</a>';
echo "</li>";
echo "</ul>";
}
?>
At first I thought this could work and in my menucontent.php I could use echo $row['menu_content']; 起初我认为这可以工作,并且在我的menucontent.php文件中可以使用echo $ row ['menu_content'];。 to print the proper menu content for the menu option.
为菜单选项打印正确的菜单内容。
I would really apreciate any suggestions. 我真的很喜欢任何建议。
I have figured it out. 我已经知道了。 Thank you all for the suggestions.
谢谢大家的建议。 I simply deleted the existing menucontent.php and created a new one.
我只是删除了现有的menucontent.php并创建了一个新菜单。 It worked.
有效。 I replaced the a href link with '' where $idaux = $row['menu_id'].
我将href链接替换为“,其中$ idaux = $ row ['menu_id']。 In my new file menuc.php i loop through the rows and when $row['menu_id'] === $_GET['id'] , i simply echo $row['menu_content'], which is what i wanted.
在我的新文件menuc.php中,我循环浏览各行,当$ row ['menu_id'] === $ _GET ['id']时,我只是呼应$ row ['menu_content'],这正是我想要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.