Jump to content

isuckat_php

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

isuckat_php's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I made some changes to the code. Hopefully it helps in my much need assistance. Help is greatly appreciated. I am working on a code that needs to have the capabilities as this link: http://athena.ecs.csus.edu/~cs010142/Greeting_tree.php Exclude the background color and the blinking. I think there is away to set up arrays to make it do this but having difficulty. This is my code so far: <HTML> <HEAD> <TITLE>The Greeting Trees </TITLE> </HEAD> <BODY bgcolor=" #3BB9FF"> <? /* Your brief description of this program which may include input, output, requirements, and your design highlights */ if ($submit) { $size=$_POST['size']; $tree=$_POST['tree']; $type=$_POST['type']; if (($size == "") || (!$tree)) { echo("<font face=\"Tahoma\" size=\"2\" color=\"#FF0000\"><b>Oops, you forgot to supply some information. </b></font><br>"); } else if ((!ereg("[0-9]",$size))) { echo("<font face=\"Tahoma\" size=\"2\" color=\"#FF0000\"><b>Please restrict your input to only numbers.</b></font><br>"); } else if (($size < "12")|| ($size > "24")) { echo("<font face=\"Tahoma\" size=\"2\" color=\"#FF0000\"><b>Out of range</b></font><br>"); } } else { $A =array($size); if (($size % 2 == 0)) $center =(($size/2)) && (($size/2 + 1)); else $center = int($size/2); for ($i=0; $i < 5; $i++) { for($j= ($center - $i); $j<= ($center + $i); $j++) { $A[$i+2][$j]= "*"; } } for ($i=0; $i< $N; $i++) { for($j=0; $j< $N; $j++) { DisplayChar ($type, $A[$i][$j]); } echo "<BR>"; } //Form to collect user input: one of the 3 greeting tree types ?> <FORM METHOD="post" ACTION="Greeting_tree.php"> <p>Please enter a tree size between 12 and 24:</p> <input type="text" name="size" /> <p>Select tree type:</p> <input type="radio" name="tree" value="Holiday" /> Holiday <input type="radio" name="tree" value="SacState" /> SacState <input type="radio" name="tree" value="Suprise" /> Suprise <br/> <input type="submit" value="Display the tree" > </FORM> </BODY> </HTML>
  2. Help is greatly appreciated. I am working on a code that needs to have the capabilities as this link: http://athena.ecs.csus.edu/~cs010142/Greeting_tree.php Exclude the background color and the blinking. I think there is away to set up arrays to make it do this but having difficulty. This is my code so far: <?php /* Your brief description of this program which may include input, output, requirements, and your design highlights */ include_once("gt_functions.php"); # MAIN-PROGRAM $title = "The Greeting Trees"; html_begin ($title, $title); if ($submit) { $size=$_POST['size']; $tree=$_POST['tree']; $type=$_POST['type']; if (($size == "") || (!$tree)) { echo("<font face=\"Tahoma\" size=\"2\" color=\"#FF0000\"><b>Oops, you forgot to supply some information. </b></font><br>"); } else if ((!ereg("[0-9]",$size)) { echo("<font face=\"Tahoma\" size=\"2\" color=\"#FF0000\"><b>Please restrict your input to only numbers.</b></font><br>"); } else if (($size < "12")|| ($size > "24")) { echo("<font face=\"Tahoma\" size=\"2\" color=\"#FF0000\"><b>Out of range</b></font><br>"); } } if else (!$type) { echo "<font face=\"Tahoma\" size=\"2\" color=\"#FF0000\"><b>Please select tree type. </b></font><br>"); } else { //set up the data in a 2-dimensional array to mark the background $A =array(array("0","0","0","0","0","0","0","0","0","0","0"), array("0","0","0","0","0","0","0","0","0","0","0"), array("0","0","0","0","0","0","0","0","0","0","0"), array("0","0","0","0","0","0","0","0","0","0","0"), array("0","0","0","0","0","0","0","0","0","0","0"), array("0","0","0","0","0","0","0","0","0","0","0"), array("0","0","0","0","0","0","0","0","0","0","0"), array("0","0","0","0","0","0","0","0","0","0","0"), array("0","0","0","0","0","0","0","0","0","0","0"), array("0","0","0","0","0","0","0","0","0","0","0"), array("0","0","0","0","0","0","0","0","0","0","0")); //this array A is 11x11, therefore the center of a row is 5 $N = 11; $center = 5; //mark tree leaves for ($i=0; $i < 5; $i++) { for($j= ($center - $i); $j<= ($center + $i); $j++) { $A[$i+2][$j]= "*"; } } //mark tree trunk for ($i = 7; $i < 10; $i++) { $A[$i][$center] = "*"; } //display elements of the array in colors of the tree type for ($i=0; $i< $N; $i++) { for($j=0; $j< $N; $j++) { DisplayChar ($type, $A[$i][$j]); } echo "<BR>"; } DisplayGreeting($type); } } //Form to collect user input: one of the 3 greeting tree types ?> <FORM METHOD="post" ACTION="Greeting_tree.php"> <p>Please enter a tree size between 12 and 24:</p> <input type="text" name="size" /> <p>Select tree type:</p> <input type="radio" name="tree" value="Holiday" /> Holiday <input type="radio" name="tree" value="SacState" /> SacState <input type="radio" name="tree" value="Suprise" /> Suprise <br/> <input type="submit" value="Display the tree" > </FORM> <? html_end () ?> This is my gt_functions so far( it is not much): <?php # A collection of functions that will be included in Greeting_tree.php function html_begin ($title, $header) print ("<HTML>\n"); print ("<HEAD>\n"); if ($title) print ("<TITLE>$title</TITLE>\n"); print ("</HEAD>\n"); print ("<BODY bgcolor=\"#FFFF9C\">\n"); if ($header) print ("<H2>$header</H2>\n"); } function html_end () { print ("</BODY></HTML>\n"); } function DisplayChar ($type, $char) //display leave color when $char = "*" and background color when $char = "0" according to given tree type {...} function DisplayGreeting ($type) //display greeting message according to given tree type {...} ?> Thank you for reading. Again help is much appreciated!
  3. Help is greatly appreciated. I am generating a multiplication table that runs numbers 2-15 depending on which number the user chooses to input. The problem is when i input a number it infinetly multiplies the number by 1. Here is the code: <?php // time_table.php - a demo of using functions and include file script // Get the functions we need for this time table // Using extension "php" instead of "inc" will prevent others see the code include_once("tt_functions.php"); # MAIN-PROGRAM $title = "The Times-Tables"; html_begin ($title, $title); #Validation of input and then produce the Times-Tables # if ($submit) { if ($n == ''){ ?> <span style="color:red;"><b>Oops, your forgot to supply info required. Please correct the problem and try again. </b></span><br/> <? } else if ((!ereg("[0-9]", $n))){ ?> <span style="color:red;"> <b>Please restrict your input to only numbers.</b></span><br/> <? } else if (($n >= 15 ) || ($n < 2)) { echo "Number Range Error."; } else{ //ready to produce the time tables //function timetable( ) was defined in the included file function_timetable.php timetable($n); } } // Forms to collect user input ?> <form method="post" action="time_table.php"> <p><b>Please enter an interger between 2 and 15:</b></P> <input type='text' name='n' /> <p><input type="submit" name="submit" value="Time Tables" /></P> </form> <? html_end () ?> Here is the tt_functions: <?php # A collection of functions to make our time table engineering # easy to understand. It will be included in time_table.php function html_begin ($title, $header) { print ("<HTML>\n"); print ("<HEAD>\n"); if ($title) print ("<TITLE>$title</TITLE>\n"); print ("</HEAD>\n"); print ("<BODY bgcolor=\"#FFFF9C\">\n"); if ($header) print ("<H2>$header</H2>\n"); } # put out final HTML tags for page. function html_end () { print ("</BODY></HTML>\n"); } function timetable ($n) { // Go through each table for ($table=1; $table<=$n; $table++) { print "<p><b>The ".$table ."Times Table</b>\n"; //Produce $n lines for each table for($counter=1; $counter=$n; $counter++) { $answer = $table * $counter; //Is this an even-number counter? if ($counter % 2 == 0) //Yes, so print this line in bold print "<br><b>$counter x $table = ". "$answer</b>"; else //No, so print this in normal face print "<br>$counter x $table = $answer"; } } }?> Again help is much appreciated. Thank you for taking the time to read this.
  4. I have this calculator code which i recieved assitance from phpfreaks.com to complete. Once again help will be greatly appreciated. I can read majority of the code although i missed alot of ";" and "(" and {" which is frustrating. For example: elseif ((!ereg("[0-9]",$score_1)) || (!ereg("[0-9]",$score_2) || (!ereg("[0-9]",$score_3)))) There are alot of ")" at the end of that... just doesn't make sense to me. A more important matter is that I am having trouble reading this part of the code: if (isset($_POST['submit'])) { $score_1 = (isset($_POST['score_1'])) ? $_POST['score_1'] : ''; $score_2 = (isset($_POST['score_2'])) ? $_POST['score_2'] : ''; $score_3 = (isset($_POST['score_3'])) ? $_POST['score_3'] : ''; I see that the more variables are being assigned; however i do not understand what it is being assigned to and how it works. I went with this and it works great with my code, no complaints I am just unable to read this part of the code. Here is the complete code: <html> <body bgcolor="#ffff33"> <?php if (isset($_POST['submit'])) { $score_1 = (isset($_POST['score_1'])) ? $_POST['score_1'] : ''; $score_2 = (isset($_POST['score_2'])) ? $_POST['score_2'] : ''; $score_3 = (isset($_POST['score_3'])) ? $_POST['score_3'] : ''; if (($score_1 == "") || ($score_2 =="") || ($score_3 =="")) { echo("<font face=\"Tahoma\" size=\"2\" color=\"#FF0000\"><b>Go play some more freegumph! Need at least three scores to calculate a handicap.</b></font><br>"); } elseif ((!ereg("[0-9]",$score_1)) || (!ereg("[0-9]",$score_2) || (!ereg("[0-9]",$score_3)))) { echo("<font face=\"Tahoma\" size=\"2\" color=\"#FF0000\"><b>You must be a new player. Freegumph scores only consist of numeric values.</b></font><br>"); } elseif (($score_1 < 0) || ($score_2 < 0) || ($score_3 < 0)) { echo("<font face=\"Tahoma\" size=\"2\" color=\"#006600\"><b>Error! Perhaps the lowest possible score is 0.</b></font><br>"); } else { $avg=($score_1 + $score_2 + $score_3)/3; if ($avg >= 27) { $total = 0; } else { $total = ((27- $avg) * (7/10)); } print(" The freegumpher handicap is: ". $total); } } ?> <form method="post" action=""> Enter your three most <i>recent</i> Freegumpher scores to calculate Handicap:<br/> <br/> <input type="text" name="score_1" size=8 <input type="text" name="score_2" size=8 <input type="text" name="score_3" size=8 /><br /><br/> <input type="submit" name="submit" value="Calculate Handicap"/> </form> </body> </html> Once again help is greatly appreciated and thank you for taking the time to read this.
  5. works wonderfully! hope hcdarkmage and jcbones have an awesome day because you guys just made my day! now to study how the code works...
  6. http://athena.ecs.csus.edu/~cs010129/freegumph.php i implemented the code you gave me. Do i need to delete the if (($score_1 == "") || ($score_2 =="") || ($score_3 =="") || (!$calc)) because i have: if ($submit != "")
  7. That got rid of the output displaying automatically but, it still keeps saying no matter what numbers I put into the text: Oops, you forgot to supply some information. Please correct the problem below. My code is set to tell it to only display that if only one of my input text are left blank.
  8. I am running into a few problems. 1) It calculates: The freegumpher handicap is:20.3 The problem with this is that i dont want it to output anything until the user gives numbers. i dont know where it came up with his number 2) Everytime I input a number it outputs: Oops, you forgot to supply some information. Please correct the problem below. The problem with this is that i dont want that message to show up unless one of the boxes is not filled after calculation button is clicked. this is the webpage: http://athena.ecs.csus.edu/~cs010129/freegumph.php this is the adjusted code: <html> <body> <?php if ($submit) { if (($score_1 == "") || ($score_2 =="") || ($score_3 =="") || (!$calc)) { echo("<font face=\"Tahoma\" size=\"2\" color=\"#FF0000\"><b>Oops, you forgot to supply some information. Please correct the problem below.</b></font><br>"); } elseif ((!ereg("[0-9]",$score_1)) || (!ereg("[0-9]",$score_2) || (!ereg("[0-9]",$score_3)))) { echo("<font face=\"Tahoma\" size=\"2\" color=\"#FF0000\"><b>Please restrict your input to only numbers.</b></font><br>"); } } else { $avg=($score_1 + $score_2 + score_3)/3; if ($avg >= 29) { echo $total = 0; } else { $total = ((29 - $avg) * (7/10)); } print("The freegumpher handicap is:". $total); } ?> <form method="post" action="freegumph.php"> Enter your three most <i>recent</i> Freegumpher scores to calculate Handicap:<br/> <br/> <input type="text" name="score_1" size=8 <input type="text" name="score_2" size=8 <input type="text" name="score_3" size=8 /><br /><br/> <input type="submit" name="submit" value="Calculate Handicap"/> </form> </body> </html> Help is greatly appreciated.
  9. I am running into a few problems. 1) It calculates: The freegumpher handicap is:20.3 The problem with this is that i dont want it to output anything until the user gives numbers. i dont know where it came up with his number 2) Everytime I input a number it outputs: Oops, you forgot to supply some information. Please correct the problem below. The problem with this is that i dont want that message to show up unless one of the boxes is not filled. this is the webpage: http://athena.ecs.csus.edu/~cs010129/freegumph.php this is the adjusted code: <html> <body> <?php if ($submit) { if (($score_1 == "") || ($score_2 =="") || ($score_3 =="") || (!$calc)) { echo("<font face=\"Tahoma\" size=\"2\" color=\"#FF0000\"><b>Oops, you forgot to supply some information. Please correct the problem below.</b></font><br>"); } elseif ((!ereg("[0-9]",$score_1)) || (!ereg("[0-9]",$score_2) || (!ereg("[0-9]",$score_3)))) { echo("<font face=\"Tahoma\" size=\"2\" color=\"#FF0000\"><b>Please restrict your input to only numbers.</b></font><br>"); } } else { $avg=($score_1 + $score_2 + score_3)/3; if ($avg >= 29) { echo $total = 0; } else { $total = ((29 - $avg) * (7/10)); } print("The freegumpher handicap is:". $total); } ?> <form method="post" action="freegumph.php"> Enter your three most <i>recent</i> Freegumpher scores to calculate Handicap:<br/> <br/> <input type="text" name="score_1" size=8 <input type="text" name="score_2" size=8 <input type="text" name="score_3" size=8 /><br /><br/> <input type="submit" name="submit" value="Calculate Handicap"/> </form> </body> </html>
  10. thank you kind sir, i hope you a really great day!
  11. I dont know how to fix this! assistance would be greatly appreciated.: everytime i try to load my page i get: Parse error: parse error, unexpected '{' in /gaia/class/cs0101/cs010129/html/freegumph.php on line 13 this is my code: <html> <body> <?php if ($submit) { if (($score_1 == "") || ($score_2 =="") || ($score_3 =="") || (!$calc)) { echo("<font face=\"Tahoma\" size=\"2\" color=\"#FF0000\"><b>Oops, you forgot to supply some information. Please correct the problem below.</b></font><br>"); } elseif ((!ereg("[0-9]",$score_1) || (!ereg("[0-9]",$score_2) || (!ereg("[0-9]",$score_3)) { echo("<font face=\"Tahoma\" size=\"2\" color=\"#FF0000\"><b>Please restrict your input to only numbers.</b></font><br>"); } } else { $avg=($score_1 + $score_2 + score_3)/3 if ($avg >= 29) { echo $total = 0 } else { echo $total= ((29 - $avg) * (7/10)) } print("The freegumpher handicap is:". $total); } } ?> <form method="post" action="freegumph.php"> Enter your three most <i>recent</i> Freegumpher scores to calculate Handicap:<br/> <br/> <input type="text" name="score_1" size=8 <input type="text" name="score_2" size=8 <input type="text" name="score_3" size=8 /><br /><br/> <input type="submit" name="submit" value="Calculate Handicap"/> </form> </body> </html>
×
×
  • 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.