Link to home
Create AccountLog in
Avatar of melvint91
melvint91Flag for United States of America

asked on

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>";      
      }
Avatar of Gary
Gary
Flag of Ireland image

I would assume $row['member_id'] doesn't exist.
What error do you get?
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.
Avatar of melvint91

ASKER

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...
ASKER CERTIFIED SOLUTION
Avatar of melvint91
melvint91
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
I decided to try the change because I knew the $row['member_id'] was correct field in database.