Jump to content

jrphplover

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by jrphplover

  1. friend this is my pagination script, how can i make it to display the page 1 to show results of July 2013 only, page 2 should show results of June 2013 and page 3 should show May 2013 results? i would really appericiate if someone could help me out please. cheers $tableName="leads"; $targetpage = "search-record.php"; $limit = 2; $query = "SELECT COUNT(*) as num FROM $tableName WHERE agent = '".$_SESSION['SESS_LOGIN_NAME'] ."'"; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages[num]; $stages = 3; $page = mysql_escape_string($_GET['page']); if($page){ $start = ($page - 1) * $limit; }else{ $start = 0; } // Get page data $query1 = "SELECT * FROM $tableName LIMIT $start, $limit"; $result = mysql_query($query1); // Initial page num setup if ($page == 0){$page = 1;} $prev = $page - 1; $next = $page + 1; $lastpage = ceil($total_pages/$limit); $LastPagem1 = $lastpage - 1; $paginate = ''; if($lastpage > 1) { $paginate .= "<div class='paginate'>"; // Previous if ($page > 1){ $paginate.= "<a href='$targetpage?page=$prev'>previous</a>"; }else{ $paginate.= "<span class='disabled'>previous</span>"; } // Pages if ($lastpage < 7 + ($stages * 2)) // Not enough pages to breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } } elseif($lastpage > 5 + ($stages * 2)) // Enough pages to hide a few? { // Beginning only hide later pages if($page < 1 + ($stages * 2)) { for ($counter = 1; $counter < 4 + ($stages * 2); $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>"; $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>"; } // Middle hide some front and some back elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2)) { $paginate.= "<a href='$targetpage?page=1'>1</a>"; $paginate.= "<a href='$targetpage?page=2'>2</a>"; $paginate.= "..."; for ($counter = $page - $stages; $counter <= $page + $stages; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>"; $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>"; } // End only hide early pages else { $paginate.= "<a href='$targetpage?page=1'>1</a>"; $paginate.= "<a href='$targetpage?page=2'>2</a>"; $paginate.= "..."; for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } } } // Next if ($page < $counter - 1){ $paginate.= "<a href='$targetpage?page=$next'>next</a>"; }else{ $paginate.= "<span class='disabled'>next</span>"; } $paginate.= "</div>"; } echo '<p align="right">'; echo $total_pages.' Results, <b> Search </b> <input type="text" name="search" value="" id="id_search" /><br/><span class="loading">Loading... </span>'; echo '</p>'; // pagination echo $paginate;
  2. thanks all soo much for your precious time well i fixed it :-) its was a simple spelling mistake for which it was not inserting. paymentPeriod should have been repaymentPeriod :-D
  3. still its not inserting eh what is wrong here? here is the entire coding <?php //Start session session_start(); //Include database connection details require_once('config.php'); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Function to sanitize values received from the form. Prevents SQL injection function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } //Sanitize the POST values $agent = clean($_SESSION['SESS_LOGIN_NAME']); $customerName = clean($_POST['customerName']); $customerAddress = clean($_POST['customerAddress']); $homePhone = clean($_POST['homePhone']); $altPhone = clean($_POST['altPhone']); $loanAmount = clean($_POST['loanAmount']); $monthlyPayment = clean($_POST['monthlyPayment']); $repaymentPeriod = clean($_POST['repaymentPeriod']); $ssn = clean($_POST['ssn']); $dl = clean($_POST['dl']); $sid = clean($_POST['sid']); $monthlyIncome = clean($_POST['monthlyIncome']); $lastPayday = clean($_POST['lastPayday']); $nextPayday = clean($_POST['nextPayday']); $dob = clean($_POST['dob']); $transferNumber = clean($_POST['transferNumber']); $applicationNumber = clean($_POST['applicationNumber']); $comments = clean($_POST['comments']); //Input Validations if($customerName == '') { $errmsg_arr[] = 'Customer name is missing'; $errflag = true; } if($customerAddress == '') { $errmsg_arr[] = 'Customer address is missing'; $errflag = true; } if($loanAmount == '') { $errmsg_arr[] = 'Loan amount is missing'; $errflag = true; } //Check for duplicate login ID if($homePhone != '') { $qry = "SELECT * FROM leads WHERE homePhone='$homePhone'"; $result = mysql_query($qry); if($result) { if(mysql_num_rows($result) > 0) { $errmsg_arr[] = 'Customer with this number already exist'; $errflag = true; } @mysql_free_result($result); } else { die("Query failed"); } } //If there are input validations, redirect back to the registration form if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); header("location: add-record.php"); exit(); } //Create INSERT query $qry = "INSERT INTO leads ( agent, customerName, customerAddress, homePhone, altPhone, loanAmount, monthlyPayment, paymentPeriod, ssn, dl, sid, monthlyIncome, lastPayday, nextPayday, dob, transferNumber, applicationNumber, comments, date_time ) VALUES ('$agent', '$customerName', '$customerAddress', '$homePhone', '$altPhone', '$loanAmount', '$monthlyPayment', '$repaymentPeriod', '$ssn', '$dl', '$sid', '$monthlyIncome', '$lastPayday', '$nextPayday', '$dob', '$transferNumber', '$applicationNumber', '$comments', now())"; $result = @mysql_query($qry); print_r($qry); //Check whether the query was successful or not if($result) { header("location: record-success.php"); exit(); }else { die("Query failed"); } ?>
  4. i get5 that but when i print i see all data in values but it just do not insert
  5. please see what im doing wrong and how do i insert date into datetime field in database? $qry = "INSERT INTO leads ('agentID, customerName, customerAddress, homePhone, altPhone, loanAmount, monthlyPayment, paymentPeriod, ssn, dl, sid, monthlyIncome, lastPayday, nextPayday, dob, transferNumber, applicationNumber, comments, date_time) VALUES ('".$agentID."', '".$customerName."', '".$customerAddress."', '".$homePhone."', '".$altPhone."', '".$loanAmount."', '".$monthlyPayment."', '".$repaymentPeriod."', '".$ssn."', '".$dl."', '".$sid."', '".$monthlyIncome."', '".$lastPayday."', '".$nextPayday."', '".$dob."', '".$transferNumber."', '".$applicationNumber."', '".$comments."', 'CURRENT_TIMESTAMP')"; $result = @mysql_query($qry); print_r($qry); //Check whether the query was successful or not if($result) { header("location: record-success.php"); exit(); }else { die("Query failed");
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.