Jump to content

Archived

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

dark dude

Inputting Two Variables in One field

Recommended Posts

[quote]
$num = mysql_numrows($result);

$UpDateNum = $num + 1;

$query="INSERT INTO Planets VALUES ('','$Galaxy','$System','$Planet','$Continent','',[color=red][b]'Colony'[/b][/color],'$Username','0','500','10','250','100','Colony11','1','','','','','','','','','$ip',CURRENT_TIMESTAMP(NOW()))";
mysql_query($query);[/quote]

Focus on the bit in bold red...

I want to be able to make it something like:

'Colony(whatever $UpDateNum is)'

But I cant find how to do it. I've tried 'Colony'.$UpDateNum.'' but that doesnt work...

Please help? ???

Share this post


Link to post
Share on other sites
You would have to do this:

[code]
$query = "INSERT INTO Planets(field, field, Colony) VALUES('$field','$field','$Colony$UpDateNum')";
[/code]

Share this post


Link to post
Share on other sites
Putting more than one value in a field is easy; it's getting them out separately that's the problem. Are you [b]absolutely certain[/b] that that's what you want to do?  One more field in your database table is pretty cheap.

Share this post


Link to post
Share on other sites
If you must have them in one field, you may want to consider separating them by something. Then when you retrieve the data you can explode it. That would make things easier.

Share this post


Link to post
Share on other sites
[quote author=AndyB link=topic=107538.msg431607#msg431607 date=1157896935]
Putting more than one value in a field is easy; it's getting them out separately that's the problem. Are you [b]absolutely certain[/b] that that's what you want to do?  One more field in your database table is pretty cheap.
[/quote]

Yeah, I just want the two variables to merge :P

Because my finding system finds "Colonies" by the number after it.

The "UpDateNum" variable holds the number that's to go after the name "Colony".

So, if there are already 4 colonies, UpDateNum will equal 5, and it will input into the database "Colony5"...

Share this post


Link to post
Share on other sites
[quote author=dark dude link=topic=107538.msg431620#msg431620 date=1157897885]
Yeah, I just want the two variables to merge :P

Because my finding system finds "Colonies" by the number after it.
[/quote]

There are no numbers in Colony5 or Colony23 - those are strings.

Share this post


Link to post
Share on other sites

×

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.