Jump to content

noahyamen

New Members
  • Posts

    9
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

noahyamen's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Also, when I was able to at least return data from each checkbox, it wasn't returning the value. It would only display "on". Couldn't figure out why.
  2. This one is a doozy for me. My brain is fried after spending a couple days trying to figure this out. None of my formulas have seemed to work out enough. So I'm waiving my white flag and asking for some help. Below is a simplified version of my code. The purpose of this page is an estimate calculator. It is for a window cleaning service, and they have pricing for doing the insides of windows and the outsides. Each style of window has different pricing for each inside and outside. What is supposed to happen in the form is this: If they want an estimate for say basic window cleaning for both inside and outside, they will check the chechboxes for both inside and outside. Then enter a number for the amount of windows to clean. The formula for this would look something like this: Amount = Inside Price x Outside Price (if inside price and outside price checkboxes are ticked). And for each entry, it needs to add up the total. But none of the foreach or while loops i try to create seem to do the trick. Basic Form Setup: $query = "SELECT * FROM estimates WHERE 1 ORDER BY id ASC"; $result = mysql_query($query); while ($estimates = mysql_fetch_object($result)) { $style = $estimates->style; $insidePrice = $estimates->price; $outsidePrice = $estimates->out; echo $style.' <input type="checkbox" name="insidePrice[]" value ="'.$insidePrice,'" /> $'.$insidePrice.' <input type="checkbox" name="outsidePrice[]" value ="'.$outsidePrice,'" /> $'.$outsidePrice.' <input type="text" name="amount[]" />'; } And an idea of how i want this to work: foreach ($_POST['amount'] as $key => $a){ if ($a != "" or $a !="0"){ //Now to llustrate what Im trying to do, I know this is wrong though foreach ($_POST['insideAmount'] as $i){ $i = $i*$a; } foreach ($_POST['outsideAmount'] as $o){ $o = $o*$a; } $a = $i+$o; } //Trying to add each row as they build to make the estimate total $prev = $a[$key-1]; $a = $a+$prev; $total = $a; } echo "$total";
  3. Awesome, thats exactly what I was looking for. It will do the trick nicely. Sorry it didnt make much sense. Thanks guys
  4. Ok so I'll try to explain what I'm trying to do the best I can. I want to build an array that allows me to add/remove/modify the variables used at any point in time without having to rebuild or rewrite a ton of new code. For example, below is an example list of variables I'd like to use in the array, followed by the code I would like to be automatically repeated. Example Variables: $materialName1, $materialName2, $materialName3, $materialName4, $materialName5, $materialName6 etc etc etc Example Code to repeat: echo "<tr><td>Material: $materialName1</td><td>Rate: $materialName1Rate</td><td>Weight: $materialName1Weight</td></tr>"; Hopefully that makes sense. As always, very appreciated.
  5. Nevermind, i had it right. Just in the wrong place in my cod. Duh
  6. Tried a number of different things but can't seem to get the decimal to show the 0 if the decimal is only a single digit. Currently using: $conversion = number_format("$conversion",2); Thanks
  7. Hi again all. Heres the concept of what I'm trying to do. I've been working on a CMS for a while now, and there is a section called Lead Manager. It works kind of like a mailbox, just really basic. It organizes all the contacts that come through on a website, and you are able to respond to the messages via Lead Manager like a email system would. Theres just one thing left I need it to do that i can't seem to get right. When you send a message, I need the "From" email address to automatically pull the email address thats assigned to the username thats currently logged into the cms. I have a table on my database called admin, in it has the stored usernames, passwords, and email addresses assigned to all the users allowed in the cms. So let's say that the current user that is logged in is "johnsmith", and his email address for his account is "johnsmith@domain.com". When johnsmith is logged in, i need the Lead Manager mail system to automatically pull johnsmiths email address to use as the "From" email address when sending messages. How would you go about doing this? Here is some of the code im working with now: session_start(); session_destroy(); $Login=$_POST['Login']; if($Login){ $username=$_POST['username']; $md5_password=md5($_POST['password']); $result = mysql_query("select * from admin where username='$username' and password='$md5_password'"); if(mysql_num_rows($result)!='0'){ session_register("username"); header("location:index.php"); exit; } else { $message = "Incorrect Username or Password"; } } And here is some conceptual coding that represents what I am trying to accomplish (not actual coding I know): $currentUser = session_is_registered; $query = "SELECT * FROM admin WHERE username='$currentUser'"; $result = mysql_query($query); $email = mysql_result($result,0,"email");
  8. So here's what I've got going on. I've created a contact form that both sends the contents to someone's inbox, and saves a record of it in a database table. The problem is that the site is hosted on someone else's server, but the database is hosted on OURS. So far, all the database work I've done has been on the localhost. So what I need to know is: How do I setup, or what do I need to setup, in order to allow permission for the contact form from another server to save into my database on my server? What does the php connection settings look like in this case?
×
×
  • 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.