Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. <?php $test = file_get_contents("C:\Users\Mike\Desktop\AthyDB.txt"); $repl = array( 'D' => 'Dail European Parliament and Local Elections only', 'E' => 'European Parliament and Local Elections only', 'L' => 'Local Elections only', 'S' => 'Post or special arrangement only' ); $test = explode("\n", $test); foreach ($test as $k => $v){ $test[$k] = $repl[substr($v,0,1)].substr($v,1); } $test = implode("\n", $test); file_put_contents('C:\Users\Mike\Desktop\test.txt', $test); ?>
  2. $sql_textareas = "SELECT * FROM textareas"; $result_ta = mysql_query($sql_textareas); $results_ta = mysql_numrows($result_ta); while($textarea = mysql_fetch_assoc($result_ta)) { $child = 'texarea_' . $textarea['name']; $$child = $textarea['content']; }
  3. in your form you mast have input field named 'mGinNo' with value menagerID it could be hidden type
  4. change line $rtytr=mysql_query($query); to $rtytr=mysql_query($query) or die(mysql_error()); part if($sql=false){ die('Error Putting data in.');} mean if(false){ die('Error Putting data in.');} never execute
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="styles.css" rel="stylesheet" type="text/css"> <title>Outdoor Adventures - Play Set Options</title> </head> <body> <h1>Outdoor Adventures - Play Set Options</h1> <p> Welcome to Outdoor Adventures. Complete the form below to calculate the cost of one of our play sets. </p> <form action="cost.php" method="post"> <table width="750" border="0" cellpadding="0" cellspacing="0"> <table width="750" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="88">First name: </td> <td width="662"><input type="text" id="first_name" name="first_name" size="30" maxlength="20" /></td> </tr> <tr> <td>Last name: </td> <td><input type="text" id="last_name" name="last_name" size="30" maxlength="20" /></td> </tr> <tr> <td>Phone: </td> <td><input type="text" id="phone" name="phone" size="10" maxlength="10" /></td> </tr> </table> <p>Base model play set:<br> <input type="radio" id="single" name="base" value="Single"> <label for="single">Single<br /> <input type="radio" id="double" name="base" value="Double"> <label for="double">Double</label><br /> <input type="radio" id="monkey" name="base" value="Double with monkey bars"> <label for="monkey">Monkey</label><br /> <p>Optional extra components:<br> <input type="checkbox" id="MetalClimbBar" name="extra[0]" value="Metal climb bar" /> <label for="MetalClimbBar">Metal climb bar</label><br /> <input type="checkbox" id="FiremanPole" name="extra[1]" value="Fireman pole" /> <label for="FiremanPole">Fireman Pole</label><br /> <input type="checkbox" id="See-saw" name="extra[2]" value="See-saw" /> <label for="See-saw">See-saw</label><br /> <input type="checkbox" id="Rock-climbingWall" name="extra[3]" value="Rock-climbing wall" /> <label for="Rock-climbingWall">Rock-climbing Wall</label><br /> <input type="checkbox" id="Trapezeandrings" name="extra[4]" value="Trapeze and rings" /> <label for="Trapezeandrings">Trapeze and rings combo</label><br /> <input type="checkbox" id="RopeLadder" name="extra[5]" value="Rope ladder" /> <label for="RopeLadder">Rope Ladder</label><br /> </p> <p> <input type="submit" value="Submit" > <input type="reset"> </p> </form> </body> </html> Second page: <?php // Variables for storing data and calculations $errors = ""; $count = 0; $cost = 0; // Function to display errors function errorMessage($errors) { echo "<p>Your order could not be completed. Please check the errors below:<br />"; echo "<ul>"; echo $errors; // Display error message echo "</ul>"; echo "Click the green \"back\" button to try again.<br />"; } // if the form has been posted,analyse it, strip out any leading or trailing spaces: if($_POST)// { foreach ($_POST as $field_name => $value) { $value = is_array($value) ? $value : trim($value); $$field_name = $value; } } $extra_arr = array('Climb bar'=>100, 'Fireman pole'=>100, 'See-saw'=>100, 'Rock-climbing wall'=>100, 'Trapeze and rings'=>100,'Rope ladder'=>100); // Testing for input errors and nil entries in the various areas of the form if($first_name == "" || is_numeric($first_name)) { $errors .= "<li>a first name needs to be entered</li><br />"; } if($last_name == "" || is_numeric($last_name)) { $errors .= "<li>a last name needs to be entered</li><br />"; } if($phone === "" || is_numeric($last_name)) { $errors .= "<li>a phone number needs to be entered</li><br />"; } if($base == "") { $errors .= "<li>a base needs to be selected</li><br />"; } if($base == "Single" ) { $cost = 550; } if($base == "Double") { $cost = 600; } if($base == "Double with monkey bars") { $cost = 700; } /* for($i = 0; $i < 6; $i++) { if($extra_arr[$i]) { $count++;// } } */ $count = count($extra); // If no errors, display the form data if($errors == "") { echo <<<END <p>First name: $first_name</p> <p>Last name: $last_name</p> <p>Phone: $phone</p> <p>Base: $base</p> Optional extra components: <ul> END; foreach ($extra as $name){ echo "<li>$name</li>\n"; $cost += $extra_arr[$name]; } echo <<<END </ul> <p>Cost: $$cost</p> END; } else // If errors, display errors { errorMessage($errors); } ?>
  6. can we see your concat() function
  7. or <?php $months_array = array(1=>'January', 2=>'February', 3=>'March', 4=>'April', 5=>'May', 6=>'June', 7=>'July', 8=>'August', 9=>'September', 10=>'October', 11=>'November', 12=>'December'); $output .= "<select name=\"due_date_month\">\n"; $m = date('n') - 1; for ($j = 0; $j < 12; $j++) { $i = ($m + $j) % 12 + 1; $output .= "\t<option value=\"$i\">$months_array[$i]</option>\n"; } echo $output .= "</select>"; ?>
  8. or <?php $horseid=$_GET['id']; $query = mysql_query("SELECT * FROM class_event_entered WHERE horseid='$horseid'"); $number=mysql_num_rows($query); print "<font size='3pt' face='comic sans ms'>Show Entries - #$horseid is entered in $number shows.</font> <br> "; ?>
  9. $ERROR = mysql_query("SELECT `Sect1_4`,`CompanyID` FROM tblDirectory2 WHERE UPPER(`Sect1_4`) LIKE '".strtoupper($_POST["Sect1_4"])."%'") or die(mysql_error());
  10. $p = pow ( 2, ceil( log( $x) / log( 2 ) ) );
  11. look functions ucfirst() ucwords()
  12. <?php $inflrate = 1.05; //5% inflation //calculate yearly bill $yearlybill = $avg_bill * 12; //total estimated yearly cost $cost5 = $inflrate != 1 ? $yearlybill * (pow($inflrate,5) - 1) / ($inflrate - 1) : $yearlybill * 5; $cost15 = $inflrate != 1 ? $yearlybill * (pow($inflrate,15) - 1) / ($inflrate - 1) : $yearlybill * 15; $cost25 = $inflrate != 1 ? $yearlybill * (pow($inflrate,25) - 1) / ($inflrate - 1) : $yearlybill * 25; ?>
  13. http://hr.php.net/manual/en/function.str-getcsv.php#85733
  14. SELECT a.member_id, a.username, SUM(b.counter) AS votes FROM members_table AS a INNER JOIN votes_table AS b ON a.member_id=b.member_id GROUP BY a.member_id
  15. <?php do { $myhash[$row_getPerson['Completed_By']][] = $row_getPerson['Switch']; } while ($row_getPerson = mysql_fetch_assoc($getPerson)); arsort ($myhash); foreach ($myhash as $key => $value){ $count = count($value); $value = implode(', ', $value); echo " <tr> <td nowrap=\"nowrap\">$key</td> <td nowrap=\"nowrap\">$count</td> <td nowrap=\"nowrap\">$value;</td> </tr>"; }
  16. explode on / and get one before last $x = ekplode('/', $url); $part = $x[count($x)-2];
  17. try $query_checkboxlist = "SELECT ID, TYPE, VALUE FROM table1 WHERE TYPE='typeofbox'"; $result_checkboxlist = mysql_query($query_checkboxlist); //save checkbox in array $ch = array(); while($r = mysql_fetch_assoc($result_checkboxlist)) $ch[$r['ID']]=$r['VALUE']; $query = "SELECT ID, CHECKBOXES FROM table2 WHERE ID=4"; $result = mysql_query($query); while($row = mysql_fetch_array($result)){ // browse users echo "<ul>\n"; $markedboxes = explode(",",$row['CHECKBOXES']); foreach($ch as $id => $value)) { if(in_array($id, $markedboxes)) $checked =' checked="checked"'; else $checked = ''; echo '<li><input type="checkbox" name="involvement[".$row['ID']."]" value="'. $id.'"'. $checked. "/>".$value."</li>\n"; } echo "</ul>\n"; }
  18. DELETE FROM `category` where `topicId` NOT IN (SELECT `id` FROM `category`)
  19. <?php $query="SELECT Height FROM `main` WHERE clientD='1'"; $result=mysql_query($query); $row = mysql_fetch_assoc($result); echo $h = $row['Height']; ?> <br> <?php $query="SELECT S1Weight FROM `main` WHERE PatientID='1'"; $result=mysql_query($query); $row1 = mysql_fetch_assoc($result); echo $w = $row1['S1Weight']; ?> <br> <?php $c=$w!=0 ? ($h*$h/$w) : 'S1Weight is zero!'; echo $c; ?>
  20. preg_replace("/[^a-zA-Z0-9-]+/","",$var);
  21. ... if (is_int($i / $cols)){ echo "<td width='180' align='center' style=\"border-style: dotted; border-width: 1\">$mybox</td></tr><tr>"; }else{ echo "<td width='180' align='center' style=\"border-style: dotted; border-width: 1\">$mybox</td>"; } if ( $i / $cols == 2) echo "<td colspan='3'>BANNER HERE</td></tr><tr>"; $i++; //end if
×
×
  • 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.