Jump to content

New to Php


wata

Recommended Posts

oh yeh well the thing is i wanna assign to variables my name and a mark (between 1-25). And Convert this mark out of 25 to a percentage. If the percentage is 70% or more print out the statement, with my name on and sayin you are a first class student!”
but i donno how to start it off so could some start it off for us please not askin to do all of it jus start it off. thank you
Link to comment
Share on other sites

here is the actual question:

[quote]1. Assign to variables your name and a mark (between 1-25).  Convert this mark out of 25 to a percentage.  If the percentage is 70% or more print out the statement, “<your name>, you are a first class student!”  (replacing <your name> with the value stored in the variable)  [/quote]
Link to comment
Share on other sites

[quote author=corbin link=topic=117040.msg477375#msg477375 date=1165024649]
I just read what wata posted about 10 times, and I still have no idea what you want...

Anyways for the percent thing you could do

if($percent*4 >= 70) {
echo "You are a first class student.";
}
else {
echo "You are not a first class student.";
}
[/quote]

where did you get the 4 from?
Link to comment
Share on other sites

[quote author=ataria link=topic=117040.msg477539#msg477539 date=1165068702]

where did you get the 4 from?

I know I didn't post ittt. but, I know the reasoning behind it.

100/25 = 4.

If you want 100% to the highest possible, you need to times the percent by 4.
Hence, a 17.5 would be 70%

get it?

thanks BUT
can you answer this please?

[quote]1.  Assign to variables your name and a mark (between 1-25).  Convert this mark out of 25 to a percentage.  If the percentage is 70% or more print out the statement, “<your name>, you are a first class student!”  (replacing <your name> with the value stored in the variable) [/quote]

[/quote]
Link to comment
Share on other sites

Corbin already did it.

if($percent*4 >= 70) {
echo " {$name}, You are a first class student.";
}
else {
echo "You are not a first class student.";
}

to do the other thingg. (giving them the mark)

<?php
$random = rand(1,25);
$insert = mysql_query("INSERT INTO `table_name`(`column name`) VALUES ('{$random}'));
?>
Link to comment
Share on other sites

should be:
[code]<?php
$name = "Wata"
$percent = 4
if ($percent*4 >= 70) {
echo " {$name}, You are a first class student.";
}
else {
echo "You are not a first class student.";
}
?>[/code]
You forgot the ()'s and the } on the last else statement.
EDIT: ^^ posted at the same time with a slightly different peice of code.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.