help please
Moderator: General Moderators
help please
hello,
can anyone help me to resolve this exercise:
"Do a PHP page with a column (named od) in a chart (named numbers) in a database (named MR) with all the od numbers between 0 ro 1000, except the number 501."
pleeease help me
thank you
can anyone help me to resolve this exercise:
"Do a PHP page with a column (named od) in a chart (named numbers) in a database (named MR) with all the od numbers between 0 ro 1000, except the number 501."
pleeease help me
thank you
Re: help please
This some sort of assignment? I wouldn't mind giving a hand... though it is extremely simple. Post some code so we can see what you've done so far and help out.
-
peterjwest
- Forum Commoner
- Posts: 63
- Joined: Tue Aug 04, 2009 1:06 pm
Re: help please
Here you are:
If you'd like help, please at least try it first and post what you've managed so far. Also spend some time checking your spelling and grammar.
And you should know that 'odd' has two d's.
Code: Select all
Numbers
<table border="1">
<tr>
<th>od</th>
</tr>
<tr>
<td>all the od numbers between 0 ro 1000, except the number 501</td>
</tr>
</table>And you should know that 'odd' has two d's.
Re: help please
lol I like how you built the table verbatim.. that's hilariouspeterjwest wrote:Here you are:
If you'd like help, please at least try it first and post what you've managed so far. Also spend some time checking your spelling and grammar.Code: Select all
Numbers <table border="1"> <tr> <th>od</th> </tr> <tr> <td>all the od numbers between 0 ro 1000, except the number 501</td> </tr> </table>
And you should know that 'odd' has two d's.
Re: help please
As stated above, you should really give it a try, before handing the problem to someone else.
Though, due to the simplicity of creating a table, I've written a small little script for you. I hope this is what you were looking for:
Please note that $x&1 performs better (read faster) than $x%2.
(This is because $x&1 performs a simple binary comparison, while $x%2 performs a division, giving you the remainder.)
Though, due to the simplicity of creating a table, I've written a small little script for you. I hope this is what you were looking for:
Code: Select all
<table>
<tr><th>Numbers</th></tr>
<?php
for($x=1;$x<1000;$x++){
if($x & 1 && $x != 501)
echo "<tr><td>$x</td></tr>\n";
}
?>
</table>(This is because $x&1 performs a simple binary comparison, while $x%2 performs a division, giving you the remainder.)
Re: help please
I don't necessarily agree with writing scripts for others. I'd rather them learn how to stand on their own two feet. But to each their own I suppose.
Re: help please
Mirge: If you read my post, you might have noticed that i agree with you 
Re: help please
I did read your post... you wrote the scriptricehigh wrote: Mirge: If you read my post, you might have noticed that i agree with you
Re: help please
I'm with you, Mirge. I spent 10 years teaching computer classes in college, and I like to think that I understand and sympathize with students as well as most, and it's for that very reason that I am very careful not to do a student's work for him or her. While it might help them receive a better grade than they deserve, it doesn't teach them a thing. What I am always happy to do is to explain how things work or give them insights when they are stuck, but never write code for them.
Re: help please
Awesome.peterjwest wrote:Here you are:
If you'd like help, please at least try it first and post what you've managed so far. Also spend some time checking your spelling and grammar.Code: Select all
Numbers <table border="1"> <tr> <th>od</th> </tr> <tr> <td>all the od numbers between 0 ro 1000, except the number 501</td> </tr> </table>
And you should know that 'odd' has two d's.
Re: help please
wooooowww. well i will explain. i have my final exam of my course on thrusday, if i dont pass this exam i will have to stay all year doing only this discipline.
because of the mismatch of schedules and because i study and work i couldn´t go to the classes and now i just have some exemples of tests and i dont have where to study.
there was a guy in my college that said that would help me with this but now he doesnt answer my calls, so i asked for this so that i can learn from somewhere.
i have to say that this area has nothing to do with what i want to do professionaly.
thank you very much for your attention
and im sorry...
because of the mismatch of schedules and because i study and work i couldn´t go to the classes and now i just have some exemples of tests and i dont have where to study.
there was a guy in my college that said that would help me with this but now he doesnt answer my calls, so i asked for this so that i can learn from somewhere.
i have to say that this area has nothing to do with what i want to do professionaly.
thank you very much for your attention
and im sorry...
Re: help please
So wait...you've done a whole PHP course and you still can't write a 9-lined script?
I don't mean to be rude...but that's pretty shocking
Also,
With this script:...i got these results:
I don't mean to be rude...but that's pretty shocking
Also,
I actually found that modulo is faster.Please note that $x&1 performs better (read faster) than $x%2.
(This is because $x&1 performs a simple binary comparison, while $x%2 performs a division, giving you the remainder.)
With this script:
Code: Select all
<?php
$begin = array_sum(explode(' ', microtime()));
for($i = 0; $i <= 100000000; $i++)
if($i % 2)
false;
echo sprintf('Modulo took %s seconds', array_sum(explode(' ', microtime())) - $begin);
$begin = array_sum(explode(' ', microtime()));
for($i = 0; $i <= 100000000; $i++)
if($i & 2)
false;
echo sprintf('Bitwise and took %s seconds', array_sum(explode(' ', microtime())) - $begin);
?>Modulo took 8.0031170845032 seconds
Bitwise and took 8.1880991458893 seconds
Re: help please
lol no! my course was (or is) audiovisual and multimedia. but what i really want is audiovisual, but this discipline was obligatory, and i couldn´t go to the classes.
thank you soooo much
thank you soooo much
Re: help please
Hope you're prepared to explain the code if you have to then lol
Re: help please
jackpf: My original findings where actually from C++, so i decided to do the test again in PHP. I did 100 million iterations of bitwise comparison and modulo operations respectively. I found that bitwise comparison was sligtly faster than modulo operations, but with such little margin, that it might as well have been a coincidence. So my conclusion is actually that in PHP it doesn't matter wether you use bitwise comparison or modulo.
(Note: I've tested with both small and large numbers and the result remains the same)
(Note: I've tested with both small and large numbers and the result remains the same)