Skip to content

Instantly share code, notes, and snippets.

@Moketronics
Created February 27, 2012 19:16
Show Gist options
  • Save Moketronics/1926422 to your computer and use it in GitHub Desktop.
Save Moketronics/1926422 to your computer and use it in GitHub Desktop.
Full inventory display - in progress, currently for testing
<?php
/* * * * * * * * * * * * * * * * * * *
*
* Tile Product Management System
* Name: full-inventory.php
* Version: DEV
* By: Michael Ramsey (mike@michaelramsey.ca, @moketronics)
*
* Last Updated: March 21, 2012 - Michael Ramsey
*
* * * * * * * * * * * * * * * * * * */
$sPage_title = 'Full Inventory';
include ('./includes/header.html');
require_once('../../../mysql_connect.php');
include ('./includes/functions.php');
$iOrder = $_GET['order'];
$iStart = $_GET['start'];
$iResults = $_GET['results'];
$query = "SELECT ti.tile_id,
ti.tile_name,
ti.tile_price,
ti.quantity,
ti.nom_height,
ti.nom_width,
ti.nom_thick,
mat.material_name,
con.country_name,
man.manufacturer_name,
col.colour_name
FROM tiles AS ti,
material AS mat,
material_associations AS mat_ass,
country AS con,
country_associations AS con_ass,
manufacturer AS man,
manufacturer_associations AS man_ass,
colour AS col,
colour_associations AS col_ass
WHERE ti.tile_id=mat_ass.tile_id AND mat.material_id=mat_ass.material_id
AND ti.tile_id=con_ass.tile_id AND con.country_id=con_ass.country_id
AND ti.tile_id=man_ass.tile_id AND man.manufacturer_id=man_ass.manufacturer_id
AND (ti.tile_id=col_ass.tile_id AND col.colour_id=col_ass.colour_id AND col_ass.b_primary_colour='1')
ORDER BY ";
$query .= order_switch($iOrder, $_SERVER['REQUEST_URI']);
// Set the available options for results per page and create picker form.
$aRes_options = array(10, 25, 50, 100);
$sResults_picker = result_picker($aRes_options, $iResults, $_SERVER['REQUEST_URI'], $iStart, $iOrder);
$query .= paginate($iResults, $iStart, $iOrder, $_SERVER['REQUEST_URI']);
$result = @mysql_query($query);
echo '<div class="center">' . $sResults_picker . '</div>';
?>
<table class="se_results">
<tr>
<th style="width:175px"><?php echo $sTile_name_h; ?></th>
<th style="width:50px"><?php echo $sTile_price_h; ?></th>
<th style="width:60px"><?php echo $sTile_quant_h; ?></th>
<th style="width:70px">Height</th>
<th style="width:70px">Width</th>
<th style="width:50px">Thick:</th>
<th style="width:70px">Material:</th>
<th style="width:50px">Colour:</th>
<th style="width:70px">Manufacturer:</th>
<th style="width:80px">Series:</th>
<th style="width:80px">Country:</th>
</tr>
<?php
if (mysql_num_rows($result) !== 0) {
$bTd_col = FALSE;
while ($row = mysql_fetch_array($result)) {
$iTd_col = ($bTd_col == TRUE) ? 1 : 0;
$bTd_col = ($bTd_col == TRUE) ? FALSE : TRUE;
echo "\t<tr class=\"row_col_" . $iTd_col . "\">\n\t\t<td><a href=\"view-tile.php?tile_id=" . $row['tile_id'] . '">' . stripslashes($row['tile_name']) . "</a></td>\n";
echo "\t\t<td class=\"right_align\">\$" . number_format(($row['tile_price'] / 100), 2) . "</td>\n";
echo "\t\t<td class=\"right_align\">" . $row['quantity'] . "</td>\n";
echo "\t\t<td>" . output_inches($row['nom_height']) . "\"</td>\n";
echo "\t\t<td>" . output_inches($row['nom_width']) . "\"</td>\n";
echo "\t\t<td>" . output_inches($row['nom_thick']) . "\"</td>\n";
echo "\t\t<td>" . $row['material_name'] . "</td>\n";
echo "\t\t<td>" . $row['colour_name'] . "</td>\n";
echo "\t\t<td>" . $row['manufacturer_name'] . "</td>\n";
echo "\t\t<td>" . get_series($row['tile_id']) . "</td>\n";
echo "\t\t<td>" . $row['country_name'] . "</td>\n\t</tr>\n";
}
} else {
echo "\t<tr>\n\t\t<td class=\"center\" colspan=\"11\"><b>No Results!</b></td>";
}
echo '</table>';
if (!empty($sNext_link) && !empty($sPrev_link)) {
echo "\n<p>" . $sPrev_link . '<span class="right_float">' . $sNext_link . '</span></p>';
} else if (!empty($sNext_link) && empty($sPrev_link)) {
echo "\n<p class=\"right_float\">" . $sNext_link . '</p>';
} else if (empty($sNext_link) && !empty($sPrev_link)) {
echo "\n<p>" . $sPrev_link . '</p>';
}
mysql_close(); // Done everything!
include ('./includes/footer.html');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment