Solved

PHP foreach loop to incorporate link

Posted on 2013-05-14
5
297 Views
Last Modified: 2013-05-19
I'm having a problem with my php link operating correctly... I've listed below two code examples... one works correctly when I don't include "member_id" pulled from database within url link.... when I include "member_id" within url link, my page is not shown:

This link doesn't work:
foreach ($rowset as $row) {
            echo "<tr><td>" . htmlspecialchars($row['lastName']) . "</td><td>" . htmlspecialchars($row['firstName']) . "</td><td>" . htmlspecialchars($row['businessName']) . "</td><td>" . "<a href='index.php?page=admin-display-user&id=" . $row['member_id'] . "'>view</a></td></tr>";      
      }

This link does work:
foreach ($rowset as $row) {
            echo "<tr><td>" . htmlspecialchars($row['lastName']) . "</td><td>" . htmlspecialchars($row['firstName']) . "</td><td>" . htmlspecialchars($row['businessName']) . "</td><td>" . "<a href='index.php?page=admin-display-user&id='>view</a></td></tr>";      
      }
0
Comment
Question by:melvint91
  • 3
5 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39166468
I would assume $row['member_id'] doesn't exist.
What error do you get?
0
 
LVL 6

Expert Comment

by:nickinthooz
ID: 39166713
That has got to be the issue, there is nothing wrong with the format of the code.  Double check the name of your member_id field and make sure it's in the table you're pulling from.
0
 

Author Comment

by:melvint91
ID: 39166944
row [member_id] does exist because the "id #" is displayed when hovering over link... I'm not getting an error, a blank page is opening but without the content showing...
0
 

Accepted Solution

by:
melvint91 earned 0 total points
ID: 39166947
I resolved the issue. . .I changed the following to :

page=admin-display-user&id=" . $row['member_id']

changed to:

page=admin-display-user&member_id=" . $row['member_id']
0
 

Author Closing Comment

by:melvint91
ID: 39178306
I decided to try the change because I knew the $row['member_id'] was correct field in database.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now