Jump to content

dardime

Members
  • Posts

    34
  • Joined

  • Last visited

Everything posted by dardime

  1. Hi Thank you for the reply. I know its basic programming but WHY it outputs 0 (zero)? If i use this code below it will work correctly: $percentage = 0.1; $result = (1.0 - $percentage) * 80; echo 'The result is '.$result.'<br>';
  2. Hi There is a value into it. I fetch it from db i think i dont need to show that anymore echo $row_product["rrp"]; The value of that is 80.
  3. Hi Thank you for your reply. Here is the code im fetching but it is empty $str = $row_product["rrp"]; If i will put a static value it will work echo "80";
  4. Hi I need help to store echo value in php and store on a variable but i get empty result. Thank you <?php ob_start(); $str = $row_product["rrp"]; echo $str; $value = ob_get_contents(); $percentToGet = 10; $percentInDecimal = $percentToGet / 100; $result= $value * $percentInDecimal; ob_end_clean(); echo $result-$value; ?> Thank you!
  5. Syntax error again. Please help! $sql = "UPDATE stock_product SET quantity = quantity - 1 WHERE id=".$_GET['id']."; UPDATE stock_product SET quantity = quantity + 1 WHERE id='".$_POST['id']."'";
  6. Hi Im about to update two query in mysql that subtracts quantity of current ID and add quantity to another ID but i got error on mysql. Here is my code: <?php require_once('localhost.php'); ?> <?php if(!isset($_SESSION)){ session_start(); } include_once("../repair/includes/product.php"); $product = new product(); $productstock = $product->fetchProduct(stripslashes($_GET["id"])); if(!empty($_POST)){ //Update include_once("../repair/includes/conn_logs.php"); if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } $sql = "UPDATE stock_product SET quantity='".$productstock["quantity"]-$_POST["quantity"]."' WHERE id='".$_GET['id']."; UPDATE stock_product SET quantity='".$productstock["quantity"]+$_POST["quantity"]."' WHERE id='".$_POST['id']."'"; if(mysqli_query($link, $sql)){ echo ""; } else{ echo "" . mysqli_error($link); } //Update } ?> HTML/PHP form <div class="alert-danger"><?php if(empty($error)){ echo ''; }else{ echo '<div class="msg" style="text-align:left;">'.$error.'</div>'; } ?></div> <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>?id=<?php echo $productstock["id"]; ?>"> <input type="hidden" name="id" value="<?php echo $id; ?>" /> <table class="table"> <tbody> <tr> <td><strong>Product ID:</strong></td> <td><?php echo $productstock["id"]; ?></td> <td><strong>Brand:</strong></td> <td><?php echo $productstock["brand_id"]; ?></td> </tr> <tr> <td><strong>Name:</strong></td> <td><?php echo $productstock["name"]; ?></td> <td><strong>Category:</strong></td> <td><?php echo $productstock["category_id"]; ?></td> <tr> <td><strong>Branch:</strong></td> <td><?php echo $productstock["branch"]; ?></td> <td><strong>Quantity:</strong></td> <td><?php echo $productstock["quantity"]; ?></td> </tr> <tr> <td><strong>Quantity:</strong></td> <td><input name="quantity" type="text" id="quantity" placeholder="Quantity" class="form-control"/></td> <td>Product ID:</td> <td><input name="id" type="text" id="id" placeholder="Product ID" class="form-control"/></td> </tr> </tbody> </table> <input class="form-control" type="hidden" name="id" id="id" value="<?php echo $_POST["id"]; ?>"> <input class="form-control" type="hidden" name="quantity" id="quantity" value="<?php echo $_POST["quantity"]; ?>"> <input name="submit" type="submit" class="btn btn-primary" value="Transfer Stock"> </form> Thanks in advance for your help!
  7. Hi This gives me error SELECT sip.quantity as quantity_sip, sp.quantity as quantity_sp FROM stock_stockin si,stock_stockin,stock_stockin_product,stock_product INNER JOIN stock_stockin_product sip ON si.id=sip.stockin_id INNER JOIN stock_product sp ON sp.id=sip.product_id WHERE stock_date>='1488366000' AND stock_date<='1488538800' AND stock_product.brand_id='11' AND stock_product.category_id='27' AND stock_product.model LIKE '%iphone 6%' AND stock_sto
  8. Hi I have 3 tables and i want to search record on 3 tables but when i query i noticed the row QUANTITY is used on stock_stockin_product and stock_product tables. When i displayed the output it shows the QUANTITY on tae stock_product which is i dont want it. I want to display QUANTITY on stock_stockin_product table. Here is my query: SELECT * FROM stock_stockin,stock_stockin_product,stock_product WHERE stock_date>='1488366000' AND stock_date<='1488538800' AND stock_product.brand_id='11' AND stock_product.category_id='27' AND stock_product.model LIKE '%iphone 6%' AND stock_stockin.branch LIKE '%henderson%' AND stock_product.id=stock_stockin_product.product_id AND stock_stockin.id=stock_stockin_product.stockin_id GROUP BY stock_stockin.id Output: All I need is the output QUANTITY 30 which i circled red. Thank you in advance for your help.
  9. Hi Thank you so much for your reply but i have tried adding exit() after header but it does the same thing. Please help Thank you
  10. hmmm yeah it loaded twice coz it redirects to payment gateway page and return the page.if the payment is decline it wont send any though. thanks for reply
  11. Hi I just need help on why my php mail function sends out 4 emails. Two emails each will be sent on 131 and 139. Im configuring a payment merchant. Thank you <?php #Inlcude PxPay objects include "PxPay_Curl.inc.php"; $PxPay_Url = ""; //$PxPay_Url = ""; $PxPay_Userid = ""; #Important! Update with your UserId $PxPay_Key = ""; #Important! Update with your Key # # MAIN # $pxpay = new PxPay_Curl( $PxPay_Url, $PxPay_Userid, $PxPay_Key ); if (isset($_REQUEST["result"])) { # this is a redirection from the payments page. print_result(); } elseif (isset($_REQUEST["Submit"])) { # this is a post back -- redirect to payments page. //START OF ADDITION BY JOHNREY include_once('includes/config.php'); include_once('includes/payment.php'); include_once('includes/generic.php'); $payment = new payment(); $generic = new generic(); if(!empty($_POST)){ $arr = array( "name" => $_POST["name"], "address" => $_POST["Address1"], "email" => $_POST["Address3"], "contact" => $_POST["contact"], "job" => $_POST["job"], "amount" => $_POST["Quantity"], ); $validate = $generic->validate($arr); if(!$validate["error"]){ $arr = array( "reference_no" => stripslashes($_POST["Reference"]), "name" => stripslashes($_POST["name"]), "address" => stripslashes($_POST["Address1"]), "email" => stripslashes($_POST["Address3"]), "contact" => stripslashes($_POST["contact"]), "job" => stripslashes($_POST["job"]), "description" => stripslashes($_POST["description"]), "amount" => stripslashes($_POST["Quantity"]), "date" => date('Y-m-d H:i:s') ); $payments = $payment->addPayment($arr); } } //END OF ADDITION BY JOHNREY redirect_form(); } else { # this is a fresh request -- display the purchase form. //print_form(); } #****************************************************************************** # This function receives information back from the payments page, # and displays it to the user. #****************************************************************************** function print_result() { global $pxpay; $enc_hex = $_REQUEST["result"]; #getResponse method in PxPay object returns PxPayResponse object #which encapsulates all the response data $rsp = $pxpay->getResponse($enc_hex); # the following are the fields available in the PxPayResponse object $Success = $rsp->getSuccess(); # =1 when request succeeds $AmountSettlement = $rsp->getAmountSettlement(); $AuthCode = $rsp->getAuthCode(); # from bank $CardName = $rsp->getCardName(); # e.g. "Visa" $CardNumber = $rsp->getCardNumber(); # Truncated card number $DateExpiry = $rsp->getDateExpiry(); # in mmyy format $DpsBillingId = $rsp->getDpsBillingId(); $BillingId = $rsp->getBillingId(); $CardHolderName = $rsp->getCardHolderName(); $DpsTxnRef = $rsp->getDpsTxnRef(); $TxnType = $rsp->getTxnType(); $TxnData1 = $rsp->getTxnData1(); $TxnData2 = $rsp->getTxnData2(); $TxnData3 = $rsp->getTxnData3(); $CurrencySettlement= $rsp->getCurrencySettlement(); $ClientInfo = $rsp->getClientInfo(); # The IP address of the user who submitted the transaction $TxnId = $rsp->getTxnId(); $CurrencyInput = $rsp->getCurrencyInput(); $EmailAddress = $rsp->getEmailAddress(); $MerchantReference = $rsp->getMerchantReference(); $ResponseText = $rsp->getResponseText(); $TxnMac = $rsp->getTxnMac(); # An indication as to the uniqueness of a card used in relation to others if ($rsp->getSuccess() == "1") { $result = '<div class="alert-success">The transaction was approved.</div>'; # Sending invoices/updating order status within database etc. if (!isProcessed($TxnId)) { # Send emails, generate invoices, update order status etc. //MAILTO $emailto = $TxnData3; $subjectto = "Online Payment"; $messageto = "Payment Details: \r\n\n Reference No: OT" . $MerchantReference . "\r\n\n Name: " . $CardHolderName . "\r\n\n Address: " . $TxnData1 . "\r\n\n Email: " . $TxnData3 . "\r\n\n Amount Paid: NZD " . $AmountSettlement . "\r\n\n Payment Status: " . $ResponseText."\r\n\n If you have any urgent queries, please call our Help Desk.\r\n\n Best Regards,\n "; $headersto = 'From: email@email.co.nz' . "\r\n" . 'Reply-To: email@email.co.nz' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($emailto, $subjectto, $messageto, $headersto); $to = "email@email.co.nz"; $subject = "Online Payment - Reference No: OT" . $MerchantReference .""; $msg = "Payment Details: \r\n\n Reference No: OT" . $MerchantReference . "\r\n\n Name: " . $CardHolderName . "\r\n\n Address: " . $TxnData1 . "\r\n\n Email: " . $TxnData3 . "\r\n\n Amount Paid: NZD " . $AmountSettlement . "\r\n\n Payment Status: " . $ResponseText; $headers = 'From: '. $TxnData3 . "\r\n" . 'Reply-To: email@email.co.nz' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $msg, $headers); //END OF //MAILTO } } else { $result = '<div class="alert-danger">The transaction was declined.</div>'; } print <<<HTMLEOF <html> <head> <title>Direct Payment Solutions PxPay transaction result</title> </head> <body> <p>$result</p> </body> </html> HTMLEOF; } #****************************************************************************** # Database lookup to check the status of the order or shopping cart #****************************************************************************** function isProcessed($TxnId) { # Check database if order relating to TxnId has alread been processed return false; } #****************************************************************************** # This function prints a blank purchase form. #****************************************************************************** function print_form() { print <<<HTMLEOF <html> <head> <title>Direct Payment Solutions PxPay transaction sample</title> </head> <body> <h1>Direct Payment Solutions PxPay transaction result</h1> <p> You have indicated you would like to buy some widgets. </p> <p> Please enter the number of widgets below, and enter your shipping details. </p> <form method="post"> <table> <tr> <td>Quantity:</td> <td><input name="Quantity" type="text"/></td> </tr> <tr> <td>Reference:</td> <td><input name="Reference" type="text"/></td> </tr> <tr> <td>Ship to</td> <td></td> </tr> <tr> <td>Address line 1:</td> <td><input name="Address1" type="text"/></td> </tr> <tr> <td>Address line 2</td> <td><input name="Address2" type="text"/></td> </tr> <tr> <td>Address line 3</td> <td><input name="Address3" type="text"/></td> </tr> </table> <input name="Submit" type="submit" value="Submit"/> Click submit to go to the secure payment page. </form> </body> </html> HTMLEOF; } #****************************************************************************** # This function formats data into a request and redirects to the # Payments Page. #****************************************************************************** function redirect_form() { global $pxpay; $request = new PxPayRequest(); $http_host = getenv("HTTP_HOST"); $request_uri = getenv("SCRIPT_NAME"); $server_url = "http://$http_host"; #$script_url = "$server_url/$request_uri"; //using this code before PHP version 4.3.4 #$script_url = "$server_url$request_uri"; //Using this code after PHP version 4.3.4 $script_url = (version_compare(PHP_VERSION, "4.3.4", ">=")) ?"$server_url$request_uri" : "$server_url/$request_uri"; # the following variables are read from the form $Quantity = $_REQUEST["Quantity"]; $MerchantReference = $_REQUEST["Reference"]; $Address1 = $_REQUEST["Address1"]; $Address2 = $_REQUEST["Address2"]; $Address3 = $_REQUEST["Address3"]; #Calculate AmountInput $AmountInput = $Quantity; #Generate a unique identifier for the transaction $TxnId = uniqid("ID"); #Set PxPay properties $request->setMerchantReference($MerchantReference); $request->setAmountInput($AmountInput); $request->setTxnData1($Address1); $request->setTxnData2($Address2); $request->setTxnData3($Address3); $request->setTxnType("Purchase"); $request->setCurrencyInput("NZD"); $request->setEmailAddress($EmailAddress); $request->setUrlFail($script_url); # can be a dedicated failure page $request->setUrlSuccess($script_url); # can be a dedicated success page $request->setTxnId($TxnId); #The following properties are not used in this case # $request->setEnableAddBillCard($EnableAddBillCard); # $request->setBillingId($BillingId); # $request->setOpt($Opt); #Call makeRequest function to obtain input XML $request_string = $pxpay->makeRequest($request); #Obtain output XML $response = new MifMessage($request_string); #Parse output XML $url = $response->get_element_text("URI"); $valid = $response->get_attribute("valid"); #Redirect to payment page header("Location: ".$url); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Online Payment</title> <!-- CSS --> <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:400,100,300,500"> <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css"> <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css"> <link rel="stylesheet" href="dist/css/form-elements.css"> <link rel="stylesheet" href="dist/css/style.css"> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> <![endif]--> <!-- Favicon and touch icons --> <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script> <script> function validateForm() { var a = document.forms["myform"]["name"].value; var x = document.forms["myform"]["Address1"].value; var c = document.forms["myform"]["Address3"].value; var atpos = c.indexOf("@"); var dotpos = c.lastIndexOf("."); if (atpos<1 || dotpos<atpos+2 || dotpos+2>=c.length) { alert("Invalid e-mail address"); return false; } var d = document.forms["myform"]["contact"].value; var e = document.forms["myform"]["job"].value; //var f = document.forms["myform"]["description"].value; var g = document.forms["myform"]["Quantity"].value; if (a == null || a == "") { alert("Name must be filled out"); return false; } if (x == null || x == "") { alert("Address must be filled out"); return false; } if (d == null || d == "") { alert("Contact No. must be filled out"); return false; } if (e == null || e == "") { alert("Job No. must be filled out"); return false; } //if (f == null || f == "") { //alert("Post Code must be filled out"); //return false; //} if (g == null || g == "") { alert("Amount must be filled out"); return false; } } </script> </head> <body> <!-- Top menu --> <!-- Top content --> <div class="top-content"> <div class="inner-bg"> <div class="container"> <div class="row"> <div class="col-sm-6 col-sm-offset-3 form-box"> <div class="form-top"> <div align="center"; style="padding-top:10px"> <img src="includes/logo.png"> </div> <div align="center"> <h3>Online Payment</h3> </div> </div> <div class="form-bottom contact-form"> <?php //START OF ADDITION BY JOHNREY include_once('includes/config.php'); include_once('includes/payment.php'); include_once('includes/generic.php'); $payment = new payment(); $generic = new generic(); if(!empty($_POST)){ $arr = array( "name" => $_POST["name"], "address" => $_POST["Address1"], "email" => $_POST["Address3"], "contact" => $_POST["contact"], "job" => $_POST["job"], "amount" => $_POST["Quantity"], ); $validate = $generic->validate($arr); } //END OF ADDITION BY JOHNREY ?> <div class="alert-danger" style="margin-bottom:20px;"><?php if(empty($error)){ echo ''; }else{ echo '<div class="msg" style="text-align:left;">'.$error.'</div>'; } ?></div> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" onsubmit="return validateForm()" name="myform" id="myform"> <?php $refquery = mysql_query("SELECT * FROM `tbpayment` ORDER BY payment_id DESC"); if($refquery) { $ref = mysql_fetch_assoc($refquery); $ref_no = intval($ref["reference_no"]) + 1; } else $ref_no = 100000; $str = strval($ref_no); $limit = 11-strlen($str); $reference = ""; for($i=0; $i<$limit; $i++) { $reference .= "0"; } $reference = $ref_no; ?> <div class="form-group"> Reference No: OT<?php echo $reference; ?> </div> <input class="form-control" type="hidden" name="Reference" id="Reference" value="<?php echo $reference; ?>"> <div class="form-group"> </div> Customer Details <div class="form-group"> <label class="sr-only" for="contact-name">Name</label> <input type="text" name="name" placeholder="Name" class="contact-name form-control" id="name" value="<?php if(!empty($_POST["name"]) && !empty($error)) { echo $_POST["name"]; } ?>" required> </div> <div class="form-group"> <textarea name="Address1" placeholder="Address" class="contact-message form-control" id="Address1"><?php if(!empty($_POST["Address1"]) && !empty($error)) { echo $_POST["Address1"]; } ?></textarea> </div> <div class="form-group"> <label class="sr-only" for="contact-email">Email</label> <input type="text" name="Address3" placeholder="Email" class="contact-email form-control" id="Address3" value="<?php if(!empty($_POST["Address3"]) && !empty($error)) { echo $_POST["Address3"]; } ?>" required> </div> <div class="form-group"> <label class="sr-only" for="contact-number">Contact Number</label> <input type="text" name="contact" placeholder="Contact Number" class="contact-number form-control" id="contact" value="<?php if(!empty($_POST["contact"]) && !empty($error)) { echo $_POST["contact"]; } ?>" required> </div> Payment Details <div class="form-group"> <label class="sr-only" for="contact-job">Job Number</label> <input type="text" name="job" placeholder="Job Number" class="contact-job form-control" id="job" value="<?php if(!empty($_POST["job"]) && !empty($error)) { echo $_POST["job"]; } ?>" required> </div> <div class="form-group"> <label class="sr-only" for="contact-job">Invoice Description</label> <input readonly type="text" name="description" placeholder="Invoice Description" class="contact-job form-control" id="description" value="Mobile Phone Repair" required> </div> <div class="form-group"> <label class="sr-only" for="contact-job">Amount</label> <input type="text" name="Quantity" placeholder="Amount" class="contact-job form-control" id="Quantity" value="<?php if(!empty($_POST["Quantity"]) && !empty($error)) { echo $_POST["Quantity"]; } ?>" required> <div align="center" style="padding-top:20px"><input name="Submit" type="submit" class="btn btn-primary" value="Pay Now"></div> </form> </div> </div> </div> </div> </div> </div> <!-- Javascript --> <script src="bower_components/jquery/dist/jquery.min.js"></script> <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script> <script src="dist/js/jquery.backstretch.min.js"></script> <script src="dist/js/scripts.js"></script> <!--[if lt IE 10]> <script src="assets/js/placeholder.js"></script> <![endif]--> </body> </html>
  12. Hi I need help to display my search results. The sql code works on SQL Query but it wont display on the page. Any help would be great. Thanks in advance. SQL Query: SELECT * FROM tbrepair WHERE dtSDate>='2016/04/01' AND dtSDate<='2016/04/02' Here is my code <?php require_once('localhost.php'); session_start(); include_once("includes/paging.class.php"); $page = new paging(); $page->db(); $page->table = "tbrepair"; if(!empty($_POST)) { $start_date = $_POST["start_date"]; $end_date = $_POST["end_date"]; //$start_date = strtotime($_POST["month_from"]." ".$_POST["day_from"].", ".$_POST["year_from"]); //$end_date = strtotime($_POST["month_to"]." ".$_POST["day_to"].", ".$_POST["year_to"]); $page->cond = "dtSDate>='".$start_date."' AND dtSDate<='".$end_date."'"; $page->selectQuery(); $sales = $page->fetchQuery(); } else { if(isset($_GET["page"]) && !empty($_GET["page"])) { $current_page = intval($_GET["page"]); } else $current_page = 1; $page->page = $current_page; $page->page_limit = 10; $page->generateSelectQuery(); $page->generatePaging(); $sales = $page->page_results; } ?> Here is the form and pagination <form method="post"> <td align="right"><strong>Start Date</strong></td> <td align="left"> <input type="text" class="ui-date" name="start_date" id="start_date" placeholder="Start Date" value="<?php if(!empty($_POST["start_date"]) && !empty($error)) { echo $_POST["start_date"]; } ?>"> </td> <td align="left"><strong>End Date</strong></td> <td align="right"> <input type="text" class="ui-date" name="end_date" id="end_date" placeholder="End Date" value="<?php if(!empty($_POST["end_date"]) && !empty($error)) { echo $_POST["end_date"]; } ?>"> </td> <input type="submit" name="Submit" value="Search" class="medium button"> </form> </div> <table width="960" height="52" border="0" align="left" cellpadding="0" cellspacing="0" class="admin applicants"> <tr class="table-top-bg"> <th width="19%" height="26" scope="col"><div align="center">DATE</div></th> <th width="22%" scope="col"><div align="center">JOB NO</div></th> </tr> <?php if(!empty($sales)) { foreach($sales as $sale) { ?> <tr> <td width="19%" height="26" scope="col"><div align="center"><?php echo date("F d, Y",$sale["dtSDate"]); ?></div></td> <td width="22%" scope="col"><div align="center"><?php echo $sale["cJN"]; ?></div></td> </tr> <?php } } else { ?> <div style="padding-bottom:20px; padding-left:20px;">No records found. Please try again.</div> <?php } ?> </table> <?php if(empty($_POST)) { ?> <div class="link-fonts" style="clear:both; margin:13px 21px 0px 0px; float:right; font-weight:bold;"> <?php $url = "manage-sales.php"; if($page->page <= 1) $start = ''; else $start = '<a href="'.$url.'?page=1" class="listViewPaginationLinkS1">Start</a>'; //prev if($page->page <= 1) $prev = ''; else $prev = '<a href="'.$url.'?page='.$page->page_details["prev"].'" class="listViewPaginationLinkS1">Previous</a>'; //label $label = '<span class="pageNumbers">'.$page->page_details["start"].' - '.$page->page_details["to"].' of '.$page->page_details["total"].'</span>'; //next if($page->page >= $page->page_details["last"]) $next = ''; else $next = '<a href="'.$url.'?page='.$page->page_details["next"].'" class="listViewPaginationLinkS1">Next</a>'; //end if($page->page >= $page->page_details["last"]) $end = ''; else $end = '<a href="'.$url.'?page='.$page->page_details["last"].'" class="listViewPaginationLinkS1">End</a>'; echo $start.' '.$prev.' '.$label.' '.$next.' '.$end; $page->mysqlClose(); } ?> </div> Thank you in advance for your help.
  13. Hi I need help in joining two database output: tblog and tbassignlog with the same fields both of them. mysql_select_db($database_localhost, $localhost); $query_rs = sprintf("SELECT * FROM tblog WHERE cJN = '%s' ORDER BY dtDate DESC", $colname_rs); $rs = mysql_query($query_rs, $localhost) or die(mysql_error()); $row_rs = mysql_fetch_assoc($rs); $totalRows_rs = mysql_num_rows($rs); Thank you in advance.
  14. Hi there i need to add date and time to my sql but its only adding the date.... My code: $colname_rs = "-1"; if (isset($_GET['iID'])) { $colname_rs = (get_magic_quotes_gpc()) ? $_GET['iID'] : addslashes($_GET['iID']); } mysql_select_db($database_localhost, $localhost); $query_rs = "SELECT *,DATE_FORMAT(dtDate,'%d %b %Y, %h:%i %p') AS dtSDate FROM tbdo WHERE iID = '". $colname_rs."'"; $rs = mysql_query($query_rs, $localhost) or die(mysql_error()); $row_rs = mysql_fetch_assoc($rs); $totalRows_rs = mysql_num_rows($rs); Thanks in advance for your help!
  15. Hi i need help in adding a checkbox saying I AGREE on my popup. Thank you in advance. Here is my code below: $('#working_days').change(function(){ if($(this).val()=="2 to 3"){ alert("Please inform the customer that the time starts once the job has been assigned to the technician. If this Job is assigned after 3pm the timeframe starts from the next working day") } else if($(this).val()=="3 to 5"){ alert("Please inform the customer that the time starts once the job has been assigned to the technician. If this Job is assigned after 3pm the timeframe starts from the next working day") } else if($(this).val()=="5 to 7"){ alert("Please inform the customer that the time starts once the job has been assigned to the technician. If this Job is assigned after 3pm the timeframe starts from the next working day") } else if($(this).val()=="Others"){ alert("Please inform the customer that the time starts once the job has been assigned to the technician. If this Job is assigned after 3pm the timeframe starts from the next working day") } }) <select name="working_days" id="working_days" class="requiredField"> <option value="">Select working days</option> <option value='2 to 3'>2 to 3</option> <option value='3 to 5'>3 to 5</option> <option value='5 to 7'>5 to 7</option> <option value='Others'>Others</option> </select>
  16. Hi there thanks for your reply. I need help to join two tables so i can get all the result. Thanks in advance for your help. stock_stockin stock_stockin_product I need to get this result but i dont know how to join these two tables.
  17. hi ther. i tried both but it doesnt work. thanks.
  18. Hi Thank you for your reply. Here is my class function: <?php session_start(); include_once("db.class.php"); class paging extends db { //for mysql paging var $page; var $page_limit; var $page_details = array(); var $page_results = array(); var $grid_columns; var $grid_results = array(); var $tab_border; var $tab_width; var $tab_padding; var $tab_spacing; var $tab_col_width; var $tab_header = array(); var $tab_header_class; var $tab_data_class; var $tab_data_odd_class; var $tab_data_even_class; function generatePaging() { if(!$this->page) $this->page = 1; $this->result = mysql_query($this->myquery); if($this->result) { $total = mysql_num_rows($this->result); $last = intval(($total/$this->page_limit)); if($this->page<=1) { $start = 0; $prev = 1; } else { $start = ($this->page-1)*$this->page_limit; $prev = $this->page-1; } $end = $this->page_limit; $next = $this->page+1; $last = intval($total/$this->page_limit); if(($total/$this->page_limit) > $last) $last += 1; if(!$last) $last = 1; if($next>$last) $next = $last; $this->myquery = $this->myquery." LIMIT ".$start.",".$end; //echo $this->myquery; $this->result = mysql_query($this->myquery); $end = mysql_num_rows($this->result); for($i=0;$row=mysql_fetch_assoc($this->result);$i++) { $this->page_results[] = $row; } if($this->page_results) { $start += 1; $to = $start + $end - 1; } else { $start = 0; $to = 0; } if($to>$total) $to = $total; for($j=0,$i=$start;$i<=$last;$i++,$j++) { $pages[$j] = $i; } $this->page_details = array( "prev" => $prev, "next" => $next, "start" => $start, "to" => $to, "total" => $total, "last" => $last, "pages" => $pages ); } return 1; } function generateGrid() { $w = 0; $x = $this->grid_columns; $z = count($this->page_results)/$x; $y = intval($z); if($z>$y) $y++; for($j=0;$j<$y;$j++) { for($i=0;$i<$x;$i++,$w++) { if($this->page_results[$w]) $this->grid_results[$j][$i] = $this->page_results[$w]; else break; } } return 1; } function tabulate() { if(count($this->tab_header)) { $table = "<table"; if($this->tab_border) $table .= " border='".$this->tab_border."'"; if($this->tab_width) $table .= " width='".$this->tab_width."'"; if($this->tab_padding) $table .= " cellpadding='".$this->tab_padding."'"; if($this->tab_spacing) $table .= " cellspacing='".$this->tab_spacing."'"; $table .= ">"; if($this->tab_header) { $table .= "<tr>"; $i = 0; foreach($this->tab_header as $tab_header) { $table .= "<td"; if($this->tab_header_class) $table .= " class='".$this->tab_header_class."'"; if($this->tab_header_align) $table .= " align='".$this->tab_header_align."'"; if($this->tab_col_width[$i]) $table .= " width='".$this->tab_col_width[$i]."'"; $table .= ">".$tab_header."</td>"; $i++; } $table .= "</tr>"; } if($j=count($this->page_results)) { for($i=0;$i<$j;$i++) { $table .= "<tr>"; foreach($this->page_results[$i] as $val) { $table .= "<td"; if($this->tab_data_class) $table .= " class='".$this->tab_data_class."'"; else if($this->tab_data_even_class && !($k%2)) $table .= " class='".$this->tab_data_even_class."'"; else if($this->tab_data_odd_class && ($k%2)) $table .= " class='".$this->tab_data_odd_class."'"; $table .= ">".$val."</td>"; } $table .= "</tr>"; } } $table .= "<table>"; return $table; } else { echo "error: header lacking."; return 0; } } } ?> function generateSelectQuery() { if(is_array($this->required)) { $j = count($this->required); for($i=0;$i<$j;$i++) { $req .= "`".$this->required[$i]."`"; if($j-1 != $i) $req .= ","; } $myquery = "SELECT ".$req." FROM ".$this->table; } else { if(!$this->required) $myquery = "SELECT * FROM ".$this->table; else $myquery = "SELECT ".$this->required." FROM ".$this->table; } if($this->cond) $myquery .= " WHERE ".$this->cond; if($this->groupby) $myquery .= " GROUP BY ".$this->groupby; if($this->order) $myquery .= " ORDER BY ".$this->order; if($this->ordertype) $myquery .= " ".$this->ordertype; if($this->limit) $myquery .= " LIMIT ".$this->limit; //echo $myquery; if($myquery) { $this->myquery = $myquery; return $myquery; } return 0; } function selectQuery() { $this->generateSelectQuery(); $this->result = mysql_query($this->myquery); if($this->result) return 1; $this->error = mysql_error(); return 0; } function fetchQuery($limit=0) { $temp = array(); if($this->result) { if(!$limit) { for($i=0;$row = mysql_fetch_assoc($this->result);$i++) { $temp[$i] = $row; } } else if($limit == 1) { $temp = mysql_fetch_assoc($this->result); } else { for($i=0;(($i<$limit)&&($row = mysql_fetch_assoc($this->result)));$i++) { $temp[$i] = $row; } } } return $temp; }
  19. Hi! Good day! I need help in displaying all records on my table that have the same stockin_id as it shows only one record in my query. I used this code to fetch: <tr> <?php if(!empty($stocks)) { $total = 0; foreach($stocks as $stock) { $page->table = "stock_stockin_product"; $page->cond = "stockin_id='".$stock["id"]."'"; $page->selectQuery(); $stockin = $page->fetchQuery(1); ?> <th><?php echo $stockin["id"]; ?></th> <td><?php echo $stock["id"]; ?></td> <td><?php echo date ('d-m-Y H:i', $stock["stock_date"]); ?></td> <td><?php echo $stockin["price"]; ?></td> <td><?php echo $stockin["quantity"]; ?></td> <td>$<?php echo number_format($stockin['quantity'] * $stockin['price'], 2, '.', ','); ?></td> <td><?php echo $stock["branch"]; ?></td> </tr> This is my output and shows only one record for stockin_id=2515. This is the total records from database stockin_id=2515. Thanks in advance for your help and reply. Thanks
×
×
  • 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.