Forums
This topic is locked
Help needed on Master page, php/Mysql Please
Posted 22 years ago
1
has voted
22 years ago Manou Manou posted:
Hello;I have made a Master /Detail page to show some data from a database I made,
master/detail page work fine.
but I have some problem with categories, in my database I have a table for
categories.
I have made a page called " category" in there it is a pull down menu of
categories, the problem is when you choose any category and click on submit,
the master page loads but always shows all the info in the master page, it
suppose to show the data related to the category it has been chosen,
I have even tried it with no pull down menu, just a simple text, but the result was same as before, actually it seems that there is no difference clicking on a catgory or opening the
Master page directly.
in the category page I have only one Recordset, which is category_id, and
Category_Title,
what i did when draging the recordset of Category_Title to the category
page, linking it to the master page, I gave it some values by clicking the
Parameter button as:
Name: category_id Value: category_id
and these are the codes of category page, "yellowpage_m "is my master page and
"yellowpage_d" is my detail page:
<?php require_once('Connections/ConnYellowPage.php'); ?>
<?php
mysql_select_db($database_ConnYellowPage, $ConnYellowPage);
$query_RsCategory = "SELECT * FROM category";
$RsCategory = mysql_query($query_RsCategory, $ConnYellowPage) or
die(mysql_error());
$row_RsCategory = mysql_fetch_assoc($RsCategory);
$totalRows_RsCategory = mysql_num_rows($RsCategory);
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="530" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<?php do { ?>
<tr>
<td width="530" height="30"><a href="yellowpage_m.php?category_id=<?php
echo $row_RsCategory['category_id']; ?>"><?php echo
$row_RsCategory['Category_Title']; ?></a></td>
<td width="530"> </td>
</tr>
<tr>
<td height="27"> </td>
<td> </td>
</tr>
<?php } while ($row_RsCategory = mysql_fetch_assoc($RsCategory)); ?>
<tr>
<td height="25"> </td>
<td> </td>
</tr>
<tr>
<td height="26"> </td>
<td> </td>
</tr>
<tr>
<td height="26"> </td>
<td> </td>
</tr>
<tr>
<td height="38"> </td>
<td> </td>
</tr>
<tr>
<td height="36"> </td>
<td> </td>
</tr>
<tr>
<td height="29"> </td>
<td> </td>
</tr>
<tr>
<td height="27"> </td>
<td> </td>
</tr>
<tr>
<td height="188"> </td>
<td> </td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($RsCategory);
?>
and these are the code of Master page:
<?php require_once('Connections/ConnYellowPage.php'); ?>
<?php
$colname_RsMasterC = "1";
if (isset($HTTP_GET_VARS['category'])) {
$colname_RsMasterC = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['category'] : addslashes($HTTP_GET_VARS['category']);
}
mysql_select_db($database_ConnYellowPage, $ConnYellowPage);
$query_RsMasterC = sprintf("SELECT company.company_id, company.Company_Name, company.Name, company.Job_Title, company.category_id, category.category_id FROM company, category WHERE company.category_id = category.category_id AND category_id=%s", $colname_RsMasterC);
$RsMasterC = mysql_query($query_RsMasterC, $ConnYellowPage) or die(mysql_error());
$row_RsMasterC = mysql_fetch_assoc($RsMasterC);
$totalRows_RsMasterC = mysql_num_rows($RsMasterC);
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="555" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="22" height="21"> </td>
<td width="516"> </td>
<td width="17"> </td>
</tr>
<tr>
<td height="53"> </td>
<td valign="top"> <table border="0">
<tr>
<td>company_id</td>
<td>Company_Name</td>
<td>Name</td>
<td>Job_Title</td>
<td>category_id</td>
<td>category_id</td>
</tr>
<?php do { ?>
<tr>
<td><a href="yellowpage_d.php?company_id=<?php echo $row_RsMasterC['company_id']; ?>"><?php echo $row_RsMasterC['company_id']; ?></a></td>
<td><?php echo $row_RsMasterC['Company_Name']; ?></td>
<td><?php echo $row_RsMasterC['Name']; ?></td>
<td><?php echo $row_RsMasterC['Job_Title']; ?></td>
<td><?php echo $row_RsMasterC['category_id']; ?></td>
<td><?php echo $row_RsMasterC['category_id']; ?></td>
</tr>
<?php } while ($row_RsMasterC = mysql_fetch_assoc($RsMasterC)); ?>
</table>
</td>
<td> </td>
</tr>
<tr>
<td height="150"> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($RsMasterC);
?>
I don't know what I do wrong, and I don't know about Php, I have just started learning Mysql,
I use DWMX and PHP, Mysql,
I appreciate any help.
Thanx