Calculating The Selected Prices In A Listbox
I am wanting to know how I can add the all of the selected prices in a
listbox? I need to add the selected prices altogether. The listbox
should have only the names of the products. The listbox should be like
below:
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Calculating Prices, Dollar Format?
I have some code which basically does some very simple addition and multiplication in order to get the total price. This is working fine, it's the way that it outputs it that troubles me. i.e 2.25 + 2.25 = $4.50 > but it just outputs it as $4.5 another example: 10 * 2 = $20.00 > but again it outputs it like $20 [ I need it to ouput like 20.00 but it does 20 instead. 6.5 instead of 6.50 etc. ] So say the total price is $total I was getting around it by just putting: $$total.00 but obviously with this it has to be a number like 10.00, 20.00 or 15.00 if it's 10.50 or 10.75 it doesn't work. In CF there is a 'dollar format' which can be used when outputting things like this. Is there a similar type function in PHP or an easy way around this?
How To Use Selected Data In The Listbox For My Query..
I have a multiple select listbox and I pass the data using array in php. How can I use these records to my query, or in one select statement. For an example: I have a listbox of item codes; the user selects an item code/s to view it's inventory. The selected itemcodes will be pass on php using array and these records will be used as a query or search items on my database.
Multiple Selected="selected" In A List.
I have a database with 1 to many and the many is a list with multiple selects in a list. When I click on a master record I have as part of my form the select statement for the multiple choice list. I want the list to highlight the multiple chosen values. here is part of the code. $dresscat = specdresscat($dresstypeid); //this is the query to get the values in the detail table $drcatrow = pg_fetch_array($dresscat);// the array for the detail table. <select name="stages[]" multiple="multiple"> <?php $allstages = allstages(); // this is a function to query my database to get the value for the list. while ($allstagerows=pg_fetch_array($allstages)) { $eachstage= $allstagerows["stageid"]; $specstage= $drcatrow["stageid"]; // this is the point I need help if ($specstage == $eachstage){ ?> <option value=<?php echo $eachstage;?> selected="selected"><?php echo allstagerows["stage"]?></option> <?php }else{ ?> <option value=<?php echo $eachstage;?>><?php echo $allstagerows["stage"]?></option> <?php } } ?> </select>
Listbox Problem
I am using two listboxes with multiple selection. I have moved the contents from the first list box to the second list box. But I am not able to get the value from the second list box.
Listbox And Its Selection
im trying to create a webpage using mysql and php. im using the below code to populate a listbox with playernames held in my database. once i select a name; im trying to make the page gather the relevant information from that users details to be displayed on the same page. for example if i select "MoFish" from the listbox, i want it to echo all MoFish's details in the page such as his: "age" "height" "weight" if i select "Berty" i want it to echo bertys details. how can i acheive this? Code:
Retaining Value In Listbox Array
i have designed an application that is a dynamic submission form. i have text fields and listboxes. now i am able to retain the values of the listboxes when i populate the listbox "manually"(single listbox) like this... <select name="title"> <option value="1"<?php if ($_POST['title'] == Ƈ') { echo 'selected="selected"' } ?>></option> <option value="Mr"<?php if ($_POST['title'] == 'Mr') { echo 'selected="selected"' } ?>>Mr</option> <option value="Mrs"<?php if ($_POST['title'] == 'Mrs') { echo 'selected="selected"' } ?>>Mrs</option> <option value="Mstr"<?php if ($_POST['title'] == 'Ms') { echo 'selected="selected"' } ?>>Ms</option> </select> Now this works flawlessly for example if the firstname text box is left blank and the user clicks "send" then validation occurs and the value in the "title" listbox is maintained and user is prompted to fix the error. However this does not work when i use a listbox that is dynamically generated in an array. <select name="title[]" //note title[] = an array of titles within the form <option value="1"<?php if ($_POST['title'] == Ƈ') { echo 'selected="selected"' } ?>></option> <option value="Mr"<?php if ($_POST['title'] == 'Mr') { echo 'selected="selected"' } ?>>Mr</option> <option value="Mrs"<?php if ($_POST['title'] == 'Mrs') { echo 'selected="selected"' } ?>>Mrs</option> <option value="Mstr"<?php if ($_POST['title'] == 'Ms') { echo 'selected="selected"' } ?>>Ms</option> </select> But my text boxes work(retain value on POST in the case there is invalid input on the form) <input name="fname[]" type="text" value="<?php echo $firstname;?>"/> i have tried a couple of scenarios and in my debugging i see that if i chose the "Mr" option and 'echo' to see if it is POST'ed, it is. However when the form reloads it reverts to the default empty value of the listbox? thought maybe something like //code above <option value="Mr"<?php if ($_POST['title'][$count] == Ƈ') { echo 'selected="selected"' } ?>></option> //code below But nothing...So how to retain the value of the listbox?
Determine Contents Of Listbox
How can I determine the values of a listbox, both unselected or selected after submitting the form: Code: <select name="sel1" size="10" multiple="multiple"> <? PHP code populates listbox ?> </select> Do I have to use Javascript to determine the contents, like in the pseudo code Javscript below. But how would you pass the Javascript return value to PHP? Code: function listBoxContents(sel1) { var selLength1 = sel1.length; var valuesPresent1 = new Array(sel1.length-1); var i; for(i=0; i<=selLength1-1; i++) { valuesPresent1[i]=sel1.options[i].valueOf(); } return valuesPresent1; }
File Listbox Of Directory
Is there anyway someone could provide code to a soultion i need here. Basically i have a directory of all these files uploaded, and i need some sort of way for a php file to list all the items in that directory somehow, it doesent need to be special, i just need them listed so my users can see what is uploaded into that directory.
Create Listbox Depending On Variable
I currently have a variable called $NumPlayers which contains a number between 4 and 8; depending on this value; i would like to create this amount of listboxes on my page. For example if the value of $NumPlayers is 6; I would like 6 listboxes to be displayed on the page with names such as "Lstbox1" "Lstbox2". I'm a bit clueless where to start; and was hoping someone could point me in the right direction.
Adding Multiple Listbox Items To Mysql
I want to be able to select multiple items from a listbox in a form and send the result to mysql blob. I only get one item to the bd. Here is part of the script. Item: <select name="itm" align="bottom" multiple size="2"> <option value="item1">item1</option> <option value="item2">item2</option> <option value="item3">item3</option> <option value="item4">item4</option> <option value="item5">item5</option> </select> "Insert into xyz set itm = '$itm'";
Change Record When User Chooses Option From Listbox
I have a combobox which has different peoples names which are pulled from fields in a database. Can anybody please show me some code that will change the recordset so say for example there were two records in the DB with three bits of data name, number and telephonenumber: John 10 01234567544 Frank 34 07883922332 and somebody selects john from the select box that in the two fields it shows 10 and 0123... and 34, 078839..... if they select frank.
Calculating
how can I solve this: I have filled variable total (total oredr) This variable I must recalculate before sending, ie (look at HERE word) total = 100 Example --------------------- function process_button() { global $order; $process_button_string = web_draw_hidden_field('x_login', blah blah ....) . HERE web_draw_hidden_field('x_amount', number_format($order->info['total'], 2)) . Here must total be not 100, but divided with 5.85 How can I do that? I have tryed web_draw_hidden_field('x_amount', number_format($order->info['total/5.85'], 2)) . but did not work
Calculating Age
Im trying to pull a date of birth from my database (mysql) and use this to calculate a users age for display on the page. At the moment i'm storing the date of birth of each user in three different INT fields in my table: Year - INT - 4 Day - INT - 2 Month - INT - 2 here is the code im trying to use to calculate the age: Code:
Calculating
when calculating i am trying to add to variables together like this but it not work why. $total = ($a+$b);
Calculating
<?php $ok = "60"; if ($ok>30) || ($ok<=50){ print "30-50"; } else { print "60-over"; } ?> what is wrong ?
Calculating Colors
wondering if anyone has built or knows of a script out there that will calculate and output all of the websafe colors as hex values.
Calculating Duration
I'm trying to figure out how to calculate the duration when given 2 times. What I have is a script shown below in which you select a start time and end time from a drop down box, but would like some assistance on how to calculate the duration. An example: Start Time: 8:30 End Time: 9:30 Result: 1 Hour (60 mins) <tr> <td><b>Select Operation Start Time</b></td> <td><select name="start_time"> <option value="null">Select One</option> <? $start=mktime(8,30,0,date('m'),date('d'),date('Y')); for($i=$start;$i<=$start+32400;$i+=900) { $time=date("H:i",$i); echo "<option value=$time>$time</option>"; } ?> </select></td> </tr> <tr> <td><b>Select Operation End Time</b></td> <td><select name="end_time"> <option value="null">Select One</option> <? $start=mktime(8,30,0,date('m'),date('d'),date('Y')); for($i=$start;$i<=$start+32400;$i+=900) { $time=date("H:i",$i); echo "<option value=$time>$time</option>"; } ?> </select></td> </tr>
Calculating Tim - Easy For You! =)
I found out that i can calculate the dates e.g $today = strftime('%Y%m%d',mktime(0, 0, 0, date("m"), date("d"), date("Y"))); $yesterday = strftime('%Y%m%d',mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"))); $dayBeforeYesterday = strftime('%Y%m%d',mktime(0, 0, 0, date("m"), date("d") - 2, date("Y"))); $dayBeforeTheDayBeforeYesterday = strftime('%Y%m%d',mktime(0, 0, 0, date("m"), date("d") - 2, date("Y"))); and so on........ This works even if we have the 1st of August $yesterday gives me the 31st july. Can I do this with times also? e.g. Iit it now 17:06 an i want to make minus 20 min (like abopve minus 1 day) and I want the result to be 16:46. I tried the above example, wit %H%M but it does not work?
Calculating Distance
Does anyone know of a service or script where you can enter two addresses and get a distance between, or do so by range? I know mapquest has something, but I'm looking for something a little less expensive and basic? If anyone has any ideas, that would be great. BTW, it must work with PHP and MySQL
Calculating Percentages?
<?php $value = '100'; $discount_value = '80'; // Value AFTER discount ?> What % do they save? How do I calculate this?
Calculating Free Space Available
Is there a way to tell how much space is remaining available for files? I'm working on a script that takes uploaded images and adds them to a database, but I'd like to check and make sure there's room for it first. I think there's probably going to be some type of issue with quotas, because that's how I found the problem. A user had uploaded a test version and got an error that a folder could not be created because of insufficient space remaining. And I know I could probably exec() out to df or something similar, but I would like it to work on Windows servers as well, so I'd prefer to keep it all in PHP code if possible.
CALCULATING Row Values To Get A Total
My problem is,, that i have a PHP script that displays a table the table has the following colums firstname,surname,boots,hospital,woolworths,br,other, total the firstname and surname are grabbed from the database when the page loads, what i want is for the user to enter values in the boxes under the colums boots,woolworths,hospital etc then when they click submit,the page is refreshed, data submited into the database, bu them redisplayed in the table the values are calucated and each user is then given a total number of hours worked at those places. im really stuck guys, havent a clue how to go about this. so an example would be F S boots Hospital woolworths other total JOE BLOGS 0.8 0.8 0.8 0.8 HELP me 0.1 0.5 0.5 0.5 submit is pressed, data entered into the database, then page redisplayed with the total column totaled up. F S boots Hospital woolworths other total JOE BLOGS 0.8 0.8 0.8 0.8 3.2 HELP me 0.1 0.5 0.5 0.5 1.6
Calculating CIDR Blocks
I have array of free IP addresses. One IP per line. Now I'm trying to share them to CIDR blocks /24 - /32. For example: if 1.1.1.0-1.1.1.255 is free, it returns array('.1.1.0/24') but let's say that 1.1.1.1 is used, then function should return array('.1.1.128/25', '.1.1.127/26', '.1.1.32/27', etc until free block doesn't fit). Here's my current code:
Calculating Future Dates
I have a variable ($today) that is simply $today = date("m/j/Y"); I want to get another variable for x months down the line, but using the php.net reference of the mktime and date command, my second date, as follows comes out in a large number. How can I make sure it is forwarding the date properly, and format it like mm/dd/yyyy? This is the line from php.net reference page. I need this to calculate properly, and format mm/dd/yyyy - just like my variable up top. $two_months_from_today = mktime(0,0,0,date("m")+2 ,date("d"),date("Y"));
Calculating Distance With Zipcodes
I have a DB of zipcdoes that includes it's lat. and long. and some other stuff. Is there an easy way of searching "within a 100 miles" etc of someone's location?
Calculating A Few Numbers Via A Form...
I am trying to put up a script where users enter certain info into a form and after they enter the info in, they click submit and the script makes a certain calculation using those numbers. For instance, the form should look something like this: Name: Age: Height in inches: Weight in pounds: Shoe size: Then the script takes the 4 numbers inputted in the age, height, weight, and shoe size rows and does this calculation and shows the user the result: (Height + Weight) * Age) / Shoe Size
Calculating Days Between Two Dates
I need to calculate the numbers of days (only the number of days) between two days, one a variable $row['user_cp_name'] in the format MM/DD/YY, and another, the current time. I've tried a bunch of tutorials on the internet and none seem to work properly.
Calculating Correct Time
Lets start off by giving you my code (Well the important sections of it!): <?php /**/# Total Time /**/$query = "SELECT sum(hours) FROM flights ".$condition; /**/$result=mysql_query($query); /**/$blcktime = number_format(mysql_result($result,0)); /**/$query = "SELECT sum(minutes) FROM flights ".$condition; /**/$result=mysql_query($query); /**/$blckmins = number_format(mysql_result($result,0)); echo "$blcktime:$blckmins"; ?> Okay this part works. Like if there is an entry that has 20 hours in hours table and 50 minutes in minute table it displays 20:50, but my problem is if there are more than one record (Which there will be) if the previous was still true and another record had 1:30 the total would be 21:80 but this of course is not correct addition of time. And this is not a 24 hour clock it simply displays the time someones been in a game so it can go lke 300:56 too. Now how would I get it so if the $minutes were greater than 60 and divisible by 60 it would add the correct numbers to the hours like $hours = $hours + $times_divisible; or something like that! I am okay with if..else..elseif statements but that would take forever to write. thats why I need a looping sttatement but I havent got a clue how to write it.
Calculating Random Numbers?
I have an average. Everybody knows that the formula to find an average number is: x = (a + b + c + d) / 4 x being the average. Say I already have an average, like this: 95 = (a + b + c + d) / 4 How would I generate four random numbers added together, divided by four, to get an average that equals 95?
Calculating Date Of Weekly Meeting
Just say I have a chat session on my site at the same time every week (eg - Friday 4pm EST). How can I calculate the time/date of the next meeting. Eg - if the current time is Thursday morning, it'll be the following day. If the current time is Friday afternoon, it needs to calculate the session in 7 days time (eg - that Friday's session has already ended). So is there a way I can calculate the date of the next session based on the current time/date? And how long till the next one? So my output would be "the next meeting is in 3 days, 22 hours and 12 minutes, on Friday 23 May 4pm"
Calculating Days From NOW From Future Datestamps
Hi All,I have datestamps of the format 11202006 (November 20th 2006) in the DB. All these datestamps are of the future. With reference to the datestamp, I need to query the database for all entries that are 90, 60, 29, 28, 27, 26, ... 02, 01 days away from NOW. So, if there are entries with datestamps 90 days from NOW, they will need to be displayed.The query will be run everyday through a CRON script. How do I create the queries? Would there be multiple SELECT queries? Eg: 90, 60, 29 .. 02, 01
Calculating Form Speed Process.
Each user have it's own technique with processing form (saving loading editing and so on). Let's think what we have 15 fields of different data. How much time you spend on scripting this form? To more concretely let's think what it's a hotel class!
Calculating Some Formulas From Database Data
I am doing a project on beetle diversity and need to calculate a few diversity indices for a load of data i have collected. I thought that maybe i could make a program in php to do that for, and save a bit of time (as well as prevent calculation errors). I imagine this could be quite a bit of programming but i have dreamweaver to help me. Now what i have is a MySQL database full of data on beetle diversity with the following tables: Date - the date the sample is from Habitat - one of 9 habitats that i am testing between (ie. grass, stones, birch woodland, etc) Replica - ie 'Repeats', there were two replicas for each habitat from each date (A and B) Trap number - from each replica there were 6 traps Species - the species of beetle that was found in the trap (of course there are often more than one per trap) Number of Individuals - the number of individuals of that species found in that trap What i need to do is calculate Shannon-Weiner, Shannon Equitability and Margalefs Diversity indices for each replica from each date for each habitat (the data for the individual traps will be merged together). I have an idea of how to do it but what i am stumbling at is how to create a recordset which will calculate the total number of individuals for that species from that replica, date & habitat (I) and calculate the number of different species for that replica, date & habitat (S). Once i have S and I i should be able to write the formula in php to create the indices. Ideally this could be done in a way to allow for each repeating areas to be assigned so that all of the indices for that habitat (for each date and replica) could be shown on one page (to save a lot of clicking).
Calculating Dates From A Date In The Database?
I`m using this format of dates: $entry_date = strftime("%B %e, %Y %H:%M:%S", time()); And that time gets saved into the database (birth in ownedpets database): $res = mysql_query("SELECT id, owner, pet_type, pet_name, birth, food, play, datetime FROM ownedpets WHERE id=$id"); $rows = mysql_fetch_row($res); mysql_free_result($res); So let`s say in this case, the database birth value ($rows[4]) is October 19 2007 20:00:00. What do I do to tell php to check to see if the current date (hours and all don`t matter) is 21 days after the $rows[4]? Why I`m looking for this task: For the pets system, if the pet is 21 days after it`s birth, it will be an adult. But if it is not 21 days after it`s birth, it will still be a baby.
Calculating A Fictional Date, Not Working In PHP 4.4.4
I'm attempting to calculate the date for an online game that's set in the future. The games time is 4 times faster then our time so to figure it out I recorded the exact date/time in the game and the exact date/time in real time. Then all I need to do is multiply the seconds by 4 to the fictional date. Here is what I currently have: $realTime_start = mktime(17, 44, 20, 9, 25, 2007); $realTime_current = mktime(date("H"), date("i"), date("s"), date("n"), date("j"), date("Y")); $fomTime_start = mktime(14, 57, 0, 12, 8, 2007); $seconds = ($realTime_current - $realTime_start) * 4; $fom_date_full = date("H:i jS F Y",(strtotime("14:57 8 December 2007") + ($seconds))); $fom_year = substr($fom_date_full, (strlen($fom_date_full) - 4), strlen($fom_date_full)); $fom_year = 2404 + ($fom_year - 2007); $fom_date = date("H:i jS F",(strtotime("14:57 8 December") + ($seconds))); $fom_date_full = $fom_date." ".$fom_year; This works perfect in PHP 5+ but not on a server I'm using at the moment for testing (which uses PHP 4.4.4). I've referred to the manual to check the functions haven't changed from these versions and by the look there hasn't been any major changes. At the time of writing this the correct output is "22:18 17th January 2405" and the PHP 4 output is "02:17 10th February 2367".
Calculating An Equation Stored In A String
I am making a simple web-based interface that will allow users to add shapes into a DB. This will involve uploading a shape description, a jpeg of the shape and an equation for the area of the shape. It doesn't have to be too dynamic so i've kept the equation as a standard format, using x0 -> xn as the variables for the equation. For example, the equation for the area of a square would be x0 * x0 ( length * length ) as there is only one variable for deriving the area of a square. A rectangle would be x0 * x1 ( length * height ) etc. I then have code that reads the equation and counts how many variables, assigns names to these variables etc. This part is all fine. When the user selects a rectangle and enters 2 as variable1 and 3 as variable2, the code will retrieve x0*x1 as the rectangle's equation, replace the x0 with 2 and x1 with 3, using str_replace() function. This all works fine. So, I'm left with a string stored under a variable with value 2*3 The only problem is that i don't know how to calculate that string. I don't know how i would return a value of 6. Will it not always return the value as "2*3" because it is a string?!?
Calculating Against SQL Database, Returing Values
I was interested in trying to calculate against an SQL Table and return values that matched within the calculation. What i am trying to put together is a Zip Code Locator. I have a table "AREA" of Lat, Long and Zip Code numbers for the area im interested in. I also have a table "LOCATIONS" of Lat, Long and Zip code numbers for 25 different locations with data about Store Name, Address, etc. What i would like to do is have a user input thier Zip code and that would launch one query, which would pull down the Lat & Long from the table "AREA". I would like to then Query the database "LOCATIONS" and calculate the distance between them using a formula. So it would do this. User submit--->$_POST['zip'];---->Query and bring down LAT, LON from "AREA" table--->Query the LOCATIONS table, bring down all values---->calculate LAT, LON, from AREA table minus LAT, LON from the LOCATIONS table and populate to Variables the values that were LESS THAN 5 or something.
Calculating Span Between Earliest And Latest Dates
I'm wanting to find the span between the earliest and latest date in my database so I can calculate how many applications are filled out every day. It would be incredible if I could exclude weekends, but that's not necessary at this point. When I'm using a "date" type field in MySQL, I can use this ugly code:
Calculating Start And Ending Dates For A Week
Given a week number, how do you derive the starting date and ending date? I am trying to get the reverse of the yearweek function of MySQL. The yearweek function returns the year and week given a date. For example, yearweek(񟭂-08-01') returns 200231.
Math: Calculating Latitude And Longitude Between Two Points..
I have a bit of a problem with a pretty complicated mathematical expression. Basically, I'm trying to determine the initial heading between two points on the globe using latitude and longitude of the two points. I already know the distance between the two ($miles). Here's the expression: $Hdg=2*M_PI-acos((sin($lat2)-sin($lat1)*cos($miles))/(sin($miles)*cos($lat1))); When I echo $Hdg, I see: -1.#IND If the expression was working, I should see something like 134.9 for the following latitude/longitude combinations: $lat1 = 33.9780761 $lon1 = -83.9623772 $lat2 = 32.1950556 $lon2 = -81.8695556 $miles = 172.7381359 I can't find any references to what #IND means, so if anyone out there has any ideas, I'd be grateful.
Calculating Time Based Off Speed And Mileage
I am trying to complete a program for calculating time based off speed and distance traveled for creating motorcyle enduro route sheets. I am posting a test page I am working on. I know the formulas are probably wrong for getting the proper times and would appreciate any input. If you run this script the entries work most of the time. The problem is that at 24MPH the display "8 miles at 09:19:59" should have rounded to 9:20:00. This throws all following calculations off by 1 second. Code:
Multiple Select From Listbox And Execute A Sql Query Select Statement
Supposing i have a html form with 2 listbox and i name it status and resolution. So it goes <select name='status[]'>... <select name='resolution[]'> Then i have a another php page. $status = $_POST['status']; $resolution = $_POST['resolution']; Now my question is, how do i do the sql query statement? mysql_query("SELECT * from bugs where status=$status and resolution=$resolution"); The problem is, i select 3 options form the status listbox eg. new, closed, duplicate. And from the resolution, i chose fixed, invalid.
|