Jump to content

Howto extract rows from a text type?


scottrohe

Recommended Posts

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!
Link to comment
Share on other sites

.. 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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.