I'm a NEWBIE and I have been stuck on this for days.
I have one table that has the following rows:
rid = Referral ID
category = Category
subcategory = Subcategory
rbusiness = Referred Business Name
rcontact = Referred Contact Name
etc..
I have created the form (referral_input.php) that allows the user to input their referral data including category and subcategory. I have also created a page (my_categories.php) which lists all the categories in which the user has a referral using a WHILE LOOP. From there, I wish for the user to select one of their categories and then be taken to (my_subcategories.php) where I employ another WHILE LOOP. From there, the user would select a subcategory and be taken to a resulting page displaying all the date for that referral (like a contact page in address book).
So here is where I am stuck. I have tried many variations (from $_POST to $GET to SESSION) to pass along the value of their selection on the (my_categories.php) to the (my_subcategories.php) page and include it in the query. None have worked. Any advice and patience is welcome. Also, as I am new, please be descriptive. I see many responses that are one sentence long and mean nothing to those of us starting out.
Here are the pages:
1st page (my_categories.php)
<?php
include "include/session.php";
include "fb-config.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
<title>friendhelper</title>
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="index,follow" name="robots" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link href="http://www.friendhelper.com/css/style.css" rel="stylesheet" media="screen" type="text/css" />
<script src="http://www.friendhelper.com/javascript/functions.js" type="text/javascript"></script>
<meta content="iPad,iPhone,iPhone4,referrals,friends,networking,app" name="keywords" />
<meta content="socially give and receive referrals with friends for products and services with this add" />
</head>
<body>
<div id="topbar">
<div id="leftnav"><a href="home.php"><img alt="home" src="images/home.png" /></a><a href="friends.html">Friends</a></div>
</div>
<div id="rightnav"><a href="page-coming-soon.php">Friend Request</a></div>
<div id="content">
<ul class="pageitem">
<li class="menu"> <a class="noeffect" onclick="location.href='referral_input.php'"> <img alt="my account" src="http://friendhelper.com/thumbs/myaccount-thumb.png" /><span class="name">Add a Referral</span><span class="arrow"></span></a></li>
</ul>
<span class="graytitle">My Categories</span>
<form method='POST' name="mycategories" action='my_subcategories.php'>
<fieldset>
<ul class="pageitem">
<?php $query = "SELECT * FROM referrals WHERE username='$_SESSION[username]' ORDER BY category ASC";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){ ?>
<li class='menu'><span class='name'>
<a class="noeffect" onclick="document.mycategories.submit();return false" />
<input type="hidden" name="category">
<?php echo $row['category']; ?>
</span><span class='arrow'></span></a></li>
<?php echo ""; } ?>
</ul>
</fieldset>
</form>
</div>
</body>
</html>
2nd page (my_subcategories.php)
<?php
include "include/session.php";
include "fb-config.php";
$category=$_POST['category'];
$category=mysql_real_escape_string($category);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
<title>friendhelper</title>
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="index,follow" name="robots" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link href="http://www.friendhelper.com/css/style.css" rel="stylesheet" media="screen" type="text/css" />
<script src="http://www.friendhelper.com/javascript/functions.js" type="text/javascript"></script>
<meta content="iPad,iPhone,iPhone4,referrals,friends,networking,app" name="keywords" />
<meta content="socially give and receive referrals with friends for products and services with this add" />
</head>
<body>
<div id="topbar">
<div id="leftnav"><a href="home.php"><img alt="home" src="images/home.png" /></a><a href="friends.html">Friends</a></div>
</div>
<div id="rightnav"><a href="page-coming-soon.php">Friend Request</a></div>
<div id="content">
<ul class="pageitem">
<li class="menu"> <a class="noeffect" onclick="location.href='referral_input.php'"> <img alt="my account" src="http://friendhelper.com/thumbs/myaccount-thumb.png" /><span class="name">Add a Referral</span><span class="arrow"></span></a></li>
</ul>
<span class="graytitle">My SubCategories</span>
<form method='POST' name="mycategories" action='my_subcategories.php'>
<fieldset>
<ul class="pageitem">
<?php $query = "SELECT * FROM referrals WHERE username='$_SESSION[username]' AND category='$category' ORDER BY subcategory ASC";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){ ?>
<li class='menu'><span class='name'>
<a class="noeffect" onclick="document.mycategories.submit();return false" />
<input type="hidden" name="subcategory">
<?php echo $row['subcategory']; ?>
</span><span class='arrow'></span></a></li>
<?php echo ""; } ?>
</ul>
</fieldset>
</form>
</div>
</body>
</html>