PHP foreach loop to incorporate link

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>";      
      }
melvint91Asked:
Who is Participating?
 
melvint91Connect With a Mentor Author Commented:
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
 
GaryCommented:
I would assume $row['member_id'] doesn't exist.
What error do you get?
0
 
nickinthoozCommented:
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
 
melvint91Author Commented:
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
 
melvint91Author Commented:
I decided to try the change because I knew the $row['member_id'] was correct field in database.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.