Thanks a lot for your help.
Ccassius
- Aug 19, 2009
- Joined Feb 9, 2003
Can anyone explain to me why this snippet doesnt return a timestamp?
- I need the function to compare to dates to check that the "fromdate" actually takes place after the "todate", but i found out that my script would pass strtotime("2209-08-15") to be an earlier date than strtotime("2010-06-30").Help would be much appreciated.
$dbdate_from = "2209-08-15"; $dbdate_to = "2010-06-30"; $strto_from = strtotime($dbdate_from); $strto_to = strtotime($dbdate_to); if($strto_from < $strto_to) //test passed, continue script else //test failed, stop and return error-msg
If i try to echo $strto_from it comes back empty(??)
Thanks a lot. I agree that this is a far better solution :-)
Do not know if this is considered as a "good" solution to the problem, but it works for me. Feel free to give me som other alternatives if you have a better way :-)
function make_timelist($preval, $postname){ echo "<select name='".$postname."' class='formstyle'>"; echo "<option value=''>...</option>"; for($x=730; $x<1815; $x=($x+15)){ if($x < 1000){ $val = '0'.$x; }else $val = $x; $thistime = substr($val,0,2).":".substr($val,2,2); echo "<option value='".$thistime."'>".$thistime."</option>"; if(substr($val,2,2)=='45'){ $x = ($x+40); }//end if }//end for echo "</select>"; }//end function make_timelist
Hi
Anyone have a good idea for a loop that could populate a select list(form) with time values from 08:00 - 18:00 (24h time format) with an interval of 15 min between each <option value> ?<select name='time'> <option value='08:00'>08:00</option> <option value='08:15'>08:15</option> <option value='08:30'>08:30</option> ... <option value='18:00'>18:00</option> </select>
Kinda stuck with this one...help would be much appreciated.
Thanks a lot. That did it for me. If anyone can think of any reason NOT to set is_dst to '0' in the mktime-function I would appreciate if you let me know. For now, that seems to have solved the problem for me
Hi.
I've used this function to calculate the number of days between to dates for a while, but when I tried to use it on some dates it suddenly gave me a result I can't quite understand. I try to calculate the number of days between 2007-10-31 and 2007-10-28 with this function:function get_numdaysnew($from, $to){ $fromcmp = explode("-", $from); $tocmp = explode("-", $to); $fromcmpmk = mktime(0,0,0,$fromcmp[1],$fromcmp[2],$fromcmp[0]); $tocmpmk = mktime(0,0,0,$tocmp[1],$tocmp[2],$tocmp[0]); $diff = (($tocmpmk - $fromcmpmk) / 86400); return $diff; } //end function get_numdaysnew $date_1 = '2007-10-28'; $date_2 = '2007-10-31'; $numday = get_numdaysnew($date_1, $date_2);
The function returns the result 3.04166666667. I can't understand this since I've set the hour/minute/second to 0 in my use of mktime-function.
Anybody to explain or to help me with a better function please?
Help would be much appreciated.
Hi.
I'm working on a invoice register that is suppose to control which date periods each customer have received an invoice for and which periods that are "uninvoiced".I'm simply(?) wondering how to check if the period i try to register as invoiced is allready registred in the database.
Example:
Custom "a" has three records in the "invoiceRegistry" table. Each record is registred with invoiceFrom(DATE), invoicTo(DATE) and customerID(references id in my customer/booking table).I want to build a php function that checks if the period I try to register(or part of the period) is allready registred as "invoiced" or not.
If customer "a" has registred this period:
2007-01-01(from) - 2007-01-14 (to)
I would like to return an error if I try to register an invoice for the period 2007-01-05(from) - 2007-01-18(to) etc etc.Help would be much appreciated.
I'm sure there's no css related to those names or css-styles with that name.
OK. I thought of that, but I couldn't figure out why it did this for just some of the 20 form fields in this application form. There's only the two fields supplied in my code that got the yellow background, none of the other form elements are supplied with this color(allthough the form is loaded/filled out/submitted the same number of times).
FF displayed it right.
I've tried different stuff now to remove the background color now, but the solution seemed to be to change the name of the field allthough I have no idea why this solved my problem. All fields had unique names before this workaround, so this doesn't explain the problem.
Let me know if anybody know why this happens:
Code that turn fields yellow:<div align="right"><span class="apptxt"><?php echo $navn[$lang]; ?></span> </div> <td><input name="sambofirstname" type="text" class="formstyle" id="sambofirstname" size="30" <?php if(isset($_POST['sambofirstname']) && $_POST['sambofirstname'] != ""){ echo "value='".$_POST['sambofirstname']."'"; }?>> </td> <div align="right"><span class="apptxt"><?php echo $etternavntxt[$lang]; ?></span></div> <td><input name="sambosurname" type="text" class="formstyle" id="sambosurname" size="30" <?php if(isset($_POST['sambosurname']) && $_POST['sambosurname'] != ""){ echo "value='".$_POST['sambosurname']."'"; }?>> </td>
Code that didn't turn fields yellow:
<div align="right"><span class="apptxt"><?php echo $navn[$lang]; ?></span> </div> <td><input name="sambofirst" type="text" class="formstyle" id="sambofirst" size="30" <?php if(isset($_POST['sambofirst']) && $_POST['sambofirst'] != ""){ echo "value='".$_POST['sambofirst']."'"; }?>> </td> <div align="right"><span class="apptxt"><?php echo $etternavntxt[$lang]; ?></span></div> <td><input name="sambosurname" type="text" class="formstyle" id="sambosurname" size="30" <?php if(isset($_POST['sambosurname']) && $_POST['sambosurname'] != ""){ echo "value='".$_POST['sambosurname']."'"; }?>> </td>
Another thing, both fields had yellow background with the first example of code, none of them had background color with the second example of code(allthough i didn't change anything with the field name "sambosurname").
This is the corresponding css style if it matters:
<style> .formstyle{ font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 8pt; border-right: #CCCCCC 1px solid; border-top: #CCCCCC 1px solid; border-bottom: #CCCCCC 1px solid; border-left: #CCCCCC 1px solid; color: #000000; } </style>
I'm experiencing that some of my form elements gets a yellow background color. Does anyone else have this same problem and know a workaround for this(it looks kind of strange) ?
It happens to <input type="text">-elements, but I can't see a connection because it doesn't happen to all text-input elements...
Help would be much appreciated.
That did it :-)
Seems I still have plenty of mysql_xxxx to learn :-)
Hi.
Im having a script looking something like this:$sql = "SELECT * FROM Table WHERE columnID='3'"; $var = @mysql_query($sql); $res = @mysql_fetch_array($var); $num = @mysql_num_rows($var); echo "The result from ".$res['name']." returned ".$num." rows<br>"; $counter = 1; while($resarray = @mysql_fetch_array($var)){ echo "Result ".$counter.": ".$resarray['value'].""; $counter++; } //end while
First of all I must say that all functions have been tested before I've added the @ to the mysql_xxxx commands.
The problem is that when I run the while-loop it seems to be missing the first result(row) from the query. By this I mean that if $num returned 5 rows, the while loop will only return the last 4 of them.
Anybody know why, and the best workaround for this ?
--> I've tried to run the query again, and that of course works, but is this necessary to make it work(it will "double" the server load doing the query over again) ?
--> This is the "workaround doing a new query:$counter = 1; $newvar = mysql_query($var); //doing the query one more time while($resarray = @mysql_fetch_array($newvar)){ //fetch array from new query result echo "Result ".$counter.": ".$resarray['value'].""; $counter++; } //end while
Help would be much appreciated.
I most certainly agree with Roger Ramjet on the update query.
In this case though, I'm not even sure if adrianqx have come to the update part, so in that case perhaps just a simple javascript can do the display part of updated number of products and Roger Ramjet's update-sql could do the update itself in the database.
Adrianqx could perhaps supply some code to get more help/suggestions.
If you have copied this line of code into your script:
$amountin = ?(value from form)
You'll probably get an error like that.
You'll have to assign a value to the variable $amountin and bough probably ment that you were suppose to assign a value to that variable from your form. Dependant on what the name of your form field(in this case name="amount"), assign the value like this(assuming you have method="post" in your <form>-tag:
$amountin = $_POST['amount'];
Tnx. The solution seems to have solved my problem so far(it was the last sql I was looking for).
Hi.
I've searched a bit around the different boards on PHPbuilder, but i cannot find an answer to my questions yet.I'm familiar with easy php/mysql-applications, but i've run into a problem now. I'm trying to build a booking system(for training purpose), and I'm kind of stuck when it comes to this:
each booking record in db has a "from" and a "to" date(DATE format)
how can i return available objects when a user searchs for "available objects from 2006.01.01 to 2006.03.01 ?help would be much appreciated.
Hey.
I solved my problem...Hey.
I'm having trouble with the length of one field in this array i read/write to a csv-file for my system here at work.This is my code:
$linecontent[49] = $article; $newarticle = str_pad("".$linecontent[49]."", 10); $linecontent[49] = "\"".$newarticle."\"";
The trouble is that the length of the field [49] differs from line to line allthough I've used str_pad. Isn't that the whole idea about str_pad, or is my code wrong?
Help would be much appreciated.