scottrohe Posted July 29, 2006 Share Posted July 29, 2006 Ok so ive been tryin to figure it out all night and i cant. Im trying to extract from a "Text" value box in mysql, but when it comes out it comes like.. blah, blah2, blah3.. or however i enter it into the box. i want it to come out so i can make each blah have an href.. is it possible or what would i do to do something like it? the purpose for it is for a "favorites" system, where the user clicks add to favorites, it simply adds the products ID to the text box "favorites" in mysql..hopefuly i explained clearly enough. ive tried stuff like;[code] function displayFavorites(){ $q = "SELECT * FROM ".TBL_USERS." ORDER BY favorites"; $result = mysql_query($q); while($rows=mysql_fetch_array($result)) { $this->display_favorites = $rows['favorites'].", "; }[/code]and anything else i could think of.. lol. help please! Quote Link to comment https://forums.phpfreaks.com/topic/15943-howto-extract-rows-from-a-text-type/ Share on other sites More sharing options...
AndyB Posted July 29, 2006 Share Posted July 29, 2006 .. and where would each blah get it's href from???It might be much better database design to have each blah AND its href as a single row in the database, rather than having to retrieve and post-process the field contents. If instead (and it's a weaker solution) you want to have a single database record with multiple pieces of data like blah, blah1, blah2 then you can separate lines by splitting the parts into array elements.[code]$blahs = explode("," $blah_from_database); // produces array of all blah elements[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15943-howto-extract-rows-from-a-text-type/#findComment-65513 Share on other sites More sharing options...
fenway Posted July 29, 2006 Share Posted July 29, 2006 Yeah, definitely stay away from storing lists in single database columns, unless you never need to edit them. Quote Link to comment https://forums.phpfreaks.com/topic/15943-howto-extract-rows-from-a-text-type/#findComment-65515 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.