Jump to content

funbinod

Members
  • Posts

    501
  • Joined

  • Last visited

Everything posted by funbinod

  1. single = is also not working. if (!isset($_POST['sort'])) {$query = "SELECT * FROM tran WHERE ssn!=0 ORDER BY date";} else {$fdate = $_REQUEST['fdate'];$tdate = $_REQUEST['tdate'];$query = "SELECT * FROM tran WHERE ssn!=0 AND date BETWEEN '$fdate' AND '$tdate' ORDER BY date";} it returns the query on if statement. but even after selecting the date it is the query from if statement (or simply the if, else statement is not working)..
  2. yes! it is redirecting. it is redirecting to the root of webpage. like: the $refer page is "http://localhost/ac/chapat/salesReport.php?" and it is redirecting to "http://localhost/ac/chapat" i just want to include the referer page.... -------------------------- EDIT: but this is working: die(header("location: $refer")); but i need some messege to display with the redirection to the referer page. like after redirection, at the top of the page it should echo "Record posted successfully" and then include the referer page.... using die(header(..........)) doesn't display the messege but only the referer page......
  3. i tried to get back to referer page after editing records but it redirected to login page. // this is editprocess page...$refer = $_REQUEST['refer']; // this is stored on a hidden input field on edit.php, that is redirected from http://....../salesRecord.php?echo "<h3>Sales Record Successfully Updated</h3>";include($refer); //echo ing $refer here gives the desired referer page...after clicking 'edit' (submit button) it redirects to login.php page. even the login page should redirect to 'main.php' since it is logged in already (there is a code for it at the top of the page) ....   any suggestion????
  4. this means single = (or something else) would work?
  5. i'm trying to get make query relating to the date selection. and if no date is selected, i want to make default query without date selection. for this i tried this ---- // above this there is a form with two input fields for from date and to date selection with a submit buttom. action is $_SERVER['PHP_SELF']if (!isset($_POST['sort'])) { // 'sort' is the submit button name$query = "SELECT * FROM tran WHERE ssn!=0 ORDER BY date";} else { $fdate == $_POST['fdate']; // from date $tdate == $_POST['tdate']; // to date$query = "SELECT * FROM tran WHERE ssn!=0 AND date BETWEEN '$fdate' AND '$tdate' ORDER BY date";} but this is not working... any suggestion!!!?????
  6. thanks. but its not still selecting aid 1 & 2....
  7. i wonder for same. file name is perfect. no error. let me explain u the error that is happening... i added the above line to 'login.php'. after adding the lines, 'login.php' fails to load and gives the error msg. removing the lines, 'login.php' opens correctly. if it was only the case of wrong file name 'chkactivation.php', it should al least redirect to the file and not open. but its not redirecting to the <header("location: chkactivation.php")>.
  8. u r right but one--- i want all columns for all 'aid's but for 'aid' 1 & 2 i don't want 'sales' & 'purchase'. and 'sales' & 'purchase' are not column name. they are row value for 'tr_type' column & this column has other values also - 'receipt', 'payment' etc.... lets assume with this |---|------------|--------|---------||aid| date | amt | tr_type ||---|------------|--------|---------|| 1 | 2014-05-01 | 50000 | SALES || 2 | 2014-05-02 | 50000 |PURCHASE ||---|------------|--------|---------|| 1 | 2014-05-03 | 50000 | RECEIPT || 2 | 2014-05-04 | 50000 | PAYMENT || 3 | 2014-05-05 | 50000 | SALES || 3 | 2014-05-06 | 50000 |PURCHASE ||---|------------|--------|---------| in this table i dont want first 2 rows only.
  9. never mind. no 404. gives only the message.
  10. i'm trying to select columns with multiple conditions. i want to select all 'tr_type' for all 'aid's but not 'SALES' & 'PURCHASE' for aid in '1' & '2'. i tried --- SELECT * FROM tran WHERE aid NOT IN ('1','2') AND tr_type IN ('SALES','PURCHASE') ORDER BY date it didn't work. please suggest....
  11. but this is working if (!$connect) { die(header("location: install.php?"));}else { die(header("location: login.php?"));}
  12. i'm trying to check before going to login page it should be checked if it is activated or not. if someone tries to access 'login.php' directly, it should be forwarded to 'chkactivation.php'. for this i tried-- // login.php$ref = $_SERVER['HTTP_REFERER'];if ($ref != 'http://localhost/ac/chapat/chkactivation.php') { die(header("location: chkactivation.php"));} but it says "This page can't be displayed" as if it didn't find the page (login.php) in spite of redirecting to 'chkactivation,php'. where m i wrong? please guide.. or suggest some better idea...
  13. i came to learn that future and past dates are calculated with the simple use of "strtotime()". but this is calculated in relating with current date. i want to know if a future date can be calculated in relation with database stored date? for example, if '2014-01-01' is stored in database, how can i get the date of 30 days(i.e.-2014-01-30) ahead from this date?
  14. this function is only for 'sid=1'. i mean for single 'sid'. and is working properly. but i asked for help to derive values for all 'sid's. i mean to ask u 'how to use this function more than once'.
  15. funbinod

    else if ( if (

    how can i put another if statement inside else if statement.......
  16. @justsomeguy refers to change this to $numrows = mysqli_num_rows($query); if($numrows <= 0) //or use just '=' coz there couldn't be, perhaps, negative number of messege
  17. how can i loop a result from a php function to loop through each 'id'? like for all 'sid's, i want to use following function to get data... /* above this i calculate value for each $cqty */$cqty = $oqty + $inqty - $outqty;$camt = "select date, pqty, prate, pamt from stock stjoin purchase p on st.sid = p.sid where st.sid = $sidunion allselect date, -sqty, srate, samt from stock stjoin sales s on st.sid = s.sid where st.sid = $sidunion allselect null, oqty, oprice, oamt from stock where sid = $sidorder by date asc";$dataSet = array();$camtresult = mysqli_query($connect, $camt);while ($row = mysqli_fetch_array($camtresult)){ $dataSet[] = $row;}function camt($dataSet, $cqty){ $totalPurchaseValue = 0; $totalPurchaseQty = 0; $done = false; foreach($dataSet as $row) { // skip sales rows if ($row['pqty'] < 0) { continue; } for ($i=0; $i<$row['pqty']; $i++ ) { $totalPurchaseQty++; $totalPurchaseValue += $row['prate']; if ($totalPurchaseQty == $cqty) { return $totalPurchaseValue; } } } return $totalPurchaseValue;}// Determine the $countOfGoodsForSale$crate = camt($dataSet, $cqty) / $cqty;$camt = $cqty*$crate; i tried while loop but it said--- please guide through
  18. is it like --> $array = array(1,2,3,4,5);$sum = array_sum($array);echo $sum; // 15
  19. i want to know how to sum the numbers returned from a php query of mysql data. please guide through...
  20. thank u @justsomeguy! but i know nothing about stored procedure. can u please tell me where can i read this with step by step explanation!?
  21. i am trying to command mysql to sum until it reaches certain value from my table 'purchase', for each 'sid' starting from the last row, i need sum of 'pqty' until the result equals a value from string (but to try i've given a certain value). let me define with the rows from my table--- the rows for 'sid=1' from 'purchase' are like this--- from this row, starting from the last row i want to 'sum(pqty) until it reaches 19(for now). it is achieved from adding last 2 rows(for 19). and stop sum here and return valus or sum of 'pqty', 'prate' and 'pamt'. to achieve this i tried the following SELECT date, pqty, @total := @total + pqty AS total FROM (purchase, (select @total :=0) t) WHERE @total<19 AND sid = $sid ORDER BY date DESC but it's not working. please guide me through this. also suggest something else if this is not the good technique for my purpose. thankz in advance.....
  22. yes @davej! but from which path, in php, i can reach to that calculation!? question is this! and @justsomeguy! its still not opening for me
  23. thanks for the reply. its ok for the spelling! but the problem is still the same. its not retrieving sum from last 3 rows. its summing from complete rows.... i wish to add qty from the declared LIMIT...
  24. i'm not calculating SHARE STOCK. i'm calculating INVENTORY STOCK. and i know the definition and manual procedure of FIFO. i'm trying to find the solution for this on php...
  25. thanks both of u. i think every account method to be applied in php we need certain data structure also, isn't it @davej? or i might be wrong! and @justsomeguy! the link is dead. its not opening.
×
×
  • Create New...