![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
dc_jt
-
Posts
290 -
Joined
-
Last visited
Never
Posts posted by dc_jt
-
-
Thanks a lot
-
Im looking to get the date of a week before a certain date
For example
$iLastDate = date("Y-m-d H:i:s ");
$timeStamp = strtotime($iLastDate);
$timeStamp += 24 * 60 * 60 * 7;
$NextBatchDate = date("Y-m-d H:i:s", $timeStamp);
This is for a week ahead, how do I do a week before?
Thanks
-
Thanks a lot Ken
-
Hi
I have a date which is set as 2007-02-01, can easily be changed to different format.
However how do I change this date to the day before?
In this case 2007-01-31?
Thanks
-
Sorry didnt really make myself clear
I wanted to add the total of the type of each product depending on the job_id
I done it using this anyway if anyone would like to know:
public function GetStorageTotal($iJobsId) { $sSql = "SELECT sum(p.load) AS storage_load from survey_results sr INNER JOIN product p ON p.product_id = sr.product_id WHERE p.type ='storage' && sr.job_id = '$iJobsId'"; $load = mysql_fetch_object(mysql_query($sSql, $db)); return $load->storage_load; }
Thanks anyway
-
-
Sorry I have product_id in the 2nd table also (the survey_results table)
-
Hi I have a product table containing:
product_id
product
price
I then have data such as
product_id = 1
product = test
price = 10
product_id = 2
product = test2
price = 20
product_id = 3
product = test3
price = 30
Then I have a survey results table with the following:
survey_results_id
surveyor_id
survey_date
job_id
room_id
location_id
elevation_id
date_posted
So job_id 123 had each product, how would i add these up.
I would have to select all products from product table and relate this to the product_id in the survey results table??
-
Thanks a lot, thats exactly what I was looking for.
However, in the year section, is it possible to not have a limit on the year.
For example, on the one above the limit is 2010 but when it gets to 2011 this will be no good.
Could you set it to todays year+3 or something so every year it will be updated??
Thanks again for your help
-
Hi I am constantly using drop down menus for dates for various projects I work on.
At the moment Im using a very poor strategy, as follows:
$form_sdate = (date("d/m/Y")); $hygine3=substr($form_sdate, 0, 2); $form_sdated= ($hygine3); $hygine2=substr($form_sdate, 3,2); $form_sdatem= ($hygine2); $hygine1=substr($form_sdate, 6, ; $form_sdatey= ($hygine1);
<td width="40%" COLSPAN=2>Approval Date <select name="sdated" class="fmgreynormal"> <option value="01" <? if ($form_sdated == '1'){ echo "selected='selected'";}?>>01</option> <option value="02" <? if ($form_sdated == '2'){ echo "selected='selected'";}?>>02</option> <option value="03" <? if ($form_sdated == '3'){ echo "selected='selected'";}?>>03</option> <option value="04" <? if ($form_sdated == '4'){ echo "selected='selected'";}?>>04</option> <option value="05" <? if ($form_sdated == '5'){ echo "selected='selected'";}?>>05</option> <option value="06" <? if ($form_sdated == '6'){ echo "selected='selected'";}?>>06</option> <option value="07" <? if ($form_sdated == '7'){ echo "selected='selected'";}?>>07</option> <option value="08" <? if ($form_sdated == '8'){ echo "selected='selected'";}?>>08</option> <option value="09" <? if ($form_sdated == '9'){ echo "selected='selected'";}?>>09</option> <option value="10" <? if ($form_sdated == '10'){ echo "selected='selected'";}?>>10</option> <option value="11" <? if ($form_sdated == '11'){ echo "selected='selected'";}?>>11</option> <option value="12" <? if ($form_sdated == '12'){ echo "selected='selected'";}?>>12</option> <option value="13" <? if ($form_sdated == '13'){ echo "selected='selected'";}?>>13</option> <option value="14" <? if ($form_sdated == '14'){ echo "selected='selected'";}?>>14</option> <option value="15" <? if ($form_sdated == '15'){ echo "selected='selected'";}?>>15</option> <option value="16" <? if ($form_sdated == '16'){ echo "selected='selected'";}?>>16</option> <option value="17" <? if ($form_sdated == '17'){ echo "selected='selected'";}?>>17</option> <option value="18" <? if ($form_sdated == '18'){ echo "selected='selected'";}?>>18</option> <option value="19" <? if ($form_sdated == '19'){ echo "selected='selected'";}?>>19</option> <option value="20" <? if ($form_sdated == '20'){ echo "selected='selected'";}?>>20</option> <option value="21" <? if ($form_sdated == '21'){ echo "selected='selected'";}?>>21</option> <option value="22" <? if ($form_sdated == '22'){ echo "selected='selected'";}?>>22</option> <option value="23" <? if ($form_sdated == '23'){ echo "selected='selected'";}?>>23</option> <option value="24" <? if ($form_sdated == '24'){ echo "selected='selected'";}?>>24</option> <option value="25" <? if ($form_sdated == '25'){ echo "selected='selected'";}?>>25</option> <option value="26" <? if ($form_sdated == '26'){ echo "selected='selected'";}?>>26</option> <option value="27" <? if ($form_sdated == '27'){ echo "selected='selected'";}?>>27</option> <option value="28" <? if ($form_sdated == '28'){ echo "selected='selected'";}?>>28</option> <option value="29" <? if ($form_sdated == '29'){ echo "selected='selected'";}?>>29</option> <option value="30" <? if ($form_sdated == '30'){ echo "selected='selected'";}?>>30</option> <option value="31" <? if ($form_sdated == '31'){ echo "selected='selected'";}?>>31</option> </select> <select name="sdatem" class="fmgreynormal"> <option value="01" <? if ($form_sdatem == '01'){ echo "selected='selected'";}?>>January</option> <option value="02" <? if ($form_sdatem == '02'){ echo "selected='selected'";}?>>Febuary</option> <option value="03" <? if ($form_sdatem == '03'){ echo "selected='selected'";}?>>March</option> <option value="04" <? if ($form_sdatem == '04'){ echo "selected='selected'";}?>>April</option> <option value="05" <? if ($form_sdatem == '05'){ echo "selected='selected'";}?>>May</option> <option value="06" <? if ($form_sdatem == '06'){ echo "selected='selected'";}?>>June</option> <option value="07" <? if ($form_sdatem == '07'){ echo "selected='selected'";}?>>July</option> <option value="08" <? if ($form_sdatem == '08'){ echo "selected='selected'";}?>>August</option> <option value="09" <? if ($form_sdatem == '09'){ echo "selected='selected'";}?>>September</option> <option value="10" <? if ($form_sdatem == '10'){ echo "selected='selected'";}?>>October</option> <option value="11" <? if ($form_sdatem == '11'){ echo "selected='selected'";}?>>November</option> <option value="12" <? if ($form_sdatem == '12'){ echo "selected='selected'";}?>>December</option> </select> <select name="sdatey" class="fmgreynormal"> <option value="2007" <? if ($form_sdatey == '2007'){ echo "selected='selected'";}?>>2007</option> <option value="2008" <? if ($form_sdatey == '2008'){ echo "selected='selected'";}?>>2008</option> <option value="2009" <? if ($form_sdatey == '2009'){ echo "selected='selected'";}?>>2009</option> <option value="2010" <? if ($form_sdatey == '2010'){ echo "selected='selected'";}?>>2010</option> <option value="2011" <? if ($form_sdatey == '2011'){ echo "selected='selected'";}?>>2011</option> <option value="2012" <? if ($form_sdatey == '2012'){ echo "selected='selected'";}?>>2012</option> </select>
I know there is a way of doing it using a loop but im not sure how. Does anyone have any templates for this as it will always be the same everytime its used, i just want todays date.
The field I am saving it in is a datetime field called approval_date.
Thanks for your help
-
It needs to be drop downs. I already have a tree, however there is thousands of data which the server cannot handle using this way, therefore Im trying to cut it down using drop down menus.
???
-
Thanks for your replies but I need to have separate drop downs I think!
Any other ideas?
-
Hi I have categories which contain sub categories which contain other sub categories etc etc....
Ive got a drop down which shows the first lot of categories, then another drop down displaying the sub categories depending on what the user clicked in the first place. Then another displaying the next set of sub categories depending on what they chose in the second drop down etc.
However, there could be hundreds of sub categories within each category therefore I need to create one drop down which can then create other drop downs if there are any sub categories in that category. (Hope your still with me)
I cant literally create 100 drop downs therefore what is the best way to do this? Maybe using an increment? Here are the three drop downs so far anyway:
<?php require_once(LOCAL_CLASSES.'RCLTblCategories.class.php'); $oTblCategories = new RCLTblCategories(); $rCategories = $oTblCategories->GetCategories(); $rCategories2 = $oTblCategories->GetCategories2($_POST['category']); $rCategories3 = $oTblCategories->GetCategories3($_POST['category2']); ?> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="tabpagemain"> <form name="category" action="<?=$_SERVER['PHP_SELF']?>" method="POST"> <tr> <td>Category</td> <td> <select name="category"> <option value="0">-- View All --</option> <?php while ($oCategories = mysql_fetch_object($rCategories)) {?> <option value="<?=$oCategories->category_id?>"<?=($_POST['category'] == $oCategories->category_id)?' selected="selected"':''?>><?=$oCategories->name ?></option> <?php } ?> </select> <td colspan="2"><input type="Submit" name="submit" value="Submit" class="cmdbutton" /></td> </tr> <input type="hidden" name="mode" value="apply" /> </table> <?php if($_POST['submit'] || $_POST['submit2']){?> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="tabpagemain"> <tr> <td>Sub Category</td> <td> <select name="category2"> <option value="0">-- View All --</option> <?php while ($oCategories2 = mysql_fetch_object($rCategories2)) {?> <option value="<?=$oCategories2->category_id?>"<?=($_POST['category2'] == $oCategories2->category_id)?' selected="selected"':''?>><?=$oCategories2->name ?></option> <?php } ?> </select> <td colspan="2"><input type="Submit" name="submit2" value="Submit" class="cmdbutton" /></td> </tr> <input type="hidden" name="mode" value="apply" /> </table> <?php } ?> <?php if($_POST['submit2']){?> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="tabpagemain"> <tr> <td>Sub Category 2</td> <td> <select name="category3"> <option value="0">-- View All --</option> <?php while ($oCategories3 = mysql_fetch_object($rCategories3)) {?> <option value="<?=$oCategories3->category_id?>"<?=($_POST['category3'] == $oCategories3->category_id)?' selected="selected"':''?>><?=$oCategories3->name ?></option> <?php } ?> </select> <td colspan="2"><input type="Submit" name="submit3" value="Submit" class="cmdbutton" /></td> </tr> <input type="hidden" name="mode" value="apply" /> </form> </table> <?php } ?>
Hope someone can help?
Thanks
-
Ok... leave the previous one...
use this code it works fine
$newDate = strtotime("+7 day", time()); $newDate = date("d/m/Y H:i:s", $newDate);
Thank you so much, that works great
-
you can change the format to which suits you...
by changing
date("d/m/Y H:i:s", $timeStamp);
the heighlited ...
When I change the format though I get 10/1/2007
Im using this:
$due = date('d/m/Y H:i:s');
$timeStamp = strtotime($due);
$timeStamp += 24 * 60 * 60 * 7; // (add 7 days)
$newDate = date("d/m/Y H:i:s", $timeStamp);
echo $newDate;
???
-
because it was
$newDate = date("Y-m-d H:i:s", $timeStamp); earlier
I just editted it. to
$newDate = date("d/m/Y H:i:s", $timeStamp);
I think you used previous one.. have a look at that...
Thanks, you were right, however I have to have it in Y-m-d H:i:s format because I have a calendar which works in this format. Is it possible doing it this way?
Thanks
-
$timeStamp = strtotime($due); $timeStamp += 24 * 60 * 60 * 7; // (add 7 days) $newDate = date("d/m/Y H:i:s", $timeStamp);
Hi thanks for your help but that seems to ouput:
2007-01-10 11:39:17
When I echo it? Any idea why???
Thanks
-
Hi
Ive got this date function:
$due = date('d/m/Y H:i:s');
which obviously displays todays date, how can I get it to display a week todays date??
Thanks
-
Thanks, just had a look at that but didnt find any results.
Anything else?
-
sorry about the caps!
-
Hi
Ive created a site with mostly static content but a small amount of dynamic content also.
Im looking to create a search engine that searches the whole site for either static or dynamic content.
Can anyone suggest a good tutorial? I have never done one before so something simple but effective.
I have tried googling it but a load of companies offering their own search engines appear.
Any help please?
Thanks
-
Thanks a lot :)
-
Hi
I have 2 tables one called leads and one called status.
The leads table contains leads_id, reference_number, status_id
The status table contains status_id, status
Im running a while loop where i get all the information from the leads table, however because I store the status_id it is showing the status_id rather than the actual status i.e Live, New etc.
Therefore, how can I get it to show the actual status instead of the number?
I was thinking I may have to have another table called linkstatus which would contain linkstatus_id, leads_id and status_id.
Would this be the best way to do it and then what would I have to do??
Hope someone can help
Thanks -
Sorry I forgot to mention im looking for an equivalent to these for TinyMCE?
Something like [quote]<textarea onchange="CheckLength(this.id)"[/quote] but that doesnt work
??
Week before date
in PHP Coding Help
Posted
Im looking to get the date 7 days ago.
I know how to do 7 days ahead:
$timeStamp = strtotime($oLastBatchDate->Last);
$timeStamp += 24 * 60 * 60 * 7;
$NextBatchDate = date("Y-m-d H:i:s", $timeStamp);
However, does anyone know how to do 7 days back?
Thanks