nickelus
Members-
Posts
39 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
nickelus's Achievements
Member (2/5)
0
Reputation
-
thanx xcandiottix but that threw the same error. However I did get it, goto() appears to be a reserved function as of 5.3, as soon as i replace all instances with new name chgSpot() no error
-
Anyone see what's wrong here? I've been making various changes with no success, the error is at line 147, its the goto() method <?php class DB_Result { private $id; // The ID that was created as a result of inserting a row private $length = 0; // The size of the resultset private $result; // The result itself private $currentRow = array(); // The row at our current position in the resultset private $position = 0; // Current position private $lastPosition = 0; // The last position we were at when we read from the resultset private $gotResult = false; // If we have pulled out any rows or not yet private $affectedRows = -1; // The affected number of rows from the query /** * Constructor * @param result result * @param resource connection * @param boolean insert query */ public function __construct(&$result, &$conn, $insert=false) { $this->result = $result; $this->conn = $conn; if ((@mysql_num_rows($this->result) >= 0 && $this->result !== false) || $insert) { if ($insert) $this->id = mysql_insert_id($conn); $this->length = (int) @mysql_num_rows($this->result); $this->affectedRows = mysql_affected_rows($conn); } } /** * Magic overloaded method. * Returns data from the resultset * @param string column */ public function __get($field) { if ($this->lastPosition != $this->position || !$this->gotResult) { mysql_data_seek($this->result, $this->position); $this->currentRow = mysql_fetch_assoc($this->result); $this->lastPosition = $this->position; $this->gotResult = true; } return $this->currentRow[$field]; } /** * Get the insert id */ public function id() { return $this->id; } /** * Size of the resultset */ public function length() { return $this->length; } /** * Go to the first row of the resultset * @return boolean */ public function first() { if ($this->length > 0) { $this->goto(0); return true; } else return false; } /** * Go to the last row of the resultset * @return boolean */ public function last() { return $this->goto($this->length-1); } /** * Check if we've reched the end of the resultset * @return boolean */ public function end() { if ($this->position >= $this->length) return true; else return false; } /** * Check if we are at the start of the resultset * @return boolean */ public function start() { return ($this->position < 0); } /** * Move to the next row of the resultset * @return boolean */ public function next() { return $this->goto($this->position+1); } /** * Move to the previous row in the resultset * @return boolean */ public function prev() { return $this->goto($this->position-1); } /** * Go to a specified row in the resultset * Row numbering starts at zero * @param int row * @return boolean */ public function goto($position) { if ($position < 0 || $position > $this->length) return false; else { $this->position = $position; return true; } } /** * Get the affected number of rows */ public function affectedRows() { return $this->affectedRows; } /** * Get the result resource itself */ public function &get() { return $this->result; } /** * Get the current position */ public function position() { return $this->position; } } // end of DB_Result ?>
-
thanks i love to see simple fixes to things i ponder for hours lol
-
i have checkbox column returned in a table row by a while statement. How can i grab the id from each row where the state is changed to post, then i can update the db
-
i should mention that the array is already in a particular order which would eliminate the last option and also the reason i want to pass the array through the buttons
-
can i get the array first then use the next() & prev() in a conditional way in combination with the buttons. i want to do something different than pagination. so maybe as the pointer increases or decreases use the value to hold the place
-
i have a table that holds client records with a pri key of account _id. i am attempting to use an array of all of the account_ids to shift to the next or previous id in the array depending on which button was pressed
-
is it possible to use an non-paged list such as an array of record_ids and a set of next /prev buttons to navigate through rows in a mysql db to display an individuals record ex. client records
-
getting closer date("Y-m-d",strtotime("+7 days", date("Y-m-d",$sDate))) but now my end date is being calc'ed from todays date and i was trying to make it from start date
-
well i've tried strtotime and mktime, and date() functions in various combinations but still frankenstein the latest is still not giving back a valid end date strtotime(date("Y-m-d", strtotime($date)) . " +1 day");
-
i've been trying to set an option value that posts to a variable which is switched based on say Last week(past 7 days), last month(past 30days),etc.. then generates two vaiables a start and end date to be used for mysql query Hers my latest attempt <?php if(isset($_POST['submit'])){ $freq = $_POST['freq']; switch ($freq) { case "This Week":{ $freq=date('Y-m-d', strtotime("-7 days"));break; } case "Last Week":{ $freq=date('Y-m-d', strtotime("-14 days"));break; } case "YTD":{ $freq=date('Y-m-d', strtotime("-365 days"));break; } case "This Month":{ $freq=date('Y-m-d', strtotime("-30 days"));break; } case "Last Month":{ $freq=date('Y-m-d', strtotime("-60 days"));break; } case "This Quarter":{ $freq=date('Y-m-d', strtotime("-120 days"));break; } case "Last Quarter":{ $freq=date('Y-m-d', strtotime("-240 days"));break; } } $sDate = $freq; echo $sDate; $freq = $_POST['freq']; $d = mktime(0,0,0,$month,$day,$year); switch ($freq) { case "This Week":{ $freq=date($sDate,strtotime("+7 days",$d));break; } case "Last Week":{ $freq=date(date("m-d-Y",$sDate),strtotime("+7 days",$d));break; } case "YTD":{ $freq=date($sDate,strtotime("+365 days",$d));break; } case "This Month":{ $freq=date($sDate,strtotime("+30 days",$d));break; } case "Last Month":{ $freq=date($sDate,strtotime("+30 days",$d));break; } case "This Quarter":{ $freq=date($sDate,strtotime("+120 days",$d));break; } case "Last Quarter":{ $freq=date($sDate,strtotime("+120 days",$d));break; } } $eDate = $freq;echo $eDate; } ?> <form action="test_dates.php" method="post"> <table> <tr> <td>Report Scope: </td> <td> <select name="freq" value=""> <option <?php if(isset($freq)&&($freq=="")){ echo "selected";}?>>(Choose One)</option> <option value="This Week" <?php if(isset($freq)&&($freq=="This Week")){ echo "selected";}?>>This Week</option> <option value="Last Week"<?php if(isset($freq)&&($freq=="Last Week")){ echo "selected";}?>>Last Week</option> <option value="YTD"<?php if(isset($freq)&&($freq=="YTD")){ echo "selected";}?>>YTD</option> <option value="This Month"<?php if(isset($freq)&&($freq=="This Month")){ echo "selected";}?>>This Month</option> <option value="Last Month"<?php if(isset($freq)&&($freq=="Last Month")){ echo "selected";}?>>Last Month</option> <option value="This Quarter"<?php if(isset($freq)&&($freq=="This Quarter")){ echo "selected";}?>>This Quarter</option> <option value="Last Quarter"<?php if(isset($freq)&&($freq=="Last Quarter")){ echo "selected";}?>>Last Quarter</option> </select> </td> </tr> <tr><td> </td><td><input type="submit" name="submit" value="Submit"></td></tr> </table> </form>
-
somehow its mixing up the date and month
-
yeah strtotime() is the first way i tried but with no success. So then i figured maybe since the data was already formatted as a date i would try without strtotime() same results
-
Hi folks, I'm having a hell of a time reordering my date format. I'm using a JavaScript date picker calendar on in my form to post data. the date picker likes to see the m-d-Y format otherwise it cant define the days or months properly. so i use date_format() in the query and all is fine. however when i format the date to Y-m-d & update the records in the db the date is not correct(non well formed) in a troubleshooting script Ive done this to isolate the issue. Form: <?php include db.php; mysql_select_db($database_bio); $ctrct="SELECT client_id,date_format(start_date,'%m-%d-%Y') AS sd , date_format(end_date,'%m-%d-%Y') AS ed,term_length,drum_count,drum_amt_paid,price_per,contract_id,freq,contract_status FROM `contract` WHERE contract_id=$contract_id"; $ctrct_qry=mysql_query($ctrct); while($row=mysql_fetch_array($ctrct_qry)){ $client_id=$row[0]; $start_date=$row['sd']; $end_date=$row['ed']; $term_length=$row[3]; $drum_count=$row[4]; $drum_amt_paid=$row[5]; $price_per=$row[6]; $contract_id=$row[7]; $freq=$row[8]; $contract_status=$row[9];?> <form name="contract" method="POST" action="<?php echo "test_dates.php";?>"> <table align="center"> <tr> <td align="center"><strong>Start date</strong></td> <td align="center"><input name="start_date" type="text" value="<?php if(isset($start_date)){ echo date("m-d-Y",strtotime($start_date)); } ?>" onFocus="showCalendarControl(this);"/> </td> </tr><tr> <td align="center"><strong>End date</strong></td> <td align="center"><input name="end_date" type="text" value="<?php if(isset($end_date)){ echo date("m-d-Y",strtotime($end_date)); } ?>" onFocus="showCalendarControl(this);"/></td> </tr></table></form> Testing: <?php $sDate=$_POST['start_date']; $eDate=$_POST['end_date']; echo $sDate."<br/>"; echo $eDate."<br/>"; $s=date('Y-m-d',$sDate); $e=date('Y-m-d',$eDate); echo $s."<br/>"; echo $e."<br/>";?> and what i get back from $s and $e is 1969-12-31 or non well formed. i've also tried $s=date("Y-m-d",strtotime($sDate)) in place of just plain date()
-
correct i was getting back results for null rows in the column