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
pedrotuga
Forum Contributor
Posts: 249 Joined: Tue Dec 13, 2005 11:08 pm
Post
by pedrotuga » Wed Jun 14, 2006 1:35 pm
Code: Select all
int $half=mysql_num_rows($result)/2;
can anybody help me please... i want to use the $half so i can know when am in the midle of the output so i can insert another line on a html table...
the above code generates this error...
Code: Select all
Parse error: parse error, unexpected T_VARIABLE in...
the manual doesnt say so much about variable types
thx in advance
Roja
Tutorials Group
Posts: 2692 Joined: Sun Jan 04, 2004 10:30 pm
Post
by Roja » Wed Jun 14, 2006 1:42 pm
You were VERY close.
Code: Select all
(int) $half=mysql_num_rows($result)/2;
(int)
casts the variable to an int.
bdlang
Forum Contributor
Posts: 395 Joined: Tue May 16, 2006 8:46 pm
Location: Ventura, CA US
Post
by bdlang » Wed Jun 14, 2006 1:43 pm
pedrotuga wrote:
the manual doesnt say so much about variable types
PHP Manual:
Types
PHP Manual:
Integers
PHP Manual:
Type Juggling
You can cast type using (int), e.g.
Code: Select all
$half=mysql_num_rows($result);
$output= (int) $half / 2;
pedrotuga
Forum Contributor
Posts: 249 Joined: Tue Dec 13, 2005 11:08 pm
Post
by pedrotuga » Wed Jun 14, 2006 1:56 pm
thank you everybody
i still have some C habits
bokehman
Forum Regular
Posts: 509 Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)
Post
by bokehman » Wed Jun 14, 2006 5:21 pm
What are you going to do if mysql reurns an odd number?