Passing info in URL
Posted: Mon Feb 23, 2004 3:56 pm
I have the following 2 pages that i need to pass an id variable between. The first page lists all categories from a DB. The second should display all the sub-categories from the chosen main category. This is not happening at the moment.
Displays all categories
Displays all sub-categories in select list
Normally I would just use but this is not working. I assume this is because their are other things in the URL. How can I extract the ID from the URL.
Displays all categories
Code: Select all
<?php
switch($_GET['act']) {
default:
menu();
break;
case "sub":
submit();
break;
}
function menu() {
$skinz = my_conn();
$query_submit = "SELECT * FROM skinz_categories WHERE status='1' ORDER BY cat_name ASC";
$submit = mysql_query($query_submit, $skinz) or die(mysql_error());
$row_submit = mysql_fetch_assoc($submit);
$totalRows_submit = mysql_num_rows($submit);
echo "<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td align='left' class='maintitle'>Choose A Category</td>
</tr>
</table>
<table width='100%' cellspacing='0' class='tableborder'>
<tr>
<td width='95%' valign='top' class='post1'><table width='90%' border='1' align='center' cellpadding='0' cellspacing='0'>\n";
do
echo "<tr>
<td class='heading'><a href='submit.php?act=sub&id=".$row_submit['cat_id']."'>".$row_submit['cat_name']."</a></td>
</tr>
<tr>
<td>".$row_submit['cat_description']."</td>
</tr>\n";
while ($row_submit = mysql_fetch_assoc($submit));
echo "</table></td>
</tr>
</table>\n";
}
function submit() {
include('sub.php');
}
?>Code: Select all
<?php
// Include SDK functions and files
require_once "forum/ipbsdk_class.inc.php";
$SDK =& new IPBSDK();
// Logged in so retrieve member info
$info = $SDK->get_info();
$member_name = $info['name'];
$member_id = $info['id'];
$id = $HTTP_GET_VARS['id'];
$skinz = my_conn();
$query_submit = "SELECT * FROM skinz_subcategories WHERE status='1' AND cat_id='$id'";
$submit = mysql_query($query_submit, $skinz) or die(mysql_error());
$row_submit = mysql_fetch_assoc($submit);
$totalRows_submit = mysql_num_rows($submit);
?>
<form action="upload.php" method="post" enctype="multipart/form-data">
<div align="center" class="tableborder">
<table width="95%" align="center" class="sborder">
<tr>
<td width="25%" class="statsheader">User Name :</td>
<td width="75%" align="right" class="statsheader"><?php echo $member_name; ?></td>
</tr>
<tr>
<td width="25%" class="statsheader">Sub Category :</td>
<td width="75%" align="right" class="statsheader"><select name="select" class="forminput">
<?php
do {
?>
<option value="<?php echo $row_submit['subcat_id']?>"><?php echo $row_submit['subcat_name']?></option>
<?php
} while ($row_submit = mysql_fetch_assoc($submit));
$rows = mysql_num_rows($submit);
if($rows > 0) {
mysql_data_seek($submit, 0);
$row_submit = mysql_fetch_assoc($submit);
}
?>
</select>
</td>
</tr>
</table>
</div>
</form>Code: Select all
$id = $HTTP_GET_VARS['id'];