登录 | 注册 | FAQ
Anonymous

Displaying names from a db,then linking to another page

+ 发表回复

2 篇帖子 分页: 1 / 1


Displaying names from a db,then linking to another page

smutolo » 周三 4月 30, 2014 7:27 am

Hello everyone,
Am using the code in http://html.net/tutorials/php/lesson20.php example 3 ( Adress book) to retrieve names of registered website users then linking them to their profile pages on the website.

The website is http://www.kenyaschoolsdownloads.com. What I want is a listing of the users then linking them to their page on the website like http://www.kenyaschoolsdownloads.com/view_profile.php?id=1

Am tring to accomplish this by changing
代码: 全选
   // Create a link to person.php with the id-value in the URL
      $strLink = "<a href = 'person.php?id = " . $row['id'] . "'>" . $strNavn . "</a>";

       // List link
      echo "<li>" . $strLink . "</li>";

     }

in example 3 to

代码: 全选
   // Create a link to http://www.kenyaschoolsdownloads.com/view_profile.php with the id-value in the URL
      $strLink = "<a href = 'http://www.kenyaschoolsdownloads.com/view_profile.php?id = " . $row['userid'] . "'>" . $strNavn . "</a>";

       // List link
      echo "<li>" . $strLink . "</li>";

     }


However, what am getting is a blank list like this http://kenyaschoolsdownloads.com/members2.php

The query is retrieving the username and email. When I remove

代码: 全选
// Create a link to person.php with the id-value in the URL
      $strLink = "<a href = 'http://www.kenyaschoolsdownloads.com/view_profile.php?id = " . $row['userid'] . "'>" . $strNavn . "</a>";


its retrieving the username and emails fine as you can see http://kenyaschoolsdownloads.com/members.php

What is wrong with the code to create the link?

Thanks.
头像

smutolo

  • 帖子: 14
  • 注册: 周六 4月 19, 2014 7:49 pm

Re: Displaying names from a db,then linking to another page

smutolo » 周四 5月 01, 2014 11:35 am

I resolved it. The error was Undefined variable $strNavn which I changed to $strName
头像

smutolo

  • 帖子: 14
  • 注册: 周六 4月 19, 2014 7:49 pm


+ 发表回复

分页: 1 / 1