Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show if url parameter =

Status
Not open for further replies.

tshey

Technical User
Dec 28, 2005
78
AU
I have a form with an initial jump menu that dynamically populates the next two drop down boxes.On selection of the initial menu, the id is passed through the url.

I want one box not to show if the initial option domestic is chosen.
table is category, field name is category and cat_id the values are domestic =1 and commercial =2
Code:
<?php if ($row_cat-id['category'] == "1") 
  { ?> 
<select name="problems"></select>
   <?php } // Show if recordset empty ?>
 
I don't think you can use a dash in a variable name because it means minus to PHP. What you have is equivalent to:

Code:
if ($row_cat - id['category'] == "1")

Lee
 
yer sorry my typo it reads as:
Code:
<?php if ($row_cat_id['category'] == "1") 
  { ?> 
<select name="problems"></select>
   <?php } // Show if recordset empty ?>
 
You gotta copy and paste your code in here so we don't have to "solve" problems that don't exist.

You're not showing the code that gets the data from the URL, though.

Lee
 
sorry!
Code:
<?php
mysql_select_db($database_vacuumshop, $vacuumshop);
$query_category = "SELECT * FROM category";
$category = mysql_query($query_category, $vacuumshop) or die(mysql_error());
$row_category = mysql_fetch_assoc($category);
$totalRows_category = mysql_num_rows($category);

$colname_subcat = "1";
if (isset($_GET['cat_id'])) {
  $colname_subcat = (get_magic_quotes_gpc()) ? $_GET['cat_id'] : addslashes($_GET['cat_id']);
}
mysql_select_db($database_vacuumshop, $vacuumshop);
$query_subcat = sprintf("SELECT * FROM subcategory WHERE cat_id = %s", $colname_subcat);
$subcat = mysql_query($query_subcat, $vacuumshop) or die(mysql_error());
$row_subcat = mysql_fetch_assoc($subcat);
$totalRows_subcat = mysql_num_rows($subcat);

$colname_subcat2 = "1";
if (isset($_GET['cat_id'])) {
  $colname_subcat2 = (get_magic_quotes_gpc()) ? $_GET['cat_id'] : addslashes($_GET['cat_id']);
}
mysql_select_db($database_vacuumshop, $vacuumshop);
$query_subcat2 = sprintf("SELECT * FROM subcategory2 WHERE cat_id = %s", $colname_subcat2);
$subcat2 = mysql_query($query_subcat2, $vacuumshop) or die(mysql_error());
$row_subcat2 = mysql_fetch_assoc($subcat2);
$totalRows_subcat2 = mysql_num_rows($subcat2);
?>
 
hi toby
you don't show where you build your select boxes.

but conditionalising the part where you build and display the select box is the way to go.

Code:
if ( (isset($_GET['cat_id'])) 
     && 
     ((int) trim($_GET['cat_id']) !== 1)):
 // build the select box
else:
 // don't build the select box
endif;

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top