Jump to content

Search the Community

Showing results for tags 'values'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 13 results

  1. "status": "success", "data": { "network": "DOGE", "prices": [ { "price": "0.00003556", "price_base": "LTC", "exchange": "cryptsy", "time": 1401185325 } ] } I know I can access the top value like this. echo $access->status; But how do I access the sub values underneath? The ones in "data"?
  2. I have a multidimensional array, lets say it's consisting of arrays for groups of balls and then with the key as the number of the ball and then subkeys for color and size, something like what can be seen below (slightly simplified). If I want to select as many balls as possible, based on their size, but there has to be 1) at least one ball from each group and 2) the number of balls from each group multiplied with each other can't be more than lets say 20, and also 3) one of the groups has to have only one single ball selected (to maximize the number of balls selected in total). I know the basics about arrays and foreach loops and so on but how would I go about checking for these above mentioned limitations? Array( [Group1] => Array ( [1] => Array ( [color] => 'blue' [size] => 1.25 ) [2] => Array ( [color] => 'red' [size] => 1.59 ) [3] => Array ( [color] => 'red' [size] => 1.20 ) [4] => Array ( [color] => 'green' [size] => 1.91 ) [5] => Array ( [color] => 'blue' [size] => 1.73 ) ) [Group2] => Array ( [1] => Array ( [color] => 'red' [size] => 1.84 ) [2] => Array ( [color] => 'red' [size] => 1.21 ) [3] => Array ( [color] => 'green' [size] => 1.17 ) [4] => Array ( [color] => 'green' [size] => 1.46 ) [5] => Array ( [color] => 'blue' [size] => 1.70 ) ) [Group3] => Array ( [1] => Array ( [color] => 'red' [size] => 1.04 ) [2] => Array ( [color] => 'yellow' [size] => 1.99 ) [3] => Array ( [color] => 'orange' [size] => 1.07 ) [4] => Array ( [color] => 'blue' [size] => 1.12 ) [5] => Array ( [color] => 'blue' [size] => 1.18 ) ) [Group4] => Array ( [1] => Array ( [color] => 'blue' [size] => 1.66 ) [2] => Array ( [color] => 'blue' [size] => 1.24 ) [3] => Array ( [color] => 'blue' [size] => 1.45 ) [4] => Array ( [color] => 'blue' [size] => 1.42 ) [5] => Array ( [color] => 'red' [size] => 1.38 ) ))
  3. Hope someone can help, I am trying to add up all the values of a variable in a PHP while loop and have tried several approaches but none seem to work. Hopefully someone can point out what the correct method is. I've set up some code to pull the pay rate from a MySQL table, and then calculate that person's earnings based on the amount of time they spend on a particular job. That works fine: while ($row = $getrate->fetch_assoc()) { $staffrate = $row["Rate"]; $earnings = ($staffrate/3600) * $jobeventtimeseconds; $earningsformatted = number_format($earnings, 2); } However there may be a number of jobs for different people with different rates, so I want to add all of these up and output the total. So for example if I had values of 125.00, 35.50 and 22.75 I want to show 183.25 as the total. So I tried a few things I found on forums on the subject: $totalearnings = 0; foreach($earningsformatted as $key => $value) { $totalearnings += $value; } echo $totalearnings; That didn't work so I tried another method that someone suggested: $total=array($earningsformatted); echo array_sum($total); The 2nd method outputted just the last individual value, the 1st method didn't work at all. Does anyone have a working method that can be used to do this? Thanks
  4. Hi Guys I am a rookie here... I have a function which gets information from a postgres database. And returns an array. But how do I echo a single value from the array returned by the function. Please see function below: function getDate($campid) { global $conn,$agencies; $return=array( 'date'=>'', ); $sql = "SELECT tsc_date_completed FROM tasks_completed WHERE campid = '".$campid."' AND tsk_id = 10 ORDER BY id DESC LIMIT 1"; $r = pg_query($conn,$sql); if ($r) { $d = pg_fetch_array($r); if (!empty($d)) { $return['date'] = $d['tsc_date_completed']; } } @pg_free_result($r); return $return; }
  5. Code what i made so far. $inputText = 'This is testing http://www.youtube.com'; $allowedDomains = 'www.google.com youtube.com/ http://www.test.org'; $array = preg_split('/[\s]+/', $allowedDomains); $regex = '';//Need this line if(preg_match($regex, $inputText)){ print 'Domain match!'; }else{ print 'Domain not match!'; }
  6. Hello there, I'm really new at PHP and I've been reading several beginner tutorials so please accept my apologies for any stupid questions I may ask along the way. I've gotten as far as installing XAMPP, set up a database plus PHP form and I'm struggling to figure out how to insert values from an array into my database. I've learnt the code in one particular way (see beginner tutorials) so I was wondering if you could help me keeping this in mind. I know there'll be a million better ways to do what I'm doing but I fear I will be bamboozled with different code or differently structured code. Anyway the tutuorials I'm reading don't see to cover how I can insert an array of values into my database, just singular values. In the attached file, I have 10 rows of 2x text inputs (20 text inputs total). Each row allows the user to enter a CarID and CarTitle. I've commented out the jQuery which validates the inputs so I can build a rudimentary version of this validation with PHP. I thought that because the line $sql="INSERT INTO carids_cartitles (CarID, CarTitle) VALUES ($id, $title)"; is inside the foreach, means that for each pair of values from the form it'd insert to the database. It doesn't do this. If I enter two or more CarIDs and CarTitles, only one pair of values gets saved to the database. I'm sorry if I haven't explained this well enough, any questions please let me know. Many thanks for your help in advance. form.php
  7. Hi, I hope you are well I have a dropdown menu and the next part of the form is checkboxes. I would like to make it so that what ever option you choose with the dropdown menu, must limit the amount of check boxes you can tick. So if you choose a package from the dropdown menu where you would like to play 2 courses, in the next part of the form you are only allowed to tick 2 courses from the tick boxes. So if you pick two courses, the other must fade out or some pop up message must appear to tell the user he can only choose two courses, or even after you hit the submit button it the error message can appear to choose the right amount of courses. Is this possible with PHP or is there some jQuery plugin that can do that. Thank you
  8. Hi all, I have a query.... have to get all the attribute names as well as values of textbox in json format. Below is the sample example how can i need to get the output... <form action="" method="POST"> <input type="text" name="someName" id="someId" maxlength="12"> <input type="submit" name="submit" value="Submit"> </form> When i click the submit button, i nedd to get all input types whether it could be textbox / textarea / checkbox / radio button in json format. Example: When i click on submit button, the output will be like these..... {"type" : "text", "name" : "someName", "id" : "someId", "maxlength" : "12"} If any body knows, Please give me some suggention with examples. Thanks in advance....! :'( :'(
  9. The program MUST use functions to calculate the cost of the conference, and to calculate the cost of meals. The functions should return the calculated costs back to the main program. I am trying to use checkboxes to for the input.. Im new to all of this trying to get it right.. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <style> body { color:black; font-size:20px; } h1 { color:orange; text-align:center; font-size:30px; } p { font-family:"Times New Roman"; font-size:20px; } </style> <title>MAJOR PROJECT 1 PHP </title> </head> <body> <h1>Nerd Roundup </h1> <form method = "POST" action = "http://localhost/Assignments php class/calculationprogress.php"> <fieldset> <label> Please type your first name: </label> <input type = "text" name = "fName" value = "" /> <br /> <label> Please type your Last name: </label> <input type = "text" name = "lName" value = "" /> <br /> Please type your city: <input type = "text" name = "city" value = "" /> <br /> Please type your State: <input type = "text" name = "state" value = "" /> <br /> Please type your Zipcode: <input type = "text" name = "zipCode" value = "" /> <br /> <label for="other">Anything else you want to add?</label> <textarea id="other" name="other"></textarea><br /> <fieldset> <legend>HOW MANY DAYS</legend> <input type = "checkbox" name = "chkOne" value = "100.OO" /><label>ONE DAY $100.00</label> <input type = "checkbox" name = "chkTwo" value = "175.00" /><label>TWO DAYS $175.00</label> <input type = "checkbox" name = "chkThree" value = "325.00" /><label>THREE DAYS $325.00</label> <br /> <fieldset> <legend>DO YOU WANT THE MEAL PLAN?</legend> <input type = "checkbox" name = "mealPlan" value = "mealPlan" /><label>YES</label> <input type = "checkbox" name = "" value = "no" /><label>NO</label> <br /> <br /> <h1>NERD TRACK</h1> <select name = "track"> <option value = "PROGRAMMING TRACK">PROGRAMMING TRACK</option> <option value = "NETWORKING TRACK">NETWORKING TRACK</option> <option value = "SECURITY TRACK">SECURITY TRACK</option> <option value = "WEB TRACK">WEB TRACK</option> </select> <button type = "submit"> place order </button> </fieldset> </form> </body> </html> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <style> body { background-color:#FF00FF; } h1 { color:orange; text-align:center; } p { font-family:"Times New Roman"; font-size:20px; } h1 {text-align:center; } </style> <title>Assignment3</title> </head> <body> <h1>Personal Information </h1> <?php // define the variables $fName = $_POST["fName"]; $lName = $_POST ["lName"]; $city = $_POST ["city"]; $state = $_POST ["state"]; $zipCode = $_POST["zipCode"]; $other = $_POST ["other"]; $chkOne = $_POST["chkOne"]; $chkTwo = $_POST["chkTwo"]; $chkThree = $_POST["chkThree"]; $mealPlan = $_POST[""]; $confTotal = 0; $no_errors = TRUE; $total = 0; //begin form filter if (filter_has_var(INPUT_POST, "chkOne")){ print "<p>ONE DAY CONFERENCE</p> \n"; $total += filter_input(INPUT_POST, "chkOne"); } if (filter_has_var(INPUT_POST, "chkTwo")){ print "<p>TWO DAY CONFERENCE</p> \n"; $total += filter_input(INPUT_POST, "chkTwo"); } if (filter_has_var(INPUT_POST, "chkThree")){ print "<p>THREE DAY CONFERENCE</p> \n"; $total += filter_input(INPUT_POST, "chkThree"); } //end $total if (filter_has_var(INPUT_POST, "mealPlan")){ } if (filter_has_var(INPUT_POST, "noFood")){ } // do they want the meal plan $track = filter_input(INPUT_POST, "track"); // what conference track are they on if(empty($fName)) { $no_errors = FALSE; echo '***FIRST NAME FIELD REQUIRED***** <br />' ; } //get users first name if(empty($lName)) { $no_errors = FALSE; echo '****LAST NAME FIELD REQUIRED***** <br /> '; } // get users last name if(empty($city)) { $no_errors = FALSE; echo '****CITY FIELD REQUIRED***** <br /> '; } //get user city if(empty($state)) { $no_errors = FALSE; echo '***STATE NAME FIELD REQUIRED***** <br /> '; } //get user state if(empty($zipCode)) { $no_errors = FALSE; echo '****ZIPCODE FIELD REQUIRED***** <br /> '; } //get user zip code if(empty($other)) { $no_errors = FALSE; echo '****TEXT FIELD REQUIRED***** <br /> '; } //get user additional comments if ($no_errors == FALSE) { echo "<br> <a href='major1progress.html'>Go back to form</a>"; } // check the fields are all filled if not direct back to form page //beging function calculateCost function calculateCost() global $total; $total = filter_input (INPUT_POST, "total"); $mealPlan = filter_input (INPUT_POST, "mealPlan"); IF (! filter_has_var (INPUT_POST, "mealPlan" )){ && $total =="100" ,$confTotal = $total+= 50; } else if ($total=="175"){ $confTotal = $total +=75; } else if ($total =="225"){$confTotal = $total +=100; } //end function cacluclateCost //end if //1 to 1000 $confId = rand(1,1000); //generate conf id number if ($no_errors == TRUE) { print " <p> $fName $lName, <br />you have registered for Nerd Roundup 2013<br /> your planned track is $track<br /> <br /> You choose -confDay<br /> with -mPlan<br /> The total cost is: \$$confTotal <br /> I hear the climate around $zipCode is great this time of year. <br /> Please make sure to bring cash, or your credit card to pay for the conference on the first day<br /> Your additional comments are as follows: $other <br /> </p> <p>Your Nerd Roundup confirmation number is $confId .</p> <br /> \n"; } //check and see is the form filled out if it is then print stuff ?> </body> </html> //beging function calculateCost function calculateCost() global $total; $total = filter_input (INPUT_POST, "total"); $mealPlan = filter_input (INPUT_POST, "mealPlan"); IF (! filter_has_var (INPUT_POST, "mealPlan" )){ && $total =="100" ,$confTotal = $total+= 50; } else if ($total=="175"){ $confTotal = $total +=75; } else if ($total =="225"){$confTotal = $total +=100; } //end function cacluclateCost
  10. Hi, I am trying to produce a result that requires 2 seperate queries to get the values required to produce the result. It works if I hard code the BETWEEN date values but when I try to pull them from the `Reportrange` table no results are returned. I am using includes to set variables, open and close the connection. (also works if BETWEEN dates are hard coded) See below: The idea is that it can search the `DMCstats` table for a count of each distinct 'gender' value WHERE the 'encdate' matches the range set in `Reportrange` record#1(---->bdate and edate) I think the issue is with the way I am calling the variables $bdat , $edat for $result My apologies in advance if this post does not conform to this forums expectations, its my first post here, feel free to enlighten me! Thanks in advance to all those donating their time for the greater good! Open Connection Include: <?php //Conection Info $con=mysqli_connect("localhost","******","******","******"); // Check connection if (mysqli_connect_errno()) echo "Failed to connect to MySQL: " . mysqli_connect_error(); ?> Close Connection Include: <?php mysqli_close($con); ?> Date Variables include: <?php include 'openconnection.php'; $bdat=mysqli_query($con,"SELECT bdate, FROM `ReportRange` WHERE cf_id=1"); $edat=mysqli_query($con,"SELECT edate, FROM `ReportRange` WHERE cf_id=1"); include 'closeconnection.php'; ?> Gender Query: //Open Connection include 'openconnection.php'; //Set Variables include 'datevars.php'; //Query $result=mysqli_query($con,"SELECT gender,encdate, COUNT(gender) AS gender_count FROM `DMC_Stats` WHERE encdate BETWEEN " . $bdat . " AND " . $edat . " GROUP BY gender"); //Output to html echo "<table border='1'> <tr> <th>Gender</th> <th>Total</th> </tr>"; while($row=mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['gender'] . "</td>"; echo "<td>" . $row['gender_count'] . "</td>"; echo "</tr>"; } echo "</table>"; //Close connection include 'closeconnection.php'; ?> Regards
  11. I am using some PHP API script to send a text message and in the <message> tags I want to get 2 values from the url (e.g. (URL address blocked: See forum rules)/sms.php?Name=John&Age=28). Problem is this that in between the php script there is a script of SOAP (I think). Sorry I am not good at programming. <?php set_time_limit(0); //URL to call define('ZONG_DOMAIN_URL', "(URL address blocked: See forum rules)"); $post_data='<?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="(URL address blocked: See forum rules)" xmlns:xsd="(URL address blocked: See forum rules)" xmlns:soap12="(URL address blocked: See forum rules)"> <soap12:Body> <SendSMS xmlns="(URL address blocked: See forum rules)/"> <Src_nbr>9145216598</Src_nbr> <Password>123</Password> <Dst_nbr>913115383168</Dst_nbr> <Mask>STAFF</Mask> <Message>Test Message from API</Message> <TransactionID>'.rand().'</TransactionID> </SendSMS> </soap12:Body> </soap12:Envelope>'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, ZONG_DOMAIN_URL ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt($ch, CURLOPT_POST, 1 ); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data ); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/soap+xml', 'charset=utf-8')); echo $result = curl_exec ($ch); ?>
  12. Hi all I have a function below that searches an array and assigns it to $totalmonthlycost. I need to know how I get the array key of the chosen array value ($m12 - $m60) How do I return the array key in the below code? $monthvalues = array($m12,$m18,$m24,$m30,$m36,$m42,$m48,$m54,$m60); function closest($monthvalues, $number){ #does the array already contain the number? if($i = array_search( $number, $monthvalues)) return $i; #add the number to the array $monthvalues[] = $number; #sort and refind the number sort($monthvalues); $i = array_search($number, $monthvalues); #check if there is a number above it if($i && isset($monthvalues[$i-1])) return $monthvalues[$i-1]; //alternatively you could return the number itself here, or below it depending on your requirements } $totalmonthlycost = closest($monthvalues, $idealcostpermonth); Thanks for your help. Pete
  13. Hi all, this my first post. I'd like to insert values of checkboxes as a string using a comma as a delimiter. So I have these checkboxes: <input type="checkbox" class="checkbox" name="box[]" value="1">One</input> <input type="checkbox" class="checkbox" name="box[]" value="2">Two</input> <input type="checkbox" class="checkbox" name="box[]" value="3">Three</input> Then I'd have a code like this, which is obviously wrong hence I wrote it for illustration only, it should also have an explode function for the delimiter: if (isset($_POST['box'])) { $newbox = array(); foreach($_POST['box'] as $boxArr){ array_push($newbox, $boxArr); } $query="INSERT INTO boxesTable (boxes) VALUES ('$newbox')"; } Any help would be much appreciated.
  • 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.