douruyun8153 2015-09-07 18:53
浏览 29
已采纳

带GET的Php菜单

I have a switch menu so my pages are called into index.php and then loads the page content from whatever is on the file so I am having to only use the includes files once throughout - I am having an issue though with a link to in my case a single product page view. So the url will be appended with something like products_single.php?prod_id=46 But the way my menus are set it does not recognise this as a valid url as far as I can see?

Here is the function which creates the link:

function settings_layout($page_id) {

    switch($page_id) {

        default: 
            echo '<p class="red">Whoops! this page does not exist!</p>';
        case '':


        // PRODUCTS      
         case 'products_single':
            include_once("modules/products/products_single.php");
            break;           
       }
   }

To get to the page products_single that query lives in the build_prod_list() which basically just lists out the products from the products table. The name of the product is wrapped in a link a href="index.php?page=products_single?prod_id='.$row["prod_id"].'"> '.$row["prod_name"]. '</a> Where this is sat in a while loop inside of the build_prod_list() function.

So as a function I which I am calling build_prods_single() grabs the product data from the database and shows it on products_single.php

so when the link is clicked the url is index.php?page=products_single?prod_id=46 but shows the error 'Whoops! this page does not exist!'

  • 写回答

1条回答 默认 最新

  • dousi5501 2015-09-07 19:01
    关注

    You forgot to add & ampersand between products_single and prod_id

    <a href="index.php?page=products_single&prod_id='.$row["prod_id"].'"> '.$row["prod_name"]. '</a>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 对于这个复杂问题的解释说明
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败