Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





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:
How To Populate Selects With Years=>months=>days That Dynamically Change?
What I'm thinking of doing is in my admin page have three different selects. They will form the day of sales at my shop.

-YEAR- -MONTH- -DAY-

The years will have 2002 -> 2005 and the months will be the 12 months of the year of course but I need the number of days to change with the particular month selected.

View Replies !
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 !
Function To Return Current Working Dir - Easy One
Just a quick and hopefully simple one....

Is there a function in PHP that returns your current working directory?

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 >= &#3907; July 2003' AND call_date < &#3914; 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 An Array With Images
I am trying to populate the following html with the contents of an image directory: 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 !
Easy Array Question
Is there a built-in function that checks to see whether or not all the keys in an array are empty/null. ie does this: PHP Code:

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 !
How To Iterativley Populate An Associative Array
I know how to do this with an indexed array, but if i'm retrieving data
from a query and would like to add it to an associative array, how
should i go about that?

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 !
Easy Form Mailer That Is Clean Looking And Easy To Edit.
I have been looking for really easy form mailer that is clean looking and easy to edit. I also am looking for required fields, ect. I have looked all over hotscripts and I really cant find what i'm looking for, anyone else have an idea where i can find what i'm lookin for?

View Replies !
Create An Array Of All The Days
lets say i have 09/01/2001 and 09/20/2001. I want to create an array of all the days including the two that are the start and end of the range. how would i go about doing this?

View Replies !
Easy Easy Question (Field Type)
I have built a little MySQL / PHP forum, and was wandering how to incresae the storage of the main message from 255 characters to a lot more, which field type am I after?


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 !
URl Array Not Working
I just set up Redhat 9 at home and trying to run one of my script as chopping the URI elements seperated as an array /
like this:

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 !
Multi-dimensional Array Not Working Correctly???
I know this is going to be something totally stupid that I just can't see. I have a two dimensional arrray. The first index is a 0 based incremented int, and the other index is either an 'l' or a 'w'. Look what's happening:

View Replies !
Loop Variable Not Working With POST Array
I am posting variables with the name pattern like,

q_1, q_2, q_3, ...... , q_n

and in the action page i am trying to receive them as PHP 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 !
Registration...error Reporting In Array Not Working?
I am trying to make it so all the errors get stored into an array, and then if there are any errors, it lists them all from the array. For some reason absolutely none of the strlen restrictions are working, nor is the array. Any ideas? Code:

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 !
Selection Of The First One To Populate The Second Box.
I have 2 drop down boxes on my site. I want the selection of the
first one to populate the second box.

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 !
Populate Database
does anybody know how to populate a database from a text file? With using script and NO loada database in file command..

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 !

Copyright © 2005-08 www.BigResource.com, All rights reserved