Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > Adobe Web Programming > Dreamweaver (all versions)
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Dreamweaver (all versions) section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 7th, 2006, 12:35 PM
Registered User
 
Join Date: Aug 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need Help Master Detail page

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
Code:
<?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
Code:
<?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?

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
master-detail hhpatek ADO.NET 0 April 3rd, 2008 02:53 PM
Master Detail prasanta2expert Access VBA 1 October 1st, 2007 06:37 AM
master/detail page yteferi ASP.NET 2.0 Basics 6 April 12th, 2006 09:04 AM
Master/Detail page yteferi ASP.NET 2.0 Basics 1 April 5th, 2006 04:06 PM



All times are GMT -4. The time now is 05:24 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.