Jump to content

[SOLVED] Admin Page...Please Help with Code!!!!


mikebyrne

Recommended Posts

Im trying to get all my completed orders to appear in a table on my .php page.

 

I'll need an If statement something like

 

If (Ordercompleted == 1) show OrderNo, Orderdate, Dispatchdate, Custname, Trackno,  Amount, Shippingmet in a table

 

My php page looks like this

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>e-commerce admin page sample | order</title>
<link href="../Admin_files/admin.css" rel="stylesheet" type="text/css" />
<script type="text/JavaScript" src="../Admin_files/wrapper.js"></script>
</head>
<body>
<div id="Box">

<div id="logoBox"><a href="http://www.btrax.com/" target="_blank"><img src="../Admin_files/logo.gif" width="51" height="125" border="0" /></a></div>
<div id="contentBox">
<form>


<!-- logo start -->
<div id="container">
	<div class="padTop28"><!-- --></div>
	<div class="clr"><!-- --></div>
</div>
<div class="clr"><!-- --></div>

<!-- logo finish -->



<!-- menu start -->
<div id="container">
			<div id="menu1">
		<div id="menu_on"><!-- --></div>
		<div id="menu_text_on"><a href="../order/new.php" class="black_on">Order</a></div>

		<div id="menu_space1"><!-- --></div>
		<div id="menu_off"><!-- --></div>
		<div id="menu_text_off"><a href="../sales/sales.php" class="black">Sales</a></div>
		<div id="menu_space1"><!-- --></div>

		<div id="menu_off"><!-- --></div>
		<div id="menu_text_off"><a href="../item/list.php" class="black">Edit item</a></div>
		<div id="menu_space1"><!-- --></div>
		<div id="menu_off"><!-- --></div>

		<div id="menu_text_off"><a href="../shipping/current.php" class="black">Postage fee</a></div>
		<div id="menu_space1"><!-- --></div>
	</div>

	<div class="clr"><!-- --></div>		<div class="clr"><!-- --></div>
	<div class="padTop5"><!-- --></div>
	<div class="clr"><!-- --></div>
	<div id="dotted"><!-- --></div>
	<div class="clr"><!-- --></div>
	<div class="padTop5"><!-- --></div>
	<div class="clr"><!-- --></div>
	<div id="menu2">

		<div id="menu_hide"><!-- --></div>
		<div id="menu_text_off"><a href="new.php" class="black">New orders</a></div>
		<div id="menu_space2"><!-- --></div>
		<div id="menu_text_off"><a href="Unprocessed.php" class="black">Unprocessed orders</a></div>
		<div id="menu_space2"><!-- --></div>
		<div id="menu_text_on"><a href="completed.php" class="black_on">Completed orders</a></div>
		<div class="clr"><!-- --></div>

	</div>
	<div class="clr"><!-- --></div>
	<div class="padTop38"><!-- --></div>
	<div class="clr"><!-- --></div>
</div>
<div class="clr"><!-- --></div>
<!-- menu finish -->



<!-- top start -->
<div id="container">

	<div id="line"><!-- --></div>
</div>
<div class="clr"><!-- --></div>
<div id="containerBg1">
	<div class="padTop15"><!-- --></div>
	<div class="clr"><!-- --></div>
</div>
<div class="clr"><!-- --></div>
<!-- top finish -->




<!-- data title start -->
<div id="containerBg2">
	<div class="padTop2"><!-- --></div>
	<div class="clr"><!-- --></div>
	<div class="titleBox">
		<table width="850" border="0" cellspacing="0" cellpadding="0">
			<tr align="left">
				<td width="33"> </td>
				<td width="82"><a href="#">order no.</a></td>

				<td width="61"><a href="#">order date</a></td>
				<td width="61"><a href="#">ship date</a></td>
				<td width="230"><a href="#">customer name</a></td>
				<td width="170"><a href="#">tracking no.</a></td>
				<td width="56" align="right"><a href="#">amount</a></td>
				<td width="21"> </td>

				<td width="136"><a href="#">shipping method</a></td>
		  </tr>
	  </table>
	</div>
	<div class="clr"><!-- --></div>
</div>
<div class="clr"><!-- --></div>
<!-- data title finish -->




<!-- 1px space start -->
<div id="containerBg1">
	<div class="padTop1"><!-- --></div>
	<div class="clr"><!-- --></div>
</div>
<div class="clr"><!-- --></div>
<!-- 1px space finish -->



<!-- data top start -->
<div id="containerBg3">

	<div class="padTop1"><!-- --></div>
	<div class="clr"><!-- --></div>
</div>
<div class="clr"><!-- --></div>
<!-- data top finish -->



<!-- data content start -->
<div id="containerBg4">


	<!-- btn start -->
	<div class="clr"><!-- --></div>

	<div class="padTop100"><!-- --></div>
	<div class="clr"><!-- --></div>
	<div id="btn_text">
		 <a href="#"><< previous</a>
		       
		 <a href="#">1</a>
		    

		 <span class="textBlackB">2</span>
		    
		 <a href="#">3</a>
		       
		 <a href="#">next>></a> </div>
	<div class="clr"><!-- --></div>
	<div class="padTop16"><!-- --></div>

	<div class="clr"><!-- --></div>
	<!-- btn finish -->

</div>
<div class="clr"><!-- --></div>
<!-- data content finish -->



<!-- data btm start -->
<div id="containerBg3">
	<div class="padTop1"><!-- --></div>
	<div class="clr"><!-- --></div>

</div>
<div class="clr"><!-- --></div>
<!-- data btm finish -->



<!-- btm start -->
<div id="containerBg1">
	<div class="padTop15"><!-- --></div>
	<div class="clr"><!-- --></div>
</div>
<div class="clr"><!-- --></div>

<div id="container">
	<div id="line"><!-- --></div>
</div>
<div class="clr"><!-- --></div>
<div class="padTop16"><!-- --></div>
<div class="clr"><!-- --></div>
<!-- btm finish -->

</form>
</div>

</div>
</body>
</html>

 

The table within the code looks like this

 

<!-- data title start -->
<div id="containerBg2">
	<div class="padTop2"><!-- --></div>
	<div class="clr"><!-- --></div>
	<div class="titleBox">
		<table width="850" border="0" cellspacing="0" cellpadding="0">
			<tr align="left">
				<td width="33"> </td>
				<td width="82"><a href="#">order no.</a></td>

				<td width="61"><a href="#">order date</a></td>
				<td width="61"><a href="#">ship date</a></td>
				<td width="230"><a href="#">customer name</a></td>
				<td width="170"><a href="#">tracking no.</a></td>
				<td width="56" align="right"><a href="#">amount</a></td>
				<td width="21"> </td>

				<td width="136"><a href="#">shipping method</a></td>
		  </tr>
	  </table>
	</div>
	<div class="clr"><!-- --></div>
</div>
<div class="clr"><!-- --></div>
<!-- data title finish -->

 

There is also a file that connects to the database called adminconnect.php so i guess that will also have to be placed within the code.

 

Any help would be great!!

Link to comment
Share on other sites

I didn't read your code, but from your question

 

If (Ordercompleted == 1) show OrderNo, Orderdate, Dispatchdate, Custname, Trackno,  Amount, Shippingmet in a table

 

you want to do something like

 

SELECT * FROM table WHERE Ordercompleted = 1;

Link to comment
Share on other sites

So in my case it would be

 

SELECT OrderNo, Orderdate, Dispatchdate, Custname, Trackno,  Amount, Shippingmet FROM admin WHERE Ordercompleted = 1;        ????

 

Where would I place that within my code to form the table? (the table code is the 2nd code box, to make life a bit easier!!)

Link to comment
Share on other sites

If you SELECT * then it grabs all the fields, unless you want to specify each one for whatever reason.

 

You forgot the FROM statement, where you have to state what table you are selecting from.

 

Once you get that, use an associate array to fetch it, then just echo the $row['OrderNo']..etc.

Link to comment
Share on other sites

I'm going to run a test to get the figures from the db. Would this work??

 

<?php

include('adminconnect');


// table name
$tbl_name= "admin";

$sql= SELECT OrderNo, Orderdate, Dispatchdate, Custname, Trackno,  Amount, Shippingmet FROM admin WHERE Ordercompleted = 1;

// values sent from database
$OrderNo=$_POST['OrderNo'];
$Orderdate=$_POST['Orderdate'];
$Custname=$_POST['Custname'];
$Dispatchdate=$_POST['Dispatchdate'];
$Trackno=$_POST['Trackno'];
$Amount=$_POST['Amount'];
$Shippingmet=$_POST['Shippingmet'];
$Ordercompleted=$_POST['Ordercompleted'];


$OrderNo = mysql_real_escape_string ($_POST['OrderNo']);
$Orderdate = mysql_real_escape_string ($_POST['Orderdate']);
$Custname = mysql_real_escape_string ($_POST['Custname']);
$Trackno = mysql_real_escape_string ($_POST['Trackno']);
$Amount = mysql_real_escape_string ($_POST['Amount']);
$Shippingmet = mysql_real_escape_string ($_POST['Shippingmet']);
$Ordercompleted = mysql_real_escape_string ($_POST['Ordercompleted']);

Echo $OrderNo['OrderNo'] ;
Echo $Orderdate['Orderdate'] ;


}

 

 

Link to comment
Share on other sites

<?php

$sql = mysql_query("SELECT OrderNo, Orderdate, Dispatchdate, Custname, Trackno,  Amount, Shippingmet FROM admin WHERE Ordercompleted = 1");

while( $row = mysql_fetch_array($sql) )
{

echo "<table>";
echo "<tr>";
echo "<td>" . $row['OrderNo'] . "</td>";
echo "</tr>";
echo "</table>";


}


?>

 

you can take it from here.  ;)

 

Regards ACE

Link to comment
Share on other sites

Great got a test page working!! Now to add it to my template page

 

I have the figures typed out and styled already. Is it just a matter of replacing the figures with the varible name?

 

<!-- data start -->
	<div class="padTop11"><!-- --></div>

	<div class="clr"><!-- --></div>
	<div class="padTop1">
		<table width="850" border="0" cellspacing="0" cellpadding="0">
			<tr align="left">
				<td width="33"> </td>
				<td width="82"><a href="javascript:openWindow('popup_detail.html', 'NewWindow', 615, 600)" class="black">1231488425</a></td>
				<td width="61">05/20/06</td>
				<td width="61">05/20/06</td>

				<td width="230">Hanae Kaorida </td>
				<td width="170">US POSTAL 3103855588</td>
				<td width="56" align="right">$107.00</td>
				<td width="21"> </td>
				<td width="136">Ground</td>
			</tr>
		</table>

	</div>
	<div class="clr"><!-- --></div>
	<div class="padTop11"><!-- --></div>
	<div class="clr"><!-- --></div>
	<div id="dottedIn"><!-- --></div>
	<div class="clr"><!-- --></div>
	<!-- data finish -->

 

Would, for example Hanae Kaorida become . $row['Custname'] .    ?????

 

 

Also where do I place the new php code in my already written template??

Link to comment
Share on other sites

my test code is now:

 

<?php

include('adminconnect.php');

$sql = mysql_query("SELECT OrderNo, Orderdate, Dispatchdate, Custname, Trackno,  Amount, Shippingmet FROM admin WHERE Ordercompleted = 1");

while( $row = mysql_fetch_array($sql) )
{

echo "<table>";
echo "<tr>";
echo "<td>" . $row['OrderNo'] . "</td>";
echo "<td>" . $row['Custname'] . "</td>";
echo "</tr>";
echo "</table>";


}


?>

<!-- data start -->
	<div class="padTop11"><!-- --></div>

	<div class="clr"><!-- --></div>
	<div class="padTop1">
		<table width="850" border="0" cellspacing="0" cellpadding="0">
			<tr align="left">
				<td width="33"> </td>
				<td width="82"><a href="javascript:openWindow('popup_detail.html', 'NewWindow', 615, 600)" class="black">1231488425</a></td>
				<td width="61">05/20/06</td>
				<td width="61">05/20/06</td>

				<td width="230">. $row['OrderNo'] .</td>
				<td width="170">. $row['TrackNo'] .</td>
				<td width="56" align="right">. $row['Amount'] .</td>
				<td width="21"> </td>
				<td width="136">test</td>
			</tr>
		</table>

	</div>
	<div class="clr"><!-- --></div>
	<div class="padTop11"><!-- --></div>
	<div class="clr"><!-- --></div>
	<div id="dottedIn"><!-- --></div>
	<div class="clr"><!-- --></div>
	<!-- data finish -->

 

My results are:

 

34556 rob

  1231488425 05/20/06 05/20/06 . $row['OrderNo'] . . $row['TrackNo'] . . $row['Amount'] .   test

 

 

 

. $row['OrderNo'] . . $row['TrackNo'] . . $row['Amount'] .  are not showing there contents, how do I change this?

Link to comment
Share on other sites

my test code is now:

 

<?php

include('adminconnect.php');

$sql = mysql_query("SELECT OrderNo, Orderdate, Dispatchdate, Custname, Trackno,  Amount, Shippingmet FROM admin WHERE Ordercompleted = 1");

while( $row = mysql_fetch_array($sql) )
{

echo "<table>";
echo "<tr>";
echo "<td>" . $row['OrderNo'] . "</td>";
echo "<td>" . $row['Custname'] . "</td>";
echo "</tr>";
echo "</table>";


}


?>

<!-- data start -->
	<div class="padTop11"><!-- --></div>

	<div class="clr"><!-- --></div>
	<div class="padTop1">
		<table width="850" border="0" cellspacing="0" cellpadding="0">
			<tr align="left">
				<td width="33"> </td>
				<td width="82"><a href="javascript:openWindow('popup_detail.html', 'NewWindow', 615, 600)" class="black">1231488425</a></td>
				<td width="61">05/20/06</td>
				<td width="61">05/20/06</td>

				<td width="230">. $row['OrderNo'] .</td>
				<td width="170">. $row['TrackNo'] .</td>
				<td width="56" align="right">. $row['Amount'] .</td>
				<td width="21"> </td>
				<td width="136">test</td>
			</tr>
		</table>

	</div>
	<div class="clr"><!-- --></div>
	<div class="padTop11"><!-- --></div>
	<div class="clr"><!-- --></div>
	<div id="dottedIn"><!-- --></div>
	<div class="clr"><!-- --></div>
	<!-- data finish -->

 

My results are:

 

34556 rob

  1231488425 05/20/06 05/20/06 . $row['OrderNo'] . . $row['TrackNo'] . . $row['Amount'] .   test

 

 

 

. $row['OrderNo'] . . $row['TrackNo'] . . $row['Amount'] .  are not showing there contents, how do I change this?

 

Try this:

 

echo "<td>.$row["OrderNo"].</td>"

Link to comment
Share on other sites

See this line -

 

<td width="230">. $row['OrderNo'] .</td>

 

Since it's all html, it NOT going to print the value of your variable.

 

What you want is:

 

<td width="230"><?php echo $row['OrderNo'];?></td>

 

Make similar adjustments to other lines as needed.

Link to comment
Share on other sites

<td width="230"><?php echo $row['OrderNo'];?></td>

 

Is just blank but the code:

 

echo "<table>";
echo "<tr>";
echo "<td>" . $row['OrderNo'] . "</td>";
echo "<td>" . $row['Custname'] . "</td>";
echo "</tr>";
echo "</table>";

 

Prints the value of OrderNo so I cant figure out why it doesnt work in the html??????

Link to comment
Share on other sites

I suspect that what you really want to do is (something) like this.  Execute query; while results display them.

 

<!-- data start -->
<div class="padTop11"><!-- --></div>
<div class="clr"><!-- --></div>
<div class="padTop1">
<table width="850" border="0" cellspacing="0" cellpadding="0">
<?php
// let's get some data
include('adminconnect.php');
$sql = mysql_query("SELECT OrderNo, Orderdate, Dispatchdate, Custname, Trackno,  Amount, Shippingmet FROM admin WHERE Ordercompleted = 1");
while( $row = mysql_fetch_array($sql) ) {
// loop through and display
?>
<tr align="left">
<td width="33"> </td>
<td width="82"><a href="javascript:openWindow('popup_detail.html', 'NewWindow', 615, 600)" class="black"><?php echo $row['OrderNo'];?></a></td>
<td width="61"><?php echo $row['Orderdate'];?></td>
<td width="61"><?php echo $row['Dispatchdate'];?></td>
<td width="230"><?php echo $row['Custname'];?></td>
<td width="170"><?php echo $row['Trackno'];?></td>
<td width="56" align="right"><?php echo $row['Amount'];?></td>
<td width="21"> </td>
<td width="136">test</td>
</tr>

<?
}
?>
</table>

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.