LastMitch
Industrious Poster
4,155 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45
@bradly.spicer
I think I probably reworded this wrong.
Basically I want the header AND page information to reflect whichever customer I choose in the URL.
reworded wrong?
You want Customer.php?customer_name="John" to be this Customer.php?id=John
Am I correct?
Then you will need to rewrite it in your URL and add a few lines in the .htaccess.
The link I provide explain to you how to write the URL like the one you can asking.
LastMitch
Industrious Poster
4,155 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45
You have to add a WHERE clause to the query:
// first check if a querystring exists at all (avoiding errors)
if(isset($_GET['customer_name'])) {
// escape the value form the url (security)
$customer_name = mysql_real_escape_string($_GET['customer_name']);
// then use the value in WHERE statement
$sql="SELECT id,customer_name FROM Customers WHERE customer_name='$customer_name'";
}
And consider using mysqli instead of mysql.
broj1
Nearly a Posting Virtuoso
1,211 posts since Jan 2011
Reputation Points: 167
Solved Threads: 164
Skill Endorsements: 13
@broj1
So it has nothing with rewriting with the URL? I'm just curious can you explain how this works. Maybe I got confused what he is asking. So by Selecting id, customer_name and using Where clause will automatically make the name appear without add or changing the URL?
LastMitch
Industrious Poster
4,155 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45
As far as I understood the question he wants to display data about a particular user. The user is defined in the querystring ?customer_name=John+Doe. So you can get cuustomer name from the $_GET array where variables from query string are stored. You have to use this info in the query to filter out the record with appropriate data.
Where the querystring comes from I do not know since it was not posted. It could be dropdown box or input box etc.
So it has nothing with rewriting with the URL?
I am not saying that. I haven't checked your proposal for solution. As far as I know rewriting the URL makes URLs look nicer, easier to bookmark, easier to get read by search engines etc.
broj1
Nearly a Posting Virtuoso
1,211 posts since Jan 2011
Reputation Points: 167
Solved Threads: 164
Skill Endorsements: 13
The url can't affect the SQL unless it has a where clause and the querystrng parameter is used in it. Rewriting has nothing to do with this. After all, rewriting is just prettifying exisiting domain and associated querystring
diafol
Keep Smiling
10,647 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,510
Skill Endorsements: 57
broj1
Nearly a Posting Virtuoso
1,211 posts since Jan 2011
Reputation Points: 167
Solved Threads: 164
Skill Endorsements: 13
Rewriting has nothing to do with this. After all, rewriting is just prettifying exisiting domain and associated querystring
Anyway the form should take care of that or urlencode php function.
OK, I didn't understand that's why I ask. Thanks it's good to know.
LastMitch
Industrious Poster
4,155 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45