Is There An Easy Way To Populate This Array With Only The Working Days?
Is there an easy way to populate this array with only the working days (no Sat or Sun) from the last 60 days. for($i = 1; $i <= 60; $i++) { $pastDates = date("Y-m-d", mktime(0, 0, 0, date("m")-2, date("d")+$i, date("Y")));
$findPastDates = array($pastDates);
}
View Complete Forum Thread with Replies
Related Forum Messages:
Populate Dropdown Not Working
I have an intranet site that I need to convert as the database backend has changed from MySQL to Postgresql. The following code should populate a dropdown box, I have changed the MySQL functions to Postgres functions but its not happening. db_connect() is connection function from include file. Code:
View Replies !
Populate/Re-Populate Array "onClick" With Checkboxes
I have a list of items - could be 1 could be 100 on 1 page. Each item has a checkbox. Looks something like: <input type="checkbox" name="expsel[]" value="<?=$somevar['id']?>" onClick"document.myform.submit Basically what I'm trying to do is this: #1 - when an item is checked - submit the form and store the value of the checkbox in a session array. $_SESSION['userinfo']['expsel'] which will be an array of its own. #2 - when an item is unchecked - submit the form and reprocess the array to remove the item that was unchecked. The reason for the session array is that at some point they will have selected all that they want and will press a button or link to export to CSV. So I'll process the session array and get them the info needed. That part is no biggie. I'm having problems understanding how what to write to catch the checked/unchecked boxes.
View Replies !
Working Days
I need to setup a script to run on the FIRST WORKING DAY of each month. I will have the script running as a cron. I was thinking the easiest way of doing this would be to have a bit of php inside the script that detects to see if the day is the first working day of the month and just run the cron every day.
View Replies !
Working Out Days Elapsed.
in mysql i have 2 files (date files) they are: 1)2007-08-27 13:20:03 2)August 13, 2007, 10:02 pm they are displayed differently, is there a way i can work out the days elapsed between them like this? or do the time stamps need to be the same?
View Replies !
Working With Dates - Set Up A Cron Job That Will Close All Auctions That Are 10 Days Old
I am writing a new auction script for my website and I have everything working except closing the auctions. I have the database set up to record the start time like this: Field    Type     Default time    datetime   0000-00-00 00:00:00 I want to set up a cron job that will close all auctions that are 10 days old. My only problem is I don't know how to write the code the find the 10 day cutoff. I know I need to somehow take today's day and subtract 10 days from it but I can't seem to find out how. My plan is once I find that code I will then take that variable and compare it to the time in the database with >.
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 !
Populate Array Using Refresh
I have a small problem about arrays. I wanted to populate an array everytime I refresh a page. the problem is everytime i refresh a page the array itself gets overwritten so the array resets. I tried using session to retain the value of the array but it still doesnt work.
View Replies !
Populate Array With Mysql Table
What I would like to do is populate an array with some information pulled from a mysql table. as an example lets say I have a table that shows: id ¦ name ¦ nickname what I would like to do is have my array as follows: $name_ar = array( 'name1' => 'nickname1', 'name2' => 'nickname2', 'name3' => 'nickname3', /* and on and on */ ); Arrays are not my favourite things, some help?
View Replies !
Returning An Array To Populate A Drop Down Menu
Scenario: two related tables (Many) 'patient' and (one) 'doctor'. In the patient table, each row has an entry for doctor_id. I have created a drop down menu on my patient form to input the doctor_id. The dropdown only shows the doctors' names. This menu is generated by a SELECT statement on the doctor table. The result of SELECT goes into an array, and then each element of the array is inserted into the dropdown with a 'while' loop. This works fine. However, I wish this dropdown to set itself to the correct doctor's name, when I retrieve a previously inputted patient record. That is, if patient 'Smith' is allocated to doctor 'Neo', the record is then saved, and later I retrieve the record: I wish to see doctor's name (Neo) as the default in the dropdown menu.
View Replies !
JS Array - Using PHP To Populate JS Array
I have a page where two select boxes containing lists of people ( Left is Absent and Right is Present) driven by several arrays, such as absent_Member, absent_Visitor, and present_Member, present_Visitor. This is so that an additional select box can be used to choose which category you want the select box to display. You can click on people on either side and click a button to swap them across. That is the easy part. The part I am stumped on is my familiarity with JS arrays. I am used to the ease of PHP for searching for values within arrays, such as in_array(needle, haystack); When I swap from on box to another, the only values being passed are options.value ( this equals the persons database ID # ) and options.text ( this equals the persons Last, First name ). The best way I can think to search the arrays to find which one this person resides in is a pathetically taxing way, such as Code:
View Replies !
Trying In Array Working
All it shows on the page is the current second but no files on page refresh. <?php ini_set('error_reporting', 8191); ini_set('display_startup_errors', 1); ini_set('display_errors', 1); $currentfile = date('s'); $allfiles = array(); $allfiles[1] = "thisfile.txt"; $allfiles[2] = "thatfile.html"; $allfiles[3] = "thatfile.gif"; $allfiles[4] = "thisfile.txt"; $allfiles[5] = "thatfile.html"; $allfiles[6] = "thatfile.gif"; if (in_array(".gif",$allfiles)) {echo '<img src="'.$allfiles[$currentfile].'">'} else {$get_content = file_get_contents($allfiles[$currentfile]); echo $get_content;} ?>
View Replies !
Array Not Working
For some reason the variable $smilies wont return the img puth instead is displaying "Array" anny solution? <?php $body = ":)"; function smilies($text) { $smilies = array( ":)" => "smile1.gif", ";)" => "wink.gif", ":D" => "grin.gif" ); $smiliesK = array_keys($smilies); $newtext = str_replace($smiliesK, "<img src='images/smilies/$smilies'>", $text); // The error is here in $smilies return $newtext; } echo smilies($body); ?>
View Replies !
Working With Array With Floats
I have read a file with the file() command and it contains numbers, numbers that are larger than 2^32 and now I wonder, will this be a problem if I do arithemtcis, or is there some easy way to force it to use consider the array as floatingpoint numbers?
View Replies !
Fetch Array Not Working
I am trying to post a detail message and say who the message was posted by. (the owner of the message) but it doesnt work quite right it says posted by the word "ARRAY". Some reason its not getting the name from the database.Can someone tell me why this is? here is my code.. $get_owner_sql = "SELECT post_owner FROM forum_posts WHERE topic_id = '".$_GET["topic_id"]."'"; $get_owner = mysqli_query($mysqli,$get_owner_sql); $post_owner = mysqli_fetch_array($get_owner);
View Replies !
Random Array Not Working.
I'm trying to pull links from a file display on my page bottoms using a PHP script... The problem is the random variable(link url) keeps repeating... Code:
View Replies !
Problem Creating Working Array Value Pair
I want to use a template for the whole website and call pages using something like 'http://localhost/template.php?page=links' I actually have a working system, but I thought I would improve by using comma-separated key => value pairs. The code is below. I am using the part of the page filename as the key and the value as the <title></title> Problem is that the first 9 work, that is I get the correct page linked. When I enter 'http://localhost/template.php?page=plan2', I get the default 'home' page. For the life of me I don't see what is wrong. I use HTML-Kit and notepad. (in the process or weening of wysiwyg products) I considered it was a text encoding problem but the same whether I use notepad or HTML-Kit. <?php $allpages=array( 'Home Page'=>'home', 'Purpose'=>'purpose', 'Spiritual Gifts'=>'spiritgifts', 'Reaching Potential'=>'potential', 'Weight Loss'=>'weightloss', 'Contact Me'=>'contactme', 'Spiritual Gifts2'=>'gifts2', 'Spiritual Gifts3'=>'gifts3', 'Links'=>'links', 'The Plan'=>'plan1', 'The Plan'=>'plan2', 'The Plan'=>'plan3' );
View Replies !
INSERT Statement Not Working - Array Question
it has been awhile since I coded in PHP and I have a little problem that is eating up way too of my energy. I have a form that is being submitted via the POST method In the handler.php file, I want to take that information and insert it into the Database. Code:
View Replies !
Using Php To Populate A <ul>
I'm am pulling data from a mysql db and want to use the data to populate a <ul. Here are relavent parts of my code : $wohdate = mysql_result($wohRS,$wohndx,woh_date); $woh_display .="<li>".$wohdate."</li>" ; $TemplateText = Replace($TemplateText,"@$wohdisplayndx@",$woh_display); print($TemplateText) ; So, I have 8 woh_dates that I retrieve (verified with an echo). My page only displays the first of the 8. ie : 2000-01-01 2001-01-01 2002-01-01 are retrieved, but only 2000-01-01 is displayed on the page. Something wrong with appending as I am doing in $woh_display .="<li>".$wohdate."</li>" ;
View Replies !
This Should Be Easy
When the form is submitted I want to do different things depending on if there is anything in the "image" field or not. I was thinking this would be a simple.
View Replies !
OK This Is An Easy One For Someone!
I'm sooo new to this, but so far i have managed to create a form (like a shopping list) in one page which looks like this where i can put quantities in on one page. Then it passes the form info onto my next page which displays a list and totals. But how, pray, would I make it miss out items on my second page where they have a value on null? You see I would rather just have the items where I have actually given a value! Is it some kind of if else statement possibly followed by the ! mark to reverse the flag or summat?
View Replies !
This Should Be Easy, But...
I'm trying to build a simple, one-dimensional array of prices, where the key to each element is the product code. So I start by executing a select query "SELECT Code, Price FROM Products", and the results are returned in a two-dimensional array, $data, which I can loop through like this: while (list(, $value) = each($data)) { $code = $value[0]; $price = $value[1]; I would have thought I could build my array here by writing something like: $command = "$arr['$code'] = $price;"; exec($command); But this doesn't work.
View Replies !
Is There An Easy Way To Do This?
I don't even know where this question classifies itself but hopefully someone can point me in the right direction: If i have a list as such: -NHL -MLB -NBA -NFL Is there a way to have an option like an 'onclick' where each item that is clicked gives a variable such as $clickedvalue the value of the item clicked while at the same time, routing to a function in separate php file? 1) So let's say i clicked on MLB 2) the variable $clickedvalue = item clicked (in this case MLB) 3) call a function in a separate php file for processing.. 4) return to main script. so far i know of the href=# but with it, i can't really give my variable a value.
View Replies !
Easy PHP
Im trying to send a variable via GET to a php script like so: <a href="process.php?id=test & test">Link</a> Leaving spaces is no problem, but the & symbol (ampersand) cannot be displayed to the screen. I want it to show "test & test". Instead it displays just "test" without the rest following it. how to display the whole variable passed to process.php?
View Replies !
Easy CMS
I am looking for a very basic CMS with user authentification... I get stuck on how to make multiple admins <b>without</b> doing something like : $admin = 1 $member = 0 type of stuff... What is another way to make different levels of membership?
View Replies !
Populate One Menu From Another
I thought this would be simple and there would be advice / tutorials everywhere for this, but now that I'm working on it, I can't find any reference except for ASP or Javascript code. PHP/MySQL - 3 form select menus: Project, Categories, Subcategories. When a Project is selected, the Categories list is populated based on Project selected, then Subcategories list is populated based on Category selected. I see this all over the Net, but through 10 books, there isn't anything specific. I think I get lost with some of PHP structure since I've been using DW - I end up editing most of it in order to follow it, but DW works pretty good for getting initial testing done. I just can't seem to find further guidance on this. So far I have:
View Replies !
Populate Form
I have a database of project number, client info, address, phone, ect. And I have a form to add data, and one to edit data... On the edit data form, I want to set it up so that when the project number is highlighted via a pull down list of active project numbers, that project number fill auto fill the form with the clients info from the database. Then, the user can edit this info...and submit the mofifications. Is this done with php, javascript, or ajax? Which is best? I'm pretty sure this could be done with php, but how? Can I get an example of code? a good starting point.
View Replies !
Populate A Listmenu
I am trying to populate a listmenu from a database with php if I run the code below it works fine. Except if I want to run it inside the table where I need it then I get the Listmenu but its empty ?. Code:
View Replies !
Populate A List Box From A Url
I have two list boxs on a page Team A and Team B I would like to fill the list boxs with teams from a division. So if I have a link to the form like myform.php?div_id=3 I want to populate the list boxs from the url so I only see teams for the division selected in the link Code:
View Replies !
Table Won't Populate
I am able to connect to the database with no trouble. The next thing I do is assing variable names to the POST variables. This is also working correctly. The next step is to populate a customers table and that is working with no trouble. The next step is to perform some calculations from data in another table. The calculations are working as well. The problem is when I try to populate the ORDERMAIN table. The fields won't populate and I can't seem to figure out why. I've checked to make sure that all my table fields match the columns in the query - that is fine. I made sure that the columns in the query match the order of which the fields are in the table - that is fine. The only thing happening is no data is being placed into the table. I'm hoping a second, third, or even fourth pair of eyes may see something that I am missing. Code:
View Replies !
Populate Combobox In PHP
is it possible to populate the comboxbox in PHP without reloading the entire page? we have three combo boxes the values of second combobox is populated from database according to selected item in first combobox but I don't need to regresh entire page.
View Replies !
Populate Dropdown
I've written a form for uploading data to a mysql database. To limit user error, I'd like one of the fields to be a dropdown of the contents of an image folder. I've got a dropdown of some mysql data taken from the database. that's fine. And I can display the contents of the image folder in a big static block. that's fine too. But I can't seem to combine the techniques. point me in the right direction.
View Replies !
Populate Drop Down
I have a text file with the following fields. item file Here's how it looks now. TEST ITEM | test.pdf ANOTHER EBOOK | another.zip I need to create a dropdown list populated by the data in the item field. The posted variable name is $item_name and the value should be the names of the items in the item field.
View Replies !
Field In DB Won't Populate
I'm running a small test query and I'm trying to populate a table. The table has three fields: item_code, price, qty. When I run my script, price and qty are populated and item_code is not. Code:
View Replies !
Populate A Foreign Key In One DB
I have a table called attendees that has attendeeID as a primary key. Then I have a table called relationships that has groupID as its primary key and attendeeID as a foreign key (from the attendees table). Both tables get populated from fields in a single HTML form and both of the primary keys are auto-incremented. What I need to do is populate both tables at once when the submit button is clicked and insert whatever auto-incremented value attendeeID was given in the attendees table into the attendeeID field in relationships.
View Replies !
Populate Combobox
php/mysql applications and would like to know if it's possible to populate a combobox from a database query. I can't find anything like that in the forum. I have a list of places that a user entered into the database and want to present that list to him at a later stage through a select box.
View Replies !
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?
View Replies !
Easy PHP+XML Parser
I have data like: <?xml version="1.0" encoding="ISO-8859-2"?> <news> <post> <date>10.04.2004</date> <text>Test test test</text> </post> <post> <date>15.04.2004</date> <text>Bleh bleh bleh <a href="www.test">test</a></text> </post> </news> and I want to have it in PHP as array looking like: array( [0] => array( date => "10.04.2004" text => "Test test test" ) [1] => array ( date => "15.04.2004" text => "Bleh bleh bleh <a href="www.test">test</a>" ) ) problem - text can have some HTML tags, so I want to just have it all in string. How can I do this in PHP if I have XML data in some data.xml ?
View Replies !
Headers Seem To Easy!
when running this code: <html> <?php /* This will give an error. Note the output * above, which is before the header() call */ header('Location: http://www.example.com/'); ?> It runs perfectly on my server! Why isnt is giving the expected error?
View Replies !
|