Jeneca

Members
  • Content count

    24
  • Joined

  • Last visited

  • Days Won

    1

Jeneca last won the day on February 13 2012

Jeneca had the most liked content!

Community Reputation

1 Neutral

About Jeneca

  • Rank
    Newbie
  • Birthday 06/22/1992

Previous Fields

  • Languages
    PHP, HTML, CSS, MYSQL

Profile Information

  • Gender
    Male
  • Location
    Philippines

Contact Methods

  • Yahoo
    nica_krystal22@yahoo.com
  1. Going to choose by Name, but the output is correct, the problem only is when the selection of all store there are output or data displayed.
  2. But why when I try to choose one store there is a rows that returning..? <?php // db connection $db = "mds_reports"; if($connect = mysql_connect("172.16.8.32", "mds_reports", "password")) $connect = mysql_select_db($db); else die("Unable to connect".mysql_error()); $date_from = $_POST['dfrom']; $date_to = $_POST['dto']; $name = $_POST['name'];?><html> <head> <title>Cancelled Order</title> </head> <body> <h1>Cancelled Order Report</h1> <form name="fetching" method="POST" action="cancelled_orders_index.php"> Date From: <input type="text" name="dfrom" id="dfrom"> Date To: <input type="text" name="dto" id="dto"><br /><br /> Select: <select name="name"> <?php $result = mysql_query("SELECT name FROM restaurant_master"); echo "<option value='0'>ALL</option>"; while($r = mysql_fetch_assoc($result)) { echo "<option value='".$r['name']."'>".$r['name']."</option>"; } echo "</select>"; ?> <input name="submit" type="submit" value="Go"> </form> <table> <table border="2" cellpadding="2" cellspacing="1" style='width:100%;'> <tr> <th>Restaurant Code</th> <th>Restaurant Name</th> <th>Net Price</th> <th>Gross Price</th> <th>Reason</th> <th>Count Reason</th> </tr> <?php if(isset($_POST['submit'])){ echo "Date select from $date_from to $date_to"."</p>"; echo "Restaurant: $name"."</p>"; $sql = "SELECT restaurant_master.code, restaurant_master.name, mds_orders.NetTotal AS 'netprice', mds_orders.GrossTotal AS 'grossprice', ReasonMaster.ReasonDescription AS 'reason', COUNT(ReasonMaster.ReasonDescription) AS 'reacount' FROM mds_orders JOIN ReasonMaster ON mds_orders.ReasonFKID = ReasonMaster.PKID JOIN restaurant_master ON mds_orders.RestaurantID = restaurant_master.pkid WHERE mds_orders.OrderDate BETWEEN '".$date_from." 00:00:00' AND '".$date_to." 23:59:59' AND restaurant_master.name = '$name' AND mds_orders.StatusFKID = 3"; if($_POST['pkid']) $sql.=" AND pkid={$_POST['pkid']}"; $sql.=" GROUP BY ReasonMaster.ReasonDescription"; $result = mysql_query($sql) or die("Error: ".mysql_error()); $num_rows = mysql_num_rows($result); $i = 0; if (mysql_num_rows($result) >0) { while ($row = mysql_fetch_array($result,MYSQL_ASSOC)){ $csv .= $row['code'].",". $row['name'].",". $row['netprice'].",". $row['grossprice'].",". $row['reason'].",". $row['reacount'].","."<br>"; ?> <tr> <td><?php echo $row['code'];?></td> <td><?php echo $row['name'];?></td> <td><?php echo $row['netprice'];?></td> <td><?php echo $row['grossprice'];?></td> <td><?php echo $row['reason'];?></td> <td><?php echo $row['reacount'];?></td> </tr> </tr> </tr> <?php }}} ?> I thought that $name comes from the variable for the restaurant_master.name, is it right..?or no need to do this..?
  3. SELECT restaurant_master.code, restaurant_master.name, mds_orders.NetTotal AS 'netprice', mds_orders.GrossTotal AS 'grossprice', ReasonMaster.ReasonDescription AS 'reason', COUNT(ReasonMaster.ReasonDescription) AS 'reacount' FROM mds_orders JOIN ReasonMaster ON mds_orders.ReasonFKID = ReasonMaster.PKID JOIN restaurant_master ON mds_orders.RestaurantID = restaurant_master.pkid WHERE mds_orders.OrderDate BETWEEN '2012-01-01 00:00:00' AND '2012-01-31 23:59:59' AND restaurant_master.name = '0' AND mds_orders.StatusFKID = 3 GROUP BY ReasonMaster.ReasonDescription this is the echo prints after I choose all.
  4. Nothing, only the selected date like.. Other than that there are no restaurant name and data displayed.
  5. Thank you Birbal! it already works.. but when I try to select all there are no data displayed..?
  6. Don E not that info, when someone selects a restaurant name from the drop down list it display the data for that particular restaurant, and data will come from the database. Any ways already done with that, my problem now is what if I select "ALL" restaurant..? IThis is my updated code <html> <head> <title>Cancelled Order</title> </head> <body> <h1>Cancelled Order Report</h1> <form name="fetching" method="POST" action="cancelled_orders_index.php"> Date From: <input type="text" name="dfrom" id="dfrom"> Date To: <input type="text" name="dto" id="dto"><br /><br /> Select: <select name="pkid"> <?php echo "<option value='0'>ALL</option>"; $result = mysql_query("SELECT name,pkid FROM restaurant_master"); while($r = mysql_fetch_assoc($result)) { echo "<option value='{$r['pkid']} '>{$r['name']}</option>"; } echo "</select>"; ?> <input name="submit" type="submit" value="Go"> </form> <table> <table border="2" cellpadding="2" cellspacing="1" style='width:100%;'> <tr> <th>Restaurant Code</th> <th>Restaurant Name</th> <th>Order No.</th> <th>Order Source</th> <th>Payment Type</th> <th>Net Price</th> <th>Gross Price</th> <th>Reason</th> <th>Count Reason</th> </tr> <?php if(isset($_POST['submit'])){ echo "Date select from $date_from to $date_to"."</p>"; echo "Restaurant: $name"."</p>"; $sql = "SELECT restaurant_master.code, restaurant_master.name, mds_orders.OrderNo, mds_orders.OrderSourceText AS 'ordersource', mds_orders.PaymentTypeText AS 'paymenttype', mds_orders.NetTotal AS 'netprice', mds_orders.GrossTotal AS 'grossprice', ReasonMaster.ReasonDescription AS 'reason', COUNT(ReasonMaster.ReasonDescription) AS 'reacount' FROM mds_orders JOIN ReasonMaster ON mds_orders.ReasonFKID = ReasonMaster.PKID JOIN restaurant_master ON mds_orders.RestaurantID = restaurant_master.pkid WHERE mds_orders.OrderDate BETWEEN '".$date_from." 00:00:00' AND '".$date_to." 23:59:59' AND restaurant_master.name = '$name' AND mds_orders.StatusFKID = 3 GROUP BY restaurant_master.code, restaurant_master.name, mds_orders.OrderNo, mds_orders.OrderSourceText, mds_orders.PaymentTypeText, ReasonMaster.ReasonDescription, mds_orders.NetTotal, mds_orders.GrossTotal"; if($_POST['pkid']) $sql.=" WHERE pkid={$_POST['pkid']}"; $result = mysql_query($sql) or die("Error: ".mysql_error()); $num_rows = mysql_num_rows($result);
  7. This query already works, but when I try to select all, there is no data displayed <?php $result = mysql_query("SELECT name FROM restaurant_master"); echo "<select name='name'>"; echo "<option value='0'>ALL</option>"; while($r = mysql_fetch_array($result)) { echo "<option value='".$r['name']."'>".$r['name']."</option>"; } echo "</select>"; ?>
  8. How can I add in the drop list the "ALL", that when I choose to select all store names..?
  9. @Don E and @ birbal thank you for your response. I already shows the store names in the drop down list, my problem now is how can I get their value..? Ex: If I Choose Greenhills, only the record of Greenhills should be displayed.
  10. how can I get their value..?Example:I Choose Greenhills, only Greenhills should be displayed.
  11. What I'm trying to display is the list of store names in a drop down list, but their restaurantID should be called/select..?What should I do..?
  12. I also try that, but I know why but still there are no store names in the drop down list. :|
  13. I already put my database connection at the top. <?php // db connection $db = "mds_reports"; if($connect = mysql_connect("172.16.8.32", "mds_reports", "password")) $connect = mysql_select_db($db); else die("Unable to connect".mysql_error()); $date_from = $_POST['dfrom']; $date_to = $_POST['dto']; $name = $_POST['name'];?><html> <head> <title>Cancelled Order</title> </head> <body> <h1>Cancelled Order Report</h1> <form name="fetching" method="POST" action="cancelled_orders_index.php"> Date From: <input type="text" name="dfrom" id="dfrom"> Date To: <input type="text" name="dto" id="dto"><br /><br /> Select: <select name="name"> <?php $result = mysql_query("SELECT RestaurantID FROM mds_orders"); while($row = mysqli_fetch_assoc($result)) { $id = $row['id']; echo '<option value=" ' . $id . ' ">' . $id . '</option>'; } ?> </select> <input name="submit" type="submit" value="Go"> </form> <table> <table border="2" cellpadding="2" cellspacing="1" style='width:100%;'> <tr> <th>Restaurant Code</th> <th>Restaurant Name</th> <th>Order No.</th> <th>Order Source</th> <th>Payment Type</th> <th>Net Price</th> <th>Gross Price</th> <th>Reason</th> </tr> <?php if(isset($_POST['submit'])){ echo "Date select from $date_from to $date_to"."</p>"; echo "Restaurant: $name"."</p>"; $sql = "SELECT restaurant_master.code, restaurant_master.name, mds_orders.OrderNo, mds_orders.OrderSourceText AS 'ordersource', mds_orders.PaymentTypeText AS 'paymenttype', mds_orders.NetTotal AS 'netprice', mds_orders.GrossTotal AS 'grossprice', COUNT(ReasonMaster.ReasonDescription) AS 'reason' FROM mds_orders JOIN ReasonMaster ON mds_orders.ReasonFKID = ReasonMaster.PKID JOIN restaurant_master ON mds_orders.RestaurantID = restaurant_master.pkid WHERE mds_orders.OrderDate BETWEEN '".$date_from." 00:00:00' AND '".$date_to." 23:59:59' AND restaurant_master.name = '$name' AND mds_orders.StatusFKID = 3 GROUP BY restaurant_master.code, restaurant_master.name, mds_orders.OrderNo, mds_orders.OrderSourceText, mds_orders.PaymentTypeText, ReasonMaster.ReasonDescription, mds_orders.NetTotal, mds_orders.GrossTotal"; $result = mysql_query($sql) or die("Error: ".mysql_error()); $num_rows = mysql_num_rows($result); $i = 0; if (mysql_num_rows($result) >0) { while ($row = mysql_fetch_array($result,MYSQL_ASSOC)){ $csv .= $row['code'].",". $row['name'].",". $row['OrderNo'].",". $row['ordersource'].",". $row['paymenttype'].",". $row['netprice'].",". $row['grossprice'].",". $row['reason'].","."<br>"; ?> <tr> <td><?php echo $row['code'];?></td> <td><?php echo $row['name'];?></td> <td><?php echo $row['OrderNo'];?></td> <td><?php echo $row['ordersource'];?></td> <td><?php echo $row['paymenttype'];?></td> <td><?php echo $row['netprice'];?></td> <td><?php echo $row['grossprice'];?></td> <td><?php echo $row['reason'];?></td> </tr> </tr> </tr> <?php }}} ?> And also change from this like what you've said awhile ago. $result = mysql_query("SELECT RestaurantID FROM mds_orders"); But nothing's change.
  14. This is what I've done..Is that correct..? <html> <head> <title>Cancelled Order</title> </head> <body> <h1>Cancelled Order Report</h1> <form name="fetching" method="POST" action="cancelled_orders_index.php"> Date From: <input type="text" name="dfrom" id="dfrom"> Date To: <input type="text" name="dto" id="dto"><br /><br /> Select: <select name="name"><?php $result = $dbc->query("SELECT RestaurantID FROM mds_orders"); while($row = mysqli_fetch_assoc($result)) { $id = $row['id']; echo '<option value=" ' . $id . ' ">' . $id . '</option>'; }?> </select> <input name="submit" type="submit" value="Go"> </form> <table> <table border="2" cellpadding="2" cellspacing="1" style='width:100%;'> <tr> <th>Restaurant Code</th> <th>Restaurant Name</th> <th>Order No.</th> <th>Order Source</th> <th>Payment Type</th> <th>Net Price</th> <th>Gross Price</th> <th>Reason</th> </tr> But still there are no names in a drop down.