Forums / Templates, Stylesheets, Page Layout / New Page Layout Issues

New Page Layout Issues

Locked

Started by games4gamers on 15 Dec 2008, 9:00 PM · Views: 955

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
15 Dec 2008, 9:00 PM
#1
games4gamers avatar

games4gamers

New Zenner

Join Date:
Dec 2008
Posts:
55
Plugin Contributions:
0

New Page Layout Issues

Hi all,

I just recently switched over to Zen Cart from OSC and need some help getting my layout for a custom page correct. This my code so far...I starred out the db bame, user name, and pw for obvious reasons...It collates all the data correctly, but it pushes all the sideboxes and what not to the bottom of the page...

<?php
/*
  $Id: shipping.php,v 1.22 2003/06/05 23:26:23 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/
?>

<html>

<body>
<div class="centerColumn" id="privacy">
<h1 id="privacyDefaultHeading"><?php echo HEADING_TITLE; ?></h1>
<div id="privacyDefaultMainContent" class="content">
		<table align="center" border="0" width="100%" cellspacing="0" cellpadding="2">
          <tr>
            <td class="main"><table align="center" border="2" cellspacing="2" cellpadding="2">
			<tr align="center">
			Click a column header to sort the list.
			<?php 
			// Make sure you setup the links here for the sorting. 
			
			// Name column
			if ($_GET['sort_name'] == 1)
			{
				echo '<td><strong><a href="' . zen_href_link(FILENAME_TRADE_IN_VALUES). '?sort_name=2">Name</a></strong></td>';
			}
			else
			{
				echo '<td><strong><a href="' . zen_href_link(FILENAME_TRADE_IN_VALUES). '?sort_name=1">Name</a></strong></td>';
			}
			
			// Trade-In Value column
			if ($_GET['sort_tradeval'] == 1)
			{
				echo '<td><strong><a href="' . zen_href_link(FILENAME_TRADE_IN_VALUES). '?sort_tradeval=2">Trade-In Value</a></strong></td>';
			}
			else
			{
				echo '<td><strong><a href="' . zen_href_link(FILENAME_TRADE_IN_VALUES). '?sort_tradeval=1">Trade-In Value</a></strong></td>';
			}

			//System/Platform column
		    if ($_GET['sort_system'] == 1)
			{
				echo '<td><strong><a href="' . zen_href_link(FILENAME_TRADE_IN_VALUES). '?sort_system=2">System/Platform</a></strong></td>';
			}
			else
			{
				echo '<td><strong><a href="' . zen_href_link(FILENAME_TRADE_IN_VALUES). '?sort_system=1">System/Platform</a></strong></td>';
			}

			
			// Make a MySQL Connection
mysql_connect("localhost", "****", "******") or die(mysql_error());
mysql_select_db("************") or die(mysql_error());

// Retrieve all the data from the "example" table
//$result = mysql_query("SELECT * FROM zen_products")
//or die(mysql_error());

// store the record of the "example" table into $row
//$row = mysql_fetch_array( $result );
// Print out the contents of the entry

// Retrieve all the data from the "example" table
// Put the SQL Statement in a string variable since we may or may not add to it before we send it to MySQL for execution
$sql_fetch_statement = "SELECT * FROM zen_products INNER JOIN zen_products_description ON zen_products.products_id = zen_products_description.products_id WHERE products_trade_in_value > 0";

// Now we check for each variable we defined in the header section of the table and add to the SQL statement as appropriate
if ($_GET['sort_name'] == 1 || $_GET['sort_name'] == 2)
{
	// 1 means ASC, 2 means DESC
	$sql_fetch_statement = $sql_fetch_statement . " ORDER BY products_name ";
	if ($_GET['sort_name'] == 2)
	{
		$sql_fetch_statement = $sql_fetch_statement . " DESC";
	}
}

if ($_GET['sort_tradeval'] == 1 || $_GET['sort_tradeval'] == 2)
{
	// 1 means ASC, 2 means DESC
	$sql_fetch_statement = $sql_fetch_statement . " ORDER BY products_trade_in_value ";
	if ($_GET['sort_tradeval'] == 2)
	{
		$sql_fetch_statement = $sql_fetch_statement . " DESC";
	}
}

if ($_GET['sort_system'] == 1 || $_GET['sort_system'] == 2)
{
	// 1 means ASC, 2 means DESC
	$sql_fetch_statement = $sql_fetch_statement . " ORDER BY products_system ";
	if ($_GET['sort_system'] == 2)
	{
		$sql_fetch_statement = $sql_fetch_statement . " DESC";
	}
}

// Execute the query
$result = mysql_query($sql_fetch_statement)
or die(mysql_error());

// *** The problem here is you're trying to link information from two tables, but you're not letting the database do that for you
// *** While this could work with some tweaking it is bad practice. What you need to do is come up with a single query that links
// *** these two tables together in a single query.  I'm not sure what your table fields are, so I'm going to just make up some field names.
// *** Lets say that both the products and products_description tables have a field called productid that is used to identify what product
// *** a record in that table is tied to.  In that case, we would write a query like so:
// *** "SELECT * FROM products INNER JOIN products_description ON products.products_id = products_description.product_id"
// *** No you have a single result set where each record contains all the fields from products and all the fields from products_description
// *** and you just loop through that one result set and print out the field values you want.

// store the record of the "example" table into $row
$row = mysql_fetch_array( $result );
// Print out the contents of the entry

// *** What you're actually doing here is every time through the loop you're gettting the next row for $result2, but you're constantly reusing the 1st record from $result
// *** mysql_fetch_array() actually fetches the next record from a result set (which is what's returned from a mysql_query() call)

while ( $row = mysql_fetch_array( $result )) {
	// Start a table row tag
	echo "<tr align='center'>";

	// Now for each column above, echo it out here:
	echo "<td>".$row['products_name']."</td>";
	$number = $row['products_trade_in_value'];
	$formatted = number_format($number, 2);
	echo "<td>"."$" .$formatted."</td>";
	echo "<td>".$row['products_system']."</td>";

	// Close the Table row tag
	echo "</tr>";
}
 ?>

</td></tr></table>
</div></div>
</body>
</html>
<!-- body_text_eof //-->
15 Dec 2008, 10:11 PM
#2
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,732
Plugin Contributions:
0

Re: New Page Layout Issues

The URL where you are trying to use this?

Please do not PM for support issues: a private solution doesn't benefit the community.

Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.

16 Dec 2008, 2:11 PM
#3
games4gamers avatar

games4gamers

New Zenner

Join Date:
Dec 2008
Posts:
55
Plugin Contributions:
0

Re: New Page Layout Issues

Kim:

The URL where you are trying to use this?

It's not live. I'm testing it on my local machine before I push it to my live site. My existing live site is running OSC.

16 Dec 2008, 4:02 PM
#4
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,732
Plugin Contributions:
0

Re: New Page Layout Issues

Without seeing the problem it is almost impossible to diagnose - but, I would try removing the <body> and <html> tags from that file if you are including it in a Zen Cart page.

Please do not PM for support issues: a private solution doesn't benefit the community.

Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.