PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
C_Calav
Forum Contributor
Posts: 395 Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand
Post
by C_Calav » Mon Jan 24, 2005 5:07 pm
ah that looks like what i want!
thanx for the help!
timvw
DevNet Master
Posts: 4897 Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium
Post
by timvw » Mon Jan 24, 2005 5:37 pm
isn't that the same as...
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Jan 24, 2005 5:41 pm
yes. I was assuming he'll have other things in there.. eventually
C_Calav
Forum Contributor
Posts: 395 Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand
Post
by C_Calav » Mon Jan 24, 2005 8:11 pm
hi, one more question..
my q_id wont be auto_increment will it?
is there a way to add in 1, then 2, then 3 keep adding one?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Jan 24, 2005 8:22 pm
no on auto_inc
once you know the value needed, you can use an UPDATE query
C_Calav
Forum Contributor
Posts: 395 Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand
Post
by C_Calav » Mon Jan 24, 2005 9:34 pm
i dont have to use a update do i?
i want to insert a question, that will be q_no=1
then insert another question, that will be q_no=2
then stop.
the come back and insert another question, that will be q_no=3
how can i do that kind of insert?
thanx
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Jan 24, 2005 9:36 pm
I have no idea why I said update... I meant insert.. I'm losing my mind today, I think.
.. not a news flash to some of you..
pretty much, you have to do a select to see what the current highest value is..
C_Calav
Forum Contributor
Posts: 395 Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand
Post
by C_Calav » Mon Jan 24, 2005 9:59 pm
cool thats what i thought, i know as much as what you just said.
im just stuck at inserting one more value at a time.
what would my insert be?
thanx feyd
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Jan 24, 2005 10:06 pm
just a standard insert:
Code: Select all
INSERT INTO table (s_id, q_no, question) VALUES('3','5','How do I lop off someone''s head?')provided your s_id is 3 and the next q_no is 5..
C_Calav
Forum Contributor
Posts: 395 Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand
Post
by C_Calav » Tue Jan 25, 2005 12:04 am
thanx feyd,
will i have to keep adding 1 all the time
for example
query=SELECT g_id FROM table WHERE s_id = $s_id ORDER BY g_id DESC LIMIT 1
query = query + 1
then insert?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Jan 25, 2005 12:15 am
that's how counter typically works..