cofey12681 Posted November 21, 2008 Share Posted November 21, 2008 Hello, what I'm trying to do is make a very basic shopping cart that interacts with mysql. Right now I have some code that will spit out a column, category in an echo statement with <li>. What I need though is to properly concatenate this for a query string... What I mean is, the user clicks the link, they get brought to the respective page that selects all records for that particular passed in category. This is what I have, and I have not been able to figure it out, sometimes I see nothing with no eror, but many times I'll get parse erros referring to ". echo " "<li> . "<a href=" . $row["category"] . " . ">" something here..., maybe $row['category"] again... . "</a>" . "</li>" . "; Can someone please educate me on the right way to do this.... thanks.And then once that's done, How would I read the category on page load? I am used to .net but not php. Link to comment https://forums.phpfreaks.com/topic/133680-proper-concatenaton-in-href-for-querystring/ Share on other sites More sharing options...
IchBin Posted November 21, 2008 Share Posted November 21, 2008 Well it will boil down to personal preference with using single or double quotes. But I prefer the single quote method. This should be properly formatted. echo '<li><a href="' . $row["category"] . '">something here..., maybe '.$row['category"].' again...</a></li>"; Link to comment https://forums.phpfreaks.com/topic/133680-proper-concatenaton-in-href-for-querystring/#findComment-695580 Share on other sites More sharing options...
xangelo Posted November 21, 2008 Share Posted November 21, 2008 The error you are receiving seems to occur because of the way you are performing the concatenation. echo "<li> . "<a href=" . $row["category"] . "> something here..., maybe $row['category"] again... </a></li>"; You only need to do the concatenation when you are trying to insert bits of php. So </a>"."</li> is complete unnecessary. However, like IchBin said, it's easier to to separate which quotes you use. Keep single quotes to php and double quotes to html. Link to comment https://forums.phpfreaks.com/topic/133680-proper-concatenaton-in-href-for-querystring/#findComment-695646 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.