Four Fields That Are Dates, Store As An Array
I have a form that has over 100 fields. I have four fields that are dates that I would like to store as an array. When I submit the form I place the dates in the array like so:
$planworkdate = array("mon" => $planworkdate0,"tue" =>$planworkdate1,"wed" =>$planworkdate2,"thu" =>$planworkdate3);
and insert into mysql database. When I try to retrieve the data I get the word Array for the result. What am I doing wrong?
$query = "SELECT planworkdate from general";
$resultall = mysql_query($query);
$planworkdate=mysql_result($resultall,$x,"planworkdate");
print $planworkdate; ...
View Complete Forum Thread with Replies
Related Forum Messages:
Store Form Fields To An Array
i have a form which consists of several fields for name, address, number etc. i use a php form to process this and output it onto a html form. the thing is, i'd like to store the information in an array. so for each user, the array will have their details. and this can be printed on the screen. can you tell me how this is possible. i have seen examples of arrays, but the values are assigned to the variables already.
View Replies !
Two Queries; Counting Fields And Adding Dates.
I have a field, let's call it Field1, that holds duplicated data; what I would like to be able to do is have a query that counts how much of the entries in that field are the same and then declares that count. Does anyone know of a way to do this? Also, I'm looking to define the data type of a field, lets call it Field2, as CurDate (so that whenever an entry is added to that table, Field2 automatically inserts today's date) - Anyone know how I would be able to do this? I would also like another field to be defined as (Field2 + 14 days). Is this possible?
View Replies !
Check If The Dates In The Array $holi[] Matches $evalday (not In An Array)
What I'm trying to do is check if the dates in the array $holi[] matches $evalday (not in an array) but with limited success the data in the array is: $holi[1] = 2006-06-20; $holi[2] = 2006-06-28; $holi[3] = 2006-07-19; $holi[4] = 2008-06-24; $holi[5] = 2006-06-30; $evalday = date("Y-m-d", strtotime("+ 1 days"); if($evalday == $holi) { echo("For the purpose of this excercise, $evalday is a holiday"); }
View Replies !
Store Values In An Array
$a=10; $a=15; while ($a <= $b) { $a++; } The output is 10,11,12,13,14,15 How to store the values of $a(10,11,12,13,14,15) in an sigle array.
View Replies !
Store Classes In An Array?
Is it possible to store classes in an array? I am fairly new to PHP, and haven't found anything either way yet. I have a program that where you can have multiple notes attached to a ticket, which are stored in a database. I would like to just pull all the notes from the database, storing each one in a seperate class, which itself is stored in an array (well, another class, but it's a classList, it's mainly an array). I'm getting an error when I run the page: "Cannot use a scalar value as an array", and "Call to a member function on a non-object". The second is related to the first, as I'm calling a function on the array value. If it is possible, I probably coded something wrong. If that's the case, I'll post some code.
View Replies !
Get Data From The Db And Store It In An Array
I want to have an input field in my Admin CP when you are creating a Forum where you can input a list of numbers (member ids) seperated by commars, like this: Quote1,6,4,8,2 These will be the ids of people who can moderate the Forum and will be stored in the db along with all the other stuff like forum name/description etc. That's easy enough. Now my problem is I need to get that from the db and store it in an array... basically so I can do something like: <?php if(in_array($_SESSION['mem_id'], $forum_moderator_array)) { echo('Congratulations, you are a forum moderator.'); } ?> How can I go about doing this?
View Replies !
Store A Array As A Variable
is there any way that i can store a array as a variable because i dont want to creat a database for thousands of variables. heres what i thought of so far <?PHP $arrayval = "1,3,2,7,4,6,8,15,12,78,96,1203,1029,39509,12999"; $array = array($arrayval); echo $array[1],$array[3],$array[2],$array[5],$array[6],$array[4],$array[7],$array[9],$array[5],$array[10],$array[13]; echo "<hr>"; echo $arrayval; echo "<hr>"; $sum = $array[1]+$array[3]+$array[2]+$array[5]+$array[6]+$array[4]+$array[7]+$array[9]+$array[5]+$array[10]+$array[13]; echo $sum; ?>
View Replies !
What's The Best Way To Store An Array In The Database
I am trying to build a simple tree menu where the main items can be either a link or open up a subList of items which themselves can belinks or open into more submenus and so on. An example is: $ar = array( 'new_user' => 'newuser.php', 'tst1' => array( 'subtst' => 'subtstlink.php', 'subtst2' => 'sublink2.php' ), 'heyhey' => 'heyhey.php', ); I am wondering what is the best way to store that in a mysql database (Both the item name and the link to it). Is there any php function that will allow me to make such an array into some sort of variable (String?) which can then be read easilly and made back into the array for manipulation and creation of the tree menu?
View Replies !
How To Store Array In Cookies?
I try to store array in cookie this way: for($i=0;$i<5;$i++) { Â Â Â Â $field[]='test'.$i; } $_COOKIE['field2']=$field; Is it possible do it that way? I don't want to store each value of array list store separately. I'd like to store them at once. If I was storing values just to another "normal" variable (not cookie), I would do it this way: Code:
View Replies !
Can I Store An Array In MySQL?
I would like to store an array in a MySQL table. The values will be numeric and ranging from 1-999. I'm not sure if this is possible, and if it is then I'm not sure on the correct field type to use.
View Replies !
Store Variable In An Array
so i have a query that returns a bunch of rows.... i display the contents of the query into a table... one of the variables that the query returns is $title.... after each row is returned im wanting to store the $title variable into an array, so i can then access that array later... here is my code for storing $title into the array Code:
View Replies !
Store An Array In A Text Document
I want to store an array in a text document. what I've been doing so far looks like this: fputs( $myFile, $myArray ); but all it does is write the word "Array", instead of the actual array. I'm new to php and I've done my best to search the manual and numerous web resources (including this forum) for an answer, so please don't flame.
View Replies !
Store Mysql Results Into An Array
i just started using php. i've used it before as a maintainer. fun stuff. well now i'm the writer. i want to abstract all the DB commands away from myself and all other developers. so i'm writing a function to query the php database from all users of the database and store them into an array as a return value so that i can seperate my database code from my html creation code. 1. is there a way to put all my database functions into a php file and include that file into all my other php pages? similiarly to a #include in C++ or a import package name in Java? 2. my code to run down the fetched results and store them into an array doesn't seem to be working the way i want it to. if i print out the results from the mysql returned fetch the data is fine. however the array seems to print out "Array[elementnumber]" instead of the value. Code:
View Replies !
How To Store Checkbox Values To An Array?
I need to allow the user to select multiple mysql records via an html form checkbox. On submission of the form I would like to store these values in an array for either multiple record deletion or creating a list of records. Code:
View Replies !
Store The Entire Table In A Two Dimensional Array
I am reading info from a tab-delimited text file and I was wondering if anyone knew how to get this concept to work. I am trying to store the entire table in a two dimensional array, but the way I'm doing it right now won't work. for($i=0; $i<$numrows; $i++) {$columnsvalue[i] = explode(" ",$newfile[i]);} does anyone else know how to better work with multi-dimensional arrays?
View Replies !
Mysql_fetch_array Way To Pull Out All The Data, Store It In An Array
I have a webpage which runs repetitive queries agaist a database in order to extract one item at a time and then put the items in an HTML table. The reason for this is formatting, plus the page hits 4 databases. Instead of running multiple queries pulling one item at a time...is there a way to pull out all the data, store it in an array, and then pull individual items from the array with php as I want to insert them in the table? So, example is Code:
View Replies !
Variables To Store (Name,Species,Sex) Inside An Array
In PHP, is there anyway of using variables to store each piece of information (Name,Species,Sex) inside an array. Then, when it comes to fetching the information, the array position (e.g. 0) is called along with the information type (Name etc). A bit like the following: record(1).name The information is coming from the record array, at position 1 displaying names.
View Replies !
Array That Contains Dates
I have an array called "$fileArray" that contains dates in the below format. 20050714 20050715 20050716 20050727 20050728 20050729 I want to delete only the dates more than 7 days old from my $directory. How can I do this?
View Replies !
Array Problem - Extract And Store In Seprate Variables .
I have an array from a program of the type $list_box_contents[$row][$col]['text']; There are 3 columns and an indefinite no. of rows. Each array element contains a few bits of information. I want to to extract this and store in seprate variables . $list_box_contents[$row][2]['text']; has 2 bits of information, a price and a small text box with some text. How can extract the price data from this .
View Replies !
Array Problem... - Store This List In $_SESSION['liste'];
the user selects 6 numbers in a list I have to store this list in $_SESSION['liste']; (I cant do it differently) the list is stored like that: 34-21-44-32-12-11 (cant do it differently either) what I need to do is to explode the array, get rid of the - , sort the values in ascending order and send them to my table as a string. so in the end I should have: 111221323444 I tried using a variation of laserlight's script (given in a previous post) without success... hope that someone will have time to give me a hand again in telling me what I could change in saberlights script to make it work.
View Replies !
Populate An Array With The Dates
Im having trouble tweaking this snippet of code below, basically what the code does is it calculates the current position in a week, goes to previous monday and prints twelve weeks(of mondays) into a dropdown box.e.g: for the start of this week, (Mon 7th July), it will print the following: call_date >= གྷ July 2003' AND call_date < ཊ July 2003' Which is all ok, but what Id like to also do is populate an array with the dates between (and including) the dates above e.g: 07 July 2003 08 July 2003 09 July 2003 10 July 2003 11 July 2003 12 July 2003 13 July 2003 14 July 2003 Hope you understand what Im trying to achieve. PHP Code:
View Replies !
Sorting An Array Of Dates
I have an array of dates formatted like: 7/17/2007, now I want to sort them from the most current date tot he furtherest from now, and let's say the array is like this: dates[0] = 7/17/2007 dates[1] = 7/22/2007 datesp2] = 6/22/2007 dates[3] = 2/22/2008.
View Replies !
Array Of Dates Returned From MYSQL
This has been puzzelling me for a couple of weeks now, and just can't figure it out. Does anyone know how to return an array of dates from MySQL given the start date and end date. The database has a rows containing 'start date' and 'end date' I need an array containing all the days between 'start date' and 'end date', ie: Start Date = 15/06/2004 End Date = 17/06/2004 Array returned: 15/06/2004,16/06/2004,17/06/2004 Hope this make sense?... I would love to hear if anyone has done this before or has any idea's how I can do this.
View Replies !
Sort An Array By The Dates At The Beginning Of Each Value
i'm trying to sort an array by the dates at the beginning of each value. ive tried nat_sort which seems to be the most logical choice but it does not work. when i print_r my array this is what i get: Array ( [0] => 2005-07-14,Admin updates- fixes,4.5,taylor [1] => 2005-07-13,Admin updates,5,taylor [2] => 2005-07-13,Room planner updates,4.5,Rich [3] => 2005-07-13,News section revisions,2,Rich [4] => 2005-07-13,Typing copy,0.3,Sarah [5] => 2005-07-12,News section revisions,1,Rich [6] => 2005-07-12,Room planner updates,1,Rich [7] => 2005-05-31,PHP.MySQL- Hildi Videos- Hildi Printable Pages,4,Taylor [8] => 2005-05-31,Ask Hildi,1,Rich [9] => 2005-05-30,Room Planner,6.50,Rich [10] => 2005-05-29,Room Planner,2,Rich [11] => 2005-05-28,Room Planner,3,Rich [12] => 2005-05-27,Room Planner,7,Rich [13] => 2005-05-26,Room Planner and Ask Hildi,7,Rich [14] => 2005-05-25,Room Planner and Ask Hildi,7,Rich [15] => 2005-05-24,Room Planner,1,Rich [16] => 2005-05-23,Ask Hildi,0.50,Rich [17] => 2005-05-13,Room Planner,5,Rich [18] => 2005-05-12,Room Planner,9,Rich [19] => 2005-05-10,Room Planner/News/Mini Headlines,6,Rich [20] => 2005-07-12,Web site updates,2.50,Rob )
View Replies !
Email Fields In An Array
How to ask this because my php knowledge is crap but here it goes. I have a form with close to 30 fields that I want emailed when submitted. I don't want to have to do the tedious line for each field: $txtFirstName = Trim(stripslashes($_POST['txtFirstName'])); So, I understand how to loop thru checkboxes and radio buttons foreach( $_POST['chkbx'] as $checkbox ){ echo $checkbox .'<br />' using chkbx[] in the name attribute but can all 30 fields be put into an array so that I don't have to write 30 lines like the one at the top.
View Replies !
Create Array From 2 Database Fields
I want to create an array of product prices, with the product id as the index and the product price as the value, so i can place the prices for particular products wherever i want on my page. Both product id and price are taken from the Products table SELECT prod_id, prod_price FROM Products Due to the client wanting an unusual layout, I cant just loop a table with the data, I need to be able to print $Price[2]; (for product id 2) wherever I like, for example.
View Replies !
Throwing Empty Fields Out Of An Array
what is the best way to throw out empty fields from an array i mean, if i have an array looking like: array[0] = house array[1] = NULL array[2] = car i whant the array[1] to be taken out, so it looks like: array[0] = house array[1] = car
View Replies !
Checkbox Array Problem Contains Several Fields
I have a form which contains several fields. One of which is a group of checkboxes that can all be selected, and if they are - all values should be passed as an array. Each checkbox is Named as follows. myCheckBoxName[] myCheckBoxName[] I have the following code on the following page to pick up the results from the querystring. while(list($key, $value) = each($HTTP_POST_VARS)) { $keys = $keys . "$key, "; $values= $values . "'$value', "; echo("$key = $value <br>" ); } But the field which contains multiple checkboxes only displays the value "array" - and nothing else.
View Replies !
Sorting And Cleaning Array From 4 DB Fields
I have 4 fields in my database that I am trying to combine and present as a unified dropdown. I've gotten the basic sort and display of the info to work, but don't quite know how to remove spaces caused by empty field nor how to make the dropdown unified. Code:
View Replies !
Form Validation For Fields In Array
I've writen the script and it all works now I want to do some validation to make sure the user enters a 'correct value', simple enough you might think, anyway what I have is 40 fields in my form which are sent to 5 different arrays for processing, so: $q1 = $_POST['q1']; $q2 = $_POST['q2']; $q3 = $_POST['q3']; //....... //then $typea = array( '1' => $q1 , '10' => $q10 , '11' => $q11 , ........ '40' => $q40); //so now I want to validate... $check = 0; foreach ($typea as $key => $value) { if ($value != 0 || $value != 2 || $value != 3) $check = 1; echo $value . " , " . $check . "<br /> "; //to make sure values are what i think } if ($check == 1) //go back to form else //do the processing $check always returns as 1 though, even when the values are 0 , 2 or 3
View Replies !
Multimple Input Fields To Array
I have a page with 24 input fields. And I want to construct an array with those values and store it in a session variable using the id of the field text as the name element. I'm populating the name of the fields with a sql query for the ids of the products. Code:
View Replies !
Converting Form Fields Into An Array
I have a form that enters inventory values based on date. Each day has a certain inventory value. Some days of the month have the same inventory values. I have 31 checkboxes, one for each day of the month and the inventory value form field. I enter the inventory value and then check the days that the inventory value applies to. When inserting the data into the mysql database, I would like to loop through the days and if a day is checked, then I run the mysql query to insert the data. How do I convert all the checkboxes into an array or is there a better way to do it?
View Replies !
Sorting An Multidimentional Array By Multiple Fields
If the multidimentional array was a mysql TABLE, what i'm trying to do would look like this: SELECT * from array WHERE 1 ORDER BY field1 ASC, field2 DESC, field3 ASC and so on. I already constructed a function do to so, but this function, or should i say these 2 functions, sort only the first field properly, and then any other field is sorted improperly. PHP Code:
View Replies !
Sorting An Array Based On One Of Many Form Fields?
I think the root of my problem, aside from mental, is array based...but I'm not even sure what I want to do is even possible. So if I can get far enough to know that one way or the other, then I can try to figure out how to do it. But here's the situation: Page 1 I have a form with many item rows pulled from a database query. Among other fields, each row contains a checkbox to select the item and a text field which contains an item_description. On submit, I have it so that every checked item goes onto the next page where more stuff happens to each item, and the select items end up in an HTML table as well as a CSV spreadsheet. Now, because the selected items are pulled from an array based on the checkbox, the sort order is based on the item's unique ID number. WHat I'm being asked is if I can have the final results sorted by that item_description field I mentioned before. Which can occurr at the end of the 2nd page's processing, sure. Well, here's what I have to select the items: .....
View Replies !
Submitting Multiple Form Fields In An Array / Loop
I have the following form <FORM NAME="form1" METHOD="POST"> <?php do { ?> <input name="approve[]" type="checkbox" id="approve[]" value="<?php echo $row_rs['ID']; ?>"> <select name="select"> <option value="1">option 1</option> <option value="2">option 2</option> <option value="3">option 3</option> </select> <?php } while ($row_rs = mysql_fetch_assoc($rs)); ?> </FORM> I want to acheive a loop that inserts a record into a database that enters the id and the value they have selected (if the approve input box was ticked) so far I have this: <? foreach($approve as $aID) { $insertSQL = "INSERT INTO TABLE('refID','optionSelected') VALUES ('$aID','')"; } ?> How do I enter the select value within this loop? I assumed that it would be just $insertSQL = "INSERT INTO TABLE('refID','optionSelected') VALUES ('$aID','$select')";
View Replies !
$_POST Array - Get All Posted Fields Which Are Extra_something And Return Each
I need some advanced help with a PHP script. I am submitting a form to a script, which has constant fields ie: price, quantity etc. However, I want to submit extra fields, which are called Extra_OptionName. I have a form, which has price, quantity, itemcode, Extra_Colour, Extra_Size as its fields. It is posted to a php script. I need the PHP script to do, is to get all posted fields which are Extra_something and return each, with the name of the field minus the Extra_ bit. $option1 = Colour $option1v = Red $option2 = Size $option2v = Large
View Replies !
Offering Dates And Booked Dates In A Table As DATE Datatype Using MYSQL.
Availability dates in offering dates except booked dates. For Example: Offering dates are : 01-09-2005 to 27-09-2005 01-11-2005 to 30-11-2005 Booked dates are : 10-09-2005 to 23-09-2005 Availability dates should be 01-09-2005 to 09-09-2005 24-09-2005 to 27-09-2005 01-11-2005 to 30-11-2005 I am storing offering dates and booked dates in a table as DATE datatype using MYSQL. So, I want the above mentioned availability dates as a result.
View Replies !
Dates In Range Falling Between Existing Dates
The latest quandry I have is that I need to: a: check whether any dates in a date range entered by a client in a form (datefrom, dateto) conflict with any existing date ranges already in the database. -this is a check to see whether the dates that a customer is trying to book are not already booked- Obviously its easy to get the numbers out of the database (i.e. 28/12/2006 or whatever format) and from the form but how to I convert this 'range' actually into a range I can loop through that will return true if any of the dates are the same (i.e. already booked)? b: is similar in that I want to check how many of the clients entered dates fall into the pre assigned high, mid and low season ranges in the database and multiply each of those days by the corresponding price.
View Replies !
Multiple Fields - How To Select 3 Rows's Fields
is there a code example on how to select 3 rows's fields. lets say. there is a same user id - but has 3 different rows with different values which came from name,middle name and last name which came from 3 different forms and i want to pull them all out in one query from db then use it as a new value for another table's row field.
View Replies !
Get Dates Between Two Dates, Then Add To Table
I've got a form that inserts data into a database. Basically what it sends is a sets of dates. What I'm wanting is another set of inputs that also sends some dates. But before it adds them to the database I want to query the dates and find all of the dates between the two given ones and add them to the database as well. Code:
View Replies !
How To Store $a Value
i am createing a dynamic web site my problem is how to store last 5 value of $a. my $a value is 94 to 250 and each click the value of $a change how i am store last 5 value of $a.
View Replies !
|