Hello,
I am building a online store with PHP and MYSQL. I have a navigation bar that in PHP, spits out categories in a link and my goal is, when a user clicks the link, that the correct items will be displayed on the target page.
I'm having trouble with proper concatenation though.
I don't have my code with me, but what I'm basically entering is... echo " "<li>" . "<a href=" . $row["category"] . " ">" . "</a>" . "</li>" " ;
I'm not sure what I'm doing wrong, I've been playing with this forever, I've had funny things happen where I don't even close off the href tag and it still appears as a link. Can someone tell me the proper way to code this?
Also, I want this category to get passed into a query string, so when the user clicks the link for cat X, all items in X will appear. I'm used to using.net where on page load I can call the Sqldatasource and write teh select statement. How is this achieved in php...
Thank you.
String concatenation and query string from link
Moderator: General Moderators
-
cofey12681
- Forum Newbie
- Posts: 1
- Joined: Fri Nov 21, 2008 7:58 am
Re: String concatenation and query string from link
Code: Select all
echo "<li><a href=\"mypage.php?cat_id=".$row["cat_id"]."\">".$row["category"]."</a></li>\n";
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: String concatenation and query string from link
Don't forget, with echo you don't need to concatenat, but can pass a series of arguments
Code: Select all
echo "<li>" , "<a href=" , $row["category"] , ">" , "</a>" , "</li>" ;