Jump to content

html forms with PHP


skylab001

Recommended Posts

Hi-

I have this page that has an html form on it used to retrieve selected data from a database. The form has two options and are set to recall orders that have been tagged completed, pending, etc. This variable on the form is called "status",  and then I have a "limit" variable  where the user decides how many returns per page, and one submit button. The "status" variable is passed and works fine.  The only problem I'm having with the page is that I have a "if" statement setup to LIMIT how many returns I get per page, by using the "limit" variable, and it's not working, it always defaults to the default limit of 10.  So I'm curious why my "limit" data isn't passing. I just a beginner and have pieced most of this code together from my friends previous website and some snippets from textbooks. 

 

Here is my page, please be kind as I know it probably isn't perfect but it does work for the most part.

 

<?php
include "../database.php";

if ($Action == "Delete") {
  $query = "update Orders set Deleted = 'Yes' where OrderID = '$OrderID'";
  mysql_query($query, $dbh);

  header("Location: orderscompleted.php");
  exit();
}



if ($limit < 15) $limit = 10;


switch($status) {


case "Pending":
header("Location: orderspending.php");
break;

case "Declined":
header("Location: ordersdeclined.php");
break;

case "Completed":
header("Location: orderscompleted.php");
break;

case "All":
header("Location: ordersall.php");
break;

case "Delivered but Not Yet Charged":
header("Location: ordersdelnocharge.php");
break;

default:
$query = "select OrderID, Date, date_format(Date,'%b %e, %Y - %r') as DisplayDate, FirstName, LastName, EMailAddress,
          AuthorizationStatus, ChargeStatus, OrderStatus, RequestedTotal, RequestedGallons from Orders
          where Deleted = 'No' and OrderStatus = 'Completed' order by Date desc LIMIT $limit";
$order_query = mysql_query($query);
$order_row = mysql_fetch_array($order_query);
break;

}

include "top.php";
include "header.php";

?>

<!------------------------------------  CONTENT AREA ----------------------------------------->	

<table background="cccccc" align="center" cellpadding="5">
		<tr>
			<td ID="Order" align="right" valign="middle">Please choose which orders to display</td>
					<td valign="middle">

				<form action="orders.php" METHOD=POST>
				<select name="status">
				<option value="">Select One</option>
				<option value="Completed">Completed</option>
				<option value="Pending">Pending</option>
				<option value="Declined">Do Not Deliver</option>
				<option value="Delivered but Not Yet Charged">Delivered but Not Yet Charged</option>
				<option value="All">All</option>
				</select>

			</td>
		</tr>



		<tr>
			<td ID="Order" align="right" valign="middle">Number of orders per page<br><font id="smallText">default is 10 or less per page</font></td>
			<td valign="middle">

				<select name="limit">
				<option value="">Select One</option>
				<option value="15">15</option>
				<option value="20">20</option>
				<option value="25">25</option>
				<option value="50">50</option>
				<option value="15000">All</option>
				</select>

			</td>
				</tr>
				<tr>
					<td align="center" colspan="2"><input type=submit name="submit" value="Get Orders">
				</form>
			</td>
		</tr>
	</table>


<BR><BR>


<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" ALIGN="CENTER">


<?php 

echo "

<TR>
			<TD ID='OrderHeader' ALIGN='CENTER'>
    Order History<BR><BR>
  </TD>
		</TR>
<TR>
   <TD ID='Order' Align='center'>
<b>$limit</B> Orders are shown below.  To view order details, simply click on the order number.<BR><BR>
  </td>
				</TR>
<TR>";

$Class = "TABLELIGHT";

while ($order_row) {
  $OrderID = $order_row["OrderID"];
  $Date = $order_row["Date"];
  $DisplayDate = $order_row["DisplayDate"];
  $FirstName = $order_row["FirstName"];
  $LastName = $order_row["LastName"];
  $EMailAddress = $order_row["EMailAddress"];
  $AuthorizationStatus = $order_row["AuthorizationStatus"];
  $ChargeStatus = $order_row["ChargeStatus"];
  $OrderStatus = $order_row["OrderStatus"];
  $RequestedTotal = $order_row["RequestedTotal"];
  $RequestedGallons = $order_row["RequestedGallons"];

  $AuthStatusClass = strtoupper($AuthorizationStatus);
  $ChargeStatusClass = strtoupper($ChargeStatus);

  echo "<TR>\n";
  echo "  <TD CLASS=\"$Class\">\n";
  echo "    <TABLE BORDER=\"0\" CELLPADDING=\"5\" CELLSPACING=\"0\" WIDTH=\"100%\">\n";

  echo "    <TR>\n";
  echo "      <TD WIDTH=\"125\"><B>OrderID:</B></TD>\n";
  echo "      <TD WIDTH=\"150\"><A HREF=\"order.php?OrderID=$OrderID\">$OrderID</A></TD>\n";
  echo "      <TD WIDTH=\"130\"><B>Date:</B></TD>\n";
  echo "      <TD><NOBR>$DisplayDate GMT</NOBR></TD>\n";
  echo "    </TR>\n";

  echo "    <TR>\n";
  echo "      <TD><B>Auth Status:</B></TD>\n";
  echo "      <TD CLASS=\"$AuthStatusClass\"><B>$AuthorizationStatus</B></TD>\n";
  echo "      <TD><B>Order Status:</B></TD>\n";
  echo "      <TD><B>$OrderStatus</B></TD>\n";
  echo "    </TR>\n";

  echo "    <TR>\n";
  echo "      <TD><B>Charge Status:</B></TD>\n";
  echo "      <TD COLSPAN=\"3\" CLASS=\"$ChargeStatusClass\"><B>$ChargeStatus</B></TD>\n";
  echo "    </TR>\n";

  echo "    <TR>\n";
  echo "      <TD><B>Name:</B></TD>\n";
  echo "      <TD>$FirstName $LastName</TD>\n";
  echo "      <TD><B>EMail:</B></TD>\n";
  echo "      <TD><A HREF=\"mailto:$EMailAddress\">$EMailAddress</A></TD>\n";
  echo "    </TR>\n";

  echo "    <TR>\n";
  echo "      <TD><B>Requested Total:</B></TD>\n";
  echo "      <TD>$$RequestedTotal</TD>\n";
  echo "      <TD><B>Requested Gallons:</B></TD>\n";
  echo "      <TD>$RequestedGallons</TD>\n";
  echo "    </TR>\n";

  echo "    <TR>\n";
  echo "      <TD COLSPAN=\"4\" ALIGN=\"CENTER\">\n";
  echo "        <BR><A HREF=\"orderscompleted.php?Action=Delete&OrderID=$OrderID\" OnClick=\"return confirm('Are you sure you want to delete this order?');\"><B>DELETE THIS ORDER</B></A><BR><BR>\n";
  echo "      </TD>\n";
  echo "    </TR>\n";

  echo "    </TABLE>\n";
  echo "  </TD>\n";
  echo "</TR>\n";


  if ($Class == "TABLELIGHT") {
    $Class = "TABLEDARK";
  } else {
    $Class = "TABLELIGHT";
  }

  $order_row = mysql_fetch_array($order_query);
}

?>
<tr>
<TD COLSPAN="4" ALIGN="CENTER">
    
  </TD>
</TR>
<TR>
					<TD ALIGN="CENTER"><a href="index.php"><B><BR><BR>Return to Admin Control Panel</b></a>

</td>
				</tr>

</TABLE>
			<!------------------------------------  CONTENT AREA END ------------------------------------->			


<?php

include "footer.php"

?>	

 

 

Thanks for any help!!

Brian

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.