Jump to content

how to increment value and add a another value?


Monkuar

Recommended Posts

$db->query('UPDATE users set actions=actions+1|'.time().' where id = '.$pun_user['id'].'');

 

im trying to do set actions=actions+1, then put a | atfter +1ing it, then add my time stamp to it so I can explode it later.

 

so it will look like this

 

2|unixtimestamphere

 

 

how would i achieve this? or do I need to make another seperate row? seems dumb

Link to comment
Share on other sites

as thorp said, each piece of information should be stored in it's own field, but if you want to do it the other way you could use something like the following - just dont come asking how to perform lookups on your data or how to get it back out in a meaningfull form :P

 

$db->query('UPDATE users set actions=CONCAT((SELECT actions+1),"|","'.time().'") where id = '.$pun_user['id'].'');

Link to comment
Share on other sites

Each column is designed to hold one value in a database. You need a new column.

 

Hey, I'll use Muddy_funster's way, just because Im not going to be selecting any data from this field, just displaying it, so holding the data is fine for what I am doing, but I understand you and where you're coming from, it's prob bad to store values in explode if they're going to have to be selected later, but as of right now it's just a info it's fine and will never have to be selected again

 

I'll use muddy_funster's way for this,

 

didn't know concat did that, will look into concat's function @ mysql and learn some more goodies, Thanks Muddy

 

Topic Solved

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.