Number rows help (MySQL)
#1

I have one realy big problem! I can't find the number of rows, because I want to create one more row (a house)! Firstly when I start the server I can create one house and it is saving perfect, but when I try to create one more I have to restart the server again, because when I'm trying to create second house, it is not saving! The problem is because the rows are counted only one time (but in the script I'm counting them always when I want to create the ouse)
Here is my creating house command: (I'm testing the number, when I have created one house it works correct, but when I'm trying to create another one it doesn't counts) Please help me guys!)
PHP код:
mysql_tquery(zMySQL"SELECT * FROM `houses` ORDER BY `ID` ASC");
new 
cache_num_rows()+1;
printf("%d"h); 
Reply
#2

try
Код:
cache_get_row_count(destination);
and whenever you are creating a new house, try to make a variable which will be AUTO_INCREMENT in the mysql table, so that you dont need to count rows whenever you are creating a new house.
Reply
#3

Still the problem with this couting, whenever I restart the server I can create only one house, that is saving! And yes I'm saving the house inside the command!
Reply
#4

Any ideas?
Reply
#5

Код:
mysql_query(zMySQL, "SELECT * FROM `houses` ORDER BY `ID` ASC",true); 
new h = cache_num_rows()+1;
printf("%d", h);
However, the correct way to do this is to create an AUTO_INCREMENT field or you will have ID problems.
Reply
#6

WOWWW HOW YOU FIXED IT?? GOOD JOB!!!!!!
Thanks a lot +1 REP!
And can you tell me what is AUTO_INCREAMENT?
Reply
#7

Quote:
Originally Posted by Kraeror
Посмотреть сообщение
WOWWW HOW YOU FIXED IT?? GOOD JOB!!!!!!
Thanks a lot +1 REP!
And can you tell me what is AUTO_INCREAMENT?
Basically, it's an unique id that keeps increasing when you add a row. Even if you delete some rows it will always increase, that's why it's unique
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)