Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PHP foreach loop to incorporate link

Posted on 2013-05-14
5
Medium Priority
?
303 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

660 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