greybeard
-
Posts
2 -
Joined
-
Last visited
Never
Posts posted by greybeard
-
-
I need to be able to click on the table header an sort ascend or desend, This is the way it works now, (I left off some of the table html)
any ideas?
$query_stuff_in_db = "SELECT * FROM new_stuff ORDER BY some_number1 ASC;";
<TH><b>Column 1</font></b></TH>
<TH><b>Column 2</font></b></TH>
<TH><b>Column 3</font></b></TH>
</TR>
<?php do { ?>
<td> <?php echo $row_stuff_in_db['some_number1'];></td>
<td><?php echo $row_stuff_in_db['some_number2'];></td>
<td><?php echo $row_stuff_in_db['some_number3'];></td>
</tr> <?php } while ($row_stuff_in_db = mysql_fetch_assoc($stuff_in_db)); ?>
PHP Mysql Help
in PHP Coding Help
Posted
about the html) The user has an admin area where he adds products to the database.I do not know
the name of the product that are added. I need to have the data displayed on the web page like
this:
manufacture x
---------------------
Manufacturer x | ID | Title | Year | Price |
---------------------------------------------------------
| x | 3 | RH1 | 2005 | 110 |
| x | 9 | WR7 | 1997 | 120 |
| x | 7 | G69 | 1992 | 150 |
manufacture y
---------------------
Manufacturer y | ID | Title | Year | Price |
---------------------------------------------------------
| y | 2 | YH1 | 2003 | 110 |
| y | 1 | HR7 | 1999 | 120 |
| y | 5 | E69 | 1995 | 150 |
manufacture z
---------------------
Manufacturer z | ID | Title | Year | Price |
---------------------------------------------------------
| z | 4 | LD1 | 2001 | 100 |
| z | 6 | HD7 | 1990 | 120 |
| z | 8 | JR89 | 1980 | 75 |
----------------------------------------------------------------------------
My Database table looks like this:
ID | Manufacturer | TITLE | Year | Price |
1 | y | HR7 | 1999 | 120 |
2 | y | YH1 | 2003 | 110 |
3 | x | RH1 | 2005 | 110 |
4 | Z | LD1 | 2001 | 100 |
5 | y | E69 | 1995 | 150 |
6 | Z | HD7 | 1990 | 120 |
7 | x | G69 | 1992 | 150 |
8 | z | JR89 | 1980 | 75 |
9 | x | WR7 | 1997 | 120 |
---------------------------------------------------------------------------
My PHP looks like this:
<?php
$maxRows_mydata = 100;
$pageNum_mydata = 0;
if (isset($_GET['pageNum_mydata'])) {
$pageNum_mydata = $_GET['pageNum_mydata'];
}
$startRow_mydata = $pageNum_mydata * $maxRows_mydata;
mysql_select_db($db_name, $link);
$query_mydata = "SELECT DISTINCT manufacturer, id, title,year,price,FROM my_product WHERE NOT
(manufacturer IS NULL) ORDER BY manufacturer DESC";
$query_limit_mydata = sprintf("%s LIMIT %d, %d", $query_mydata, $startRow_mydata,
$maxRows_mydata);
$mydata = mysql_query($query_limit_mydata) or die(mysql_error());
$row_mydata = mysql_fetch_assoc($mydata);
if (isset($_GET['totalRows_mydata'])) {
$totalRows_mydata = $_GET['totalRows_mydata'];
} else {
$all_mydata = mysql_query($query_mydata);
$totalRows_mydata = mysql_num_rows($all_mydata);
}
$totalPages_mydata = ceil($totalRows_mydata/$maxRows_mydata)-1;
?>
---------------------------------------
<td valign="middle">
<p class="header1"></p>
<?php echo $row_mydata['manufacturer']; ?></td>
<?php do { ?>
<td align="center" valign="middle" bgcolor="#5080a8" class="Black_copy">Manufacturer</td>
<td align="center" valign="middle" bgcolor="#5080a8" class="Black_copy">ID</td>
<td align="center" valign="middle" bgcolor="#5080a8" class="Black_copy">Title</td>
<td align="center" valign="middle" bgcolor="#5080a8" class="Black_copy"> Year </td>
<td align="center" valign="middle" bgcolor="#5080a8" class="Black_copy">Price </td>
--------------------------------------
<td>
<a href="http://www.mywebsite.com/products/inventory.php?id=<?php echo $row_mydata['id']; ?>"
class="listing">
<?php echo $row_mydata['manufacturer']; ?></td>
<td align="center" class="listing"><?php echo $row_mydata['title']; ?> </a></td>
<td align="center" class="listing"><?php echo $row_mydata['year']; ?></td>
<td align="center" class="listing"><?php echo $row_mydata['hull_type']; ?></td>
<?php } while ($row_mydata = mysql_fetch_assoc($mydata)); ?>
<?php mysql_free_result($mydata);?>
---------------------------------------------------------------
This almost works but it only list the first manufacturer as a title and then list all fo the
records as it loops through the code.
so I only get one header and one table with all of the listings on the web page.
Any insite would be appreciated.
Thanks