hi dought in the coding base

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

Post Reply
kuttus
Forum Newbie
Posts: 15
Joined: Sun Jun 21, 2009 3:48 am

hi dought in the coding base

Post 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
iamngk
Forum Commoner
Posts: 50
Joined: Mon Jun 29, 2009 2:20 am

Re: hi dought in the coding base

Post by iamngk »

you can use mysql_insert_id function... please refer the manual : http://us.php.net/manual/en/function.my ... ert-id.php
kuttus
Forum Newbie
Posts: 15
Joined: Sun Jun 21, 2009 3:48 am

Re: hi dought in the coding base

Post 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
iamngk
Forum Commoner
Posts: 50
Joined: Mon Jun 29, 2009 2:20 am

Re: hi dought in the coding base

Post 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...
Post Reply