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

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'].'');

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.