Jump to content

Space Cowboy

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Space Cowboy's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi there, Im creating a job sheet system, where people enter how many minutes they have spent on a job. The minutes are totaled up and im left with a total like: 465 (minutes). I need something that will break that down into hours. (465 minutes is equal to 7 hours and 45 mins). If I try this calculation: 465 / 60 it equals 7.75. It needs to be 7.45 and I cant find the answer anywhere  Any help would be massively appreciated
  2. Hey guys and gals, got a toughie here for someone to help me crack. Its a PHP and Javascript issue so was unsure really which forum topost in, but here goes..... http://www.edensteet.net/internal/newPurchaseOne.php If you look at this page I think you will see the general gist of what im wanting. Basically you select the quantity, type in a description of an item, type in the unit cost (ie cost per item), and then it automatically calculates the last field (quantity X unit price). Pretty easy so far! But what about this: http://www.edensteet.net/internal/newPurchase.php :o Now the code doesnt work. Now before anyone suggests a fix, each line need to be inserted into database. The code goes like this: <?php echo "<form name=\"frmOne\" method=\"post\" action=\"$PHP_SELF\">\n"; ?> <SCRIPT language = JavaScript> function calculate() { A = document.frmOne.inputQuantity.value B = document.frmOne.inputUnitPrice.value C = (A * B) document.frmOne.inputLineTotal.value = C } </SCRIPT> <?php echo "<table width=\"100%\">\n"; echo "<tr>\n"; echo "<td class=\"stats\"><p>Quantity\n"; echo "</p></td>\n"; echo "<td class=\"stats\"><p>\n"; echo "Item Description\n"; echo "</p></td>\n"; echo "<td class=\"stats\"><p>\n"; echo "Unit Price\n"; echo "</p></td>\n"; echo "<td class=\"stats\"><p>\n"; echo "Line Total\n"; echo "</p></td>\n"; echo "</tr>\n"; while ($i < '10') { echo "<tr>\n"; echo "<td class=\"stats\"><p>\n"; echo "<select name=\"inputQuantity[$i]\">\n"; echo "<option value=\"\">Quantity</option>\n"; echo "<option value=\"0\">0</option>\n"; echo "<option value=\"1\">1</option>\n"; echo "<option value=\"2\">2</option>\n"; echo "<option value=\"3\">3</option>\n"; echo "<option value=\"4\">4</option>\n"; echo "<option value=\"5\">5</option>\n"; echo "<option value=\"6\">6</option>\n"; echo "<option value=\"7\">7</option>\n"; echo "<option value=\"8\">8</option>\n"; echo "<option value=\"9\">9</option>\n"; echo "<option value=\"10\">10</option>\n"; echo "<option value=\"11\">11</option>\n"; echo "<option value=\"12\">12</option>\n"; echo "<option value=\"13\">13</option>\n"; echo "<option value=\"14\">14</option>\n"; echo "<option value=\"15\">15</option>\n"; echo "<option value=\"16\">16</option>\n"; echo "<option value=\"17\">17</option>\n"; echo "<option value=\"18\">18</option>\n"; echo "<option value=\"19\">19</option>\n"; echo "<option value=\"20\">20</option>\n"; echo "<option value=\"21\">21</option>\n"; echo "<option value=\"22\">22</option>\n"; echo "<option value=\"23\">23</option>\n"; echo "<option value=\"24\">24</option>\n"; echo "<option value=\"25\">25</option>\n"; echo "<option value=\"26\">26</option>\n"; echo "<option value=\"27\">27</option>\n"; echo "<option value=\"28\">28</option>\n"; echo "<option value=\"29\">29</option>\n"; echo "<option value=\"30\">30</option>\n"; echo "<option value=\"31\">31</option>\n"; echo "<option value=\"32\">32</option>\n"; echo "<option value=\"33\">33</option>\n"; echo "<option value=\"34\">34</option>\n"; echo "<option value=\"35\">35</option>\n"; echo "<option value=\"36\">36</option>\n"; echo "<option value=\"37\">37</option>\n"; echo "<option value=\"38\">38</option>\n"; echo "<option value=\"39\">39</option>\n"; echo "<option value=\"40\">40</option>\n"; echo "<option value=\"41\">41</option>\n"; echo "<option value=\"42\">42</option>\n"; echo "<option value=\"43\">43</option>\n"; echo "<option value=\"44\">44</option>\n"; echo "<option value=\"45\">45</option>\n"; echo "<option value=\"46\">46</option>\n"; echo "<option value=\"47\">47</option>\n"; echo "<option value=\"48\">48</option>\n"; echo "<option value=\"49\">49</option>\n"; echo "<option value=\"50\">50</option>\n"; echo "</select>\n"; echo "</p></td>\n"; echo "<td class=\"stats\"><p>\n"; echo "<input type=\"text\" name=\"inputDescription[$i]\" size=\"40\" maxlength=\"255\"/></p>\n"; echo "</p></td>\n"; echo "<td class=\"stats\"><p>\n"; echo "<input type=\"text\" name=\"inputUnitPrice[$i]\" size=\"5\" maxlength=\"255\" onKeyup=\"calculate()\"/></p>\n"; echo "</p></td>\n"; echo "<td class=\"stats\"><p>\n"; echo "<input type=\"text\" name=\"inputLineTotal[$i]\" size=\"5\" maxlength=\"255\"/></p>\n"; echo "</p></td>\n"; echo "</tr>\n"; ++$i; } echo "<tr>\n"; echo "<td class=\"stats\"><p>\n"; echo " \n"; echo "</p></td>\n"; echo "<td class=\"stats\"><p>\n"; echo "<input type=\"submit\" type=\"submit\" name=\"submit\" value=\"Submit\"/>\n"; echo "</p></td>\n"; echo "</tr>\n"; echo "</table>\n"; echo "</form>\n"; ?> Basically this bit of the code "while ($i < '10') {" dictates how many rows to display. Thats the form and this is the code upon submission that sends to database: <?php if (isset($_POST['submit'])) { //--IF FORM HAS BEEN SUBMITTED // find out how many records there are to update $size = count($_POST['inputLineTotal']); // start a loop in order to update each record $i = 0; while ($i < $size) { // define each variable $inputQuantity= $_POST['inputQuantity'][$i]; $inputDescription= $_POST['inputDescription'][$i]; $inputUnitPrice= $_POST['inputUnitPrice'][$i]; $inputLineTotal= $_POST['inputLineTotal'][$i]; if ($inputLineTotal) { //--MAIN DATABSE QUERY $Query = "INSERT INTO internal_items (order_id, quantity, unit_price, line_price, description) VALUES ('77', '".mysql_escape_string($inputQuantity)."', '".mysql_escape_string($inputUnitPrice)."', '".mysql_escape_string($inputLineTotal)."', '".mysql_escape_string($inputDescription)."')"; $resultComplete = mysql_query ($Query); } ++$i; } if ($resultComplete) { //--IF EVERYTHING SUCCESSFULL THEM DIRECT TO POSITIVE MESSAGE header ("Location: http://" . $_SERVER['HTTP_HOST'] . "/internal/newPurchase.php"); exit(); } else { //--IF NOT INSERTED INTO DATABASE SUCCESFULLY REDIRECT TO ERROR MESSAGE header ("Location: http://" . $_SERVER['HTTP_HOST'] . "/internal/error.php?message=1"); exit(); } } //--END IF FORM HAS BEEN SUBMITTED ?> Now how do I get the javascript to work with the multiple rows of data? Ive tried the obvious which is: <SCRIPT language = JavaScript> function calculate() { A = document.frmOne.inputQuantity[$i].value B = document.frmOne.inputUnitPrice[$i].value C = (A * B) document.frmOne.inputLineTotal[$i].value = C } </SCRIPT> ....obviouslly with php start and end braces but still no work! If anyone can help, it would be much appreciated!!!!
  3. for some reason that isnt sending it out at all!!! besides which, I cant rely on whats being sent being W3 complient...and many HTML emails are sent out without being complient.
  4. <?php //add From: header $headers = "From: newsletter@domain.co.uk\r\n"; //specify MIME version 1.0 $headers .= "MIME-Version: 1.0\r\n"; //unique boundary $boundary = uniqid("HTMLDEMO"); //tell e-mail client this e-mail contains//alternate versions $headers .= "Content-Type: multipart/alternative" . "; boundary = $boundary\r\n\r\n"; //message to people with clients who don't understand MIME $headers .= "This is a MIME encoded message.\r\n\r\n"; //plain text version of message $headers .= "--$boundary\r\n" . "Content-Type: text/plain; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n"; $headers .= chunk_split(base64_encode("This is the plain text version!")); //HTML version of message $headers .= "--$boundary\r\n" . "Content-Type: text/html; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n"; $headers .= chunk_split(base64_encode("$abstract")); //send message mail("$email", "An HTML Message", "", $headers); ?> OK, ive adapted this code and I think im getting somewhere. The email is being recieved in HTML, things like the bold/strong tag and H1/h2 tags are being picked up, but its stripping all style. If I send something with a table like this: <table width="680" border="4" align="center" cellpadding="0" cellspacing="0" bordercolor="#257690" bgcolor="#257690"> its being stripped and when recieved its coming out as just <table> arrrghhhhhhhhhhhhh!
  5. thanks, but I dont understand where to insert the headers. Ive tried copying and pasting the script on the page you gave but it just comes up with errors. Do the headers need to be sent within the html part of the email or they are just set within the script?
  6. <?php //--SETS UP THE EMAIL LAYOUT WITH VARIABLES IN PLACE $administrator="$email"; $subject="test mails"; $message.="$textarea\n"; //--SENDS THE EMAIL mail($administrator,$subject,$message,"From:gareth@humberep.co.uk"); ?> Hello, this is the code im using to send out an email (the variable $textarea" comes from a form (text area) just submitted). The emails are sending out, however if I send out html, the actual code shows up in the email rather than the visual style the HTML should render. How do I change this?
  7. ummm.... this does not seem to be working. Within the loop ive added echo "$email_to_send<br/>\n"; just to see what its doing.... it displays the email addresses (and other data) within the loop, so the loop seems to be working correctly, however for some reason the email isnt actually getting sent. Yes ive checked spam filters and sent it to a various number of different email accounts, but still no good. :-(
  8. thanjks, but im not 100% sure of what you mean with (save as $result = mysql_query()) sorry, but what would the actual select statement be? because dont understand how to quite fit it in with this?
  9. Hey guys, im trying to add on somewhat of a newsletter feature onto a website. Basically I have a list of email addresses (along with their first and last names) in mysql database. From here ive created a form, simply its one text box, in which the administrator will type their text into this text box, press submit and the email will be sent to all those in the database. Below is the entire of my code but I cant get it to work! argh! The part in red (the actual email sending bit) works only if I was sending to one person. But for some reason it doesnt like to looped and used for each row of data (ie each email sending attempt). (edit, the code below doesnt seem to want to go red, but you can see where its ment to!) What am I doing wrong? if (isset($_POST['Submit'])) { //--IF FORM HAS BEEN SUBMITTED //--GET NEWS ITEMS LIST $GetList = "SELECT * FROM newsletter WHERE active = 1"; $ResultList = mysql_query($GetList); $num = mysql_num_rows($ResultList); if ($num > 0) { //--IF THERE IS AT LEAST ONE TOPIC TO DISPLAY- DISPLAY TABLE $i = 0; while ($i < $num) { //--START DISPLAYING ROWS OF DATA IN MAIN TABLE $id = mysql_result($ResultList,$i,"id"); $email = mysql_result($ResultList,$i,"email"); $firstname = mysql_result($ResultList,$i,"firstname"); $lastname = mysql_result($ResultList,$i,"lastname"); $emailHSC = stripslashes (htmlspecialchars ($email)); [color=red] //--GET VARIABLES FROM PHP AND CONVERT TO EMAIL FORMAT $firstname=$HTTP_POST_VARS["firstname"]; $lastname=$HTTP_POST_VARS["lastname"]; $email=$HTTP_POST_VARS["email"]; $textarea=$HTTP_POST_VARS["textarea"]; //--SETS UP THE EMAIL LAYOUT WITH VARIABLES IN PLACE $administrator="$email"; $subject="WEEKLY NEWSLETTER"; $message="Hello $firstname $lastname\n"; $message.="$textarea\n"; //--SENDS THE EMAIL mail($administrator,$subject,$message,"From:subscribe@domain.co.uk"); [/color] echo "<p>Email sent to: $emailHSC</p>\n"; $i++; } //--END DISPLAY ROWS OF DATA IN MAIN TABLE } else { //--ELSE IF FORM HAS BEEN SUBMITTED echo "<form action=\"/send.php\" method=\"POST\">\n"; echo "<fieldset id=\"SearchForm\">\n"; echo "<p class=\"MainContentArea\">Edit text<br/><textarea name=\"textarea\" cols=\"50\" rows=\"7\"></textarea></p>\n"; echo "<p class=\"MainContentArea\"><input class=\"submit\" name=\"Submit\" type=\"submit\" value=\"Submit\"></p>\n"; echo "</fieldset>\n"; echo "</form>\n"; } //--END IF FORM HAS BEEN SUBMITTED
  10. ive done this and it doesnt work. and from looking at that query, it doesnt mention anywhere the old colum or date. So how does this query know what date it needs to convert?
  11. thanks, I dont fully understand that query but I will give it a go! ...presuming this quesry understands this daft format the date it currently in? (ie 18/02/2007 16:40:53"). Infact ideally I could do to get rid of the time completly, and just convert to "20071802"
  12. thanks..... but that website was the first place I looked!!! But it doesnt answer my question. I already have the date in the awkward format. I need to convert this into the traditional "20060522123353" format.
  13. Hey guys, I need a bit of help here with dates. Im rebuilding a website (a CMS). Ive been given the existing database which I now need to input into the new CMS. The dates (of the articles) are in this format "18/02/2006 16:32:57" Im used to working with dates in this format "20061802163257" (from this format its easy to order (the articles) by dates etc). How can I convert this date format (on the fly) to something more workable?
  14. but this will obviouly still use php to do the things I asked?
×
×
  • 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.