简体   繁体   English

为什么PHP模板无法从mySQL数据库检索正确的数据?

[英]Why is PHP template not retrieving correct data from mySQL database?

Okay, so I have three pages: 好的,所以我有三页:

  1. index.php index.php
  2. form.php form.php
  3. posting.php posting.php

It's basically a jobs posting site, where users submit data via the form (form.php), that form data gets put in the database, then I pull that data out into a table on the home page (index.php). 从本质上讲,这是一个工作发布站点,用户通过表单(form.php)提交数据,然后将表单数据放入数据库中,然后将这些数据提取到主页(index.php)的表中。 Then, if you click on one of the rows in the table, you get taken to the job posting itself (posting.php). 然后,如果单击表中的行之一,您将进入作业发布本身(posting.php)。 It's a lot like a message board. 这很像留言板。 You can see the live version here: You can see the live version at http://onepotcooking.com/students/mattsellers/final_project/final_project.php . 您可以在此处看到实时版本:您可以在http://onepotcooking.com/students/mattsellers/final_project/final_project.php上看到实时版本。

So the problem I'm having is that the job title links in the table are not leading to their corresponding job postings. 因此,我遇到的问题是表格中的职位标题链接未导致其相应的职位发布。 Every single job title link in the table leads to the same row in the database...that is, the row with id = 1. You'll see that if you click on a job title, the URLs are dynamic...but it just seems that it's not pulling the correct data. 表中的每个单个职位标题链接都指向数据库中的同一行...即id = 1的行。您会看到,如果单击职位,URL是动态的...但是似乎它没有提取正确的数据。 I had it working the other day, but for some reason it's not anymore...it's a bummer. 前几天我让它工作了,但由于某种原因,它不再存在了。

The code I have around the job title links is: 我在职称链接上拥有的代码是:

<div class='job_title'>
    <span class='job_title_style'>
        <a href="posting.php?id=<?php echo $row['id']; ?>"><?php echo $row['job_title'];
        </a>
    </span>
</div>

Shouldn't that do it? 那不是吗? Any help you could give me would be greatly appreciated. 您能给我的任何帮助将不胜感激。

Thanks! 谢谢!

-Matt -马特

Matt, just thinking. 马特,只是在想。 As far as I understood, the link to the offer is put in MySQL also while form is submitted, so you may define the ID part of the link as variable there. 据我了解,在提交表单时,商品的链接也放置在MySQL中,因此您可以在其中将链接的ID部分定义为变量。

If you do not have a column for the URL in MySQL table, and no query is runing on index.php, just posting the code echo $row['id'] will not give you the id of the offer. 如果您在MySQL表中没有用于URL的列,并且没有在index.php上运行查询,则仅发布代码echo $row['id']不会为您提供优惠的ID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM