Jump to content


Photo

incrementation help


  • Please log in to reply
5 replies to this topic

#1 visuelz

visuelz
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 07 April 2003 - 10:16 PM

my auto_increment keeps increasing from my old entry after i deleted it. It\'s like 1 then 2 then 3. Then i decide i want to delete 3. After i delete it and i remake it i get it as 4. I read somewhere that you can make it something like hit=hit+1 but im not sure how to do it on my table or page. can someone help me?

#2 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 07 April 2003 - 10:26 PM

Humm! thats the problme with auto increment

Now the best way would be to do a numb_row_count and get the total rows and just add a + 1 to that.

$numrows = mysql_num_rows($result);

Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#3 visuelz

visuelz
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 07 April 2003 - 10:29 PM

thanks a lot for the advice. hmmm say i want to display. this is match number 1 and the next data i enter i want to say this is match number 2 without affecting the number for match number 1. what can i do? i know what you just gave me could affect all the numbers.

#4 DocSeuss

DocSeuss
  • Members
  • PipPipPip
  • Advanced Member
  • 73 posts
  • LocationTexas, USA

Posted 08 April 2003 - 03:18 AM

Chance are your going thru a loop, just create your own variable. Start the variable a 1.
$matches = 1;
Substitute the following in your loop:
echo \'This is matche Number \' . $matches;
Then add inside your loop.
$matches++;
"Unlimited budget? Great, for $5,000,0000 we will run your ad banner for one year"  ----Rasmus Lerdorf

#5 visuelz

visuelz
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 09 April 2003 - 04:07 AM

so would it be like
for($matches=0;$matches<=score.length();$matches++)

echo \'Match Number\' $matches;
sorry if it\'s wrong. I\'m using c++ method of doing this. heh

#6 DocSeuss

DocSeuss
  • Members
  • PipPipPip
  • Advanced Member
  • 73 posts
  • LocationTexas, USA

Posted 09 April 2003 - 04:28 AM

pretty much only I would start matches at 1 instead of 0, makes more sense to the non-programmers who will view the output.

I\'m not sure what score.length is but you would want the loop to repeat as many times as you had matches, your going through a loop anyway to echo out your DB results.

$matchnum = 1;
while ($myRow = mysql_fetch_array)) {
echo \"Match $matchnum -- $myRow[opponent] $myRow[ourscore] $myRow[thierscore]<BR>\";
$matchnum++;
}
"Unlimited budget? Great, for $5,000,0000 we will run your ad banner for one year"  ----Rasmus Lerdorf




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users