Subject: Need Help Master Detail page
Posted By: ollie281 Post Date: 8/7/2006 12:35:06 PM
Need help with php mysql to display information from my database.
I create a page call coupon_list.php with table logo/store/description/coupon/date where people can click on the store and have the coupon list of that store right now when people click on and go to the store_detail page list only one coupon of that store.
I need also to create page with all my merchants name where again people can click on it and have the full coupon list of that store.
and coupon by category.

My structure table

-merchants-
id
name
url
extra

-deals-
dealID
logo
merchID
description
coupon
expire
cat_id

-category-
id
name

coupon_list.php
<?php
// Load the tNG classes
require_once('includes/tng/tNG.inc.php');

$maxRows_rsTOTALDEAL = 20;
$pageNum_rsTOTALDEAL = 0;
if (isset($_GET['pageNum_rsTOTALDEAL'])) {
  $pageNum_rsTOTALDEAL = $_GET['pageNum_rsTOTALDEAL'];
}
$startRow_rsTOTALDEAL = $pageNum_rsTOTALDEAL * $maxRows_rsTOTALDEAL;
$recordID = $HTTP_GET_VARS['recordID'];

mysql_select_db($database_onlinebestlinks, $onlinebestlinks);
$query_rsTOTALDEAL = "SELECT deals.logo, merchants.name, merchants.id, deals.description, deals.coupon, deals.expires FROM (merchants LEFT JOIN deals ON deals.merchID=merchants.id) ORDER BY merchants.name ASC";
$query_limit_rsTOTALDEAL = sprintf("%s LIMIT %d, %d", $query_rsTOTALDEAL, $startRow_rsTOTALDEAL, $maxRows_rsTOTALDEAL);
$rsTOTALDEAL = mysql_query($query_limit_rsTOTALDEAL, $onlinebestlinks) or die(mysql_error());
$row_rsTOTALDEAL = mysql_fetch_assoc($rsTOTALDEAL);

if (isset($_GET['totalRows_rsTOTALDEAL'])) {
  $totalRows_rsTOTALDEAL = $_GET['totalRows_rsTOTALDEAL'];
} else {
  $all_rsTOTALDEAL = mysql_query($query_rsTOTALDEAL);
  $totalRows_rsTOTALDEAL = mysql_num_rows($all_rsTOTALDEAL);
}
$totalPages_rsTOTALDEAL = ceil($totalRows_rsTOTALDEAL/$maxRows_rsTOTALDEAL)-1;

$colname_rsDETAIL = "-1";
if (isset($_GET['recordID'])) {
  $colname_rsDETAIL = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);
}
mysql_select_db($database_onlinebestlinks, $onlinebestlinks);
$query_rsDETAIL = sprintf("SELECT name, url, extra FROM merchants WHERE id = %s", $colname_rsDETAIL);
$rsDETAIL = mysql_query($query_rsDETAIL, $onlinebestlinks) or die(mysql_error());
$row_rsDETAIL = mysql_fetch_assoc($rsDETAIL);
$totalRows_rsDETAIL = mysql_num_rows($rsDETAIL);
?>

<body>
<table class="sample">
  <tr>
    <th>Logo</th>
    <th>Store</th>
    <th>Description </th>
    <th>Coupon</th>
    <th>Expiration</th>
  </tr>
  <?php do { ?>
  <tr>
    <td><img src="<?php echo tNG_showDynamicImage("", "img/", "{rsTOTALDEAL.logo}");?>" /></td>
    <td><a href="store_detail.php?recordID=<?php echo $row_rsTOTALDEAL['id']; ?>"> <?php echo $row_rsTOTALDEAL['name']; ?></a></td>
    <td><?php echo $row_rsTOTALDEAL['description']; ?></td>
    <td><?php echo $row_rsTOTALDEAL['coupon']; ?></td>
    <td><?php echo $row_rsTOTALDEAL['expires']; ?></td>
  </tr>
  <?php } while ($row_rsTOTALDEAL = mysql_fetch_assoc($rsTOTALDEAL)); ?>
</table>
<?php
mysql_free_result($rsTOTALDEAL);

mysql_free_result($rsDETAIL);
?>


store_detail.php
<?php
// Load the tNG classes
require_once('includes/tng/tNG.inc.php');

$maxRows_rsTOTALDEAL = 20;
$pageNum_rsTOTALDEAL = 0;
if (isset($_GET['pageNum_rsTOTALDEAL'])) {
  $pageNum_rsTOTALDEAL = $_GET['pageNum_rsTOTALDEAL'];
}
$startRow_rsTOTALDEAL = $pageNum_rsTOTALDEAL * $maxRows_rsTOTALDEAL;
$recordID = $HTTP_GET_VARS['recordID'];

mysql_select_db($database_onlinebestlinks, $onlinebestlinks);
$query_rsTOTALDEAL = "SELECT deals.logo, merchants.name, merchants.id, deals.description, deals.coupon, deals.expires FROM (merchants LEFT JOIN deals ON deals.merchID=merchants.id) ORDER BY merchants.name ASC";
$query_limit_rsTOTALDEAL = sprintf("%s LIMIT %d, %d", $query_rsTOTALDEAL, $startRow_rsTOTALDEAL, $maxRows_rsTOTALDEAL);
$rsTOTALDEAL = mysql_query($query_limit_rsTOTALDEAL, $onlinebestlinks) or die(mysql_error());
$row_rsTOTALDEAL = mysql_fetch_assoc($rsTOTALDEAL);

if (isset($_GET['totalRows_rsTOTALDEAL'])) {
  $totalRows_rsTOTALDEAL = $_GET['totalRows_rsTOTALDEAL'];
} else {
  $all_rsTOTALDEAL = mysql_query($query_rsTOTALDEAL);
  $totalRows_rsTOTALDEAL = mysql_num_rows($all_rsTOTALDEAL);
}
$totalPages_rsTOTALDEAL = ceil($totalRows_rsTOTALDEAL/$maxRows_rsTOTALDEAL)-1;

$colname_rsDETAIL = "-1";
if (isset($_GET['recordID'])) {
  $colname_rsDETAIL = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);
}
mysql_select_db($database_onlinebestlinks, $onlinebestlinks);
$query_rsDETAIL = sprintf("SELECT name, url, extra FROM merchants WHERE id = %s", $colname_rsDETAIL);
$rsDETAIL = mysql_query($query_rsDETAIL, $onlinebestlinks) or die(mysql_error());
$row_rsDETAIL = mysql_fetch_assoc($rsDETAIL);
$totalRows_rsDETAIL = mysql_num_rows($rsDETAIL);
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<table width="640" border="1">
  <tr>
    <td colspan="6" align="center"><?php echo $row_rsDETAIL['name']; ?></td>
  </tr>
  <tr>
    <td colspan="6"><?php echo $row_rsDETAIL['extra']; ?></td>
  </tr>
  <tr>
    <td width="89"><?php echo $row_rsDETAIL['url']; ?></td>
    <td width="89"><?php echo $row_rsTOTALDEAL['description']; ?></td>
    <td width="89"><?php echo $row_rsTOTALDEAL['coupon']; ?></td>
    <td width="89"><?php echo $row_rsTOTALDEAL['expires']; ?></td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($rsDETAIL);
?>


Anybody got any ideas?


Go to topic 47804

Return to index page 210
Return to index page 209
Return to index page 208
Return to index page 207
Return to index page 206
Return to index page 205
Return to index page 204
Return to index page 203
Return to index page 202
Return to index page 201