Page 1 of 1

hi dought in the coding base

Posted: Mon Jul 06, 2009 2:13 am
by kuttus
how we can fetch the data from the database by automatically incrementing the id

$result = mysql_query("SELECT title FROM optionaltext WHERE id= 1");

i need to increment the id value automatically in my program hw pls help me

Re: hi dought in the coding base

Posted: Mon Jul 06, 2009 3:43 am
by iamngk
you can use mysql_insert_id function... please refer the manual : http://us.php.net/manual/en/function.my ... ert-id.php

Re: hi dought in the coding base

Posted: Mon Jul 06, 2009 4:18 am
by kuttus
i need to increment the number of fetching id means the 1st user will see the data stored in text stored in the id 1 and the other user should see the text containing in the other id pls think and help me its a form like captcha i am telling

Re: hi dought in the coding base

Posted: Mon Jul 06, 2009 5:07 am
by iamngk
i hope you have to work in following scenario

1. You have to maintain separate table with one column for count. Initially it should have 0 as value.
2. First you should fetch the count value and store it in $count.
3. Then you need to write the query like below.
mysql_query("SELECT title FROM optionaltext order by id asc limit ".$count.",1")
4. update count table with following query.
update tbl_count set count = (count+1);
5. In certain moment you can reset the count table to start from beginning...