Jump to content

filtering multiple recordset. Desperate


jonnyfortis

Recommended Posts

Hello

I am really desperate for help can someone look at my code and see where i am going wrong.

I have three tables in a PHP Mysql database all joined. I will show the joined feilds

 

Catagory Table

catID

catname

 

Product Table

ID

catID

SizeProdID

 

and a Size Table

SizeID

SizeProdID

catname

 

 

I have a product page showing all products (by images) from a product table.

 

mysql_select_db($database_beau, $beau);
$query_Recordset1 = "SELECT * FROM beauProd ORDER BY name ASC";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $beau) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

<a href="product-description.php?ID=<?php echo $row_Recordset1['ID']; ?>"><img src="../images/AW/thumbs/<?php echo $row_Recordset1['imageSmall']; ?>"/></a>

 

on the detail page i need to get information from ALL the tables

 

the first part is I need to have a select list that shows all the products from that catagory and when another product is select form the list and submitted is shows the new product

 

so here is this script

$colname_Recordset1 = "-1";
if (isset($_GET['ID'])) {
  $colname_Recordset1 = $_GET['ID'];
}
mysql_select_db($database_beau, $beau);
$query_Recordset1 = sprintf("SELECT * FROM beauProd WHERE ID = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $beau) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = "-1";
if (isset($_GET['ID'])) {
  $totalRows_Recordset1 = $_GET['ID'];
}

<select name="name" class="text" id="selectName">
                  <option value="Select Design">Select Design</option>
                  <?php
do {
?>
                  <option value="<?php echo $row_Recordset1['ID']; ?>"><?php echo $row_Recordset1['name']; ?></option>
                  <?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
  $rows = mysql_num_rows($Recordset1);
  if($rows > 0) {
      mysql_data_seek($Recordset1, 0);
            $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  }
?>
                </select>

i then need to show in another select list the sizes from the product selected in the previous select list

$colname_Recordset2 = "-1";
if (isset($_GET['SizeProdID'])) {
  $colname_Recordset2 = $_GET['SizeProdID'];
}
mysql_select_db($database_beau, $beau);
$query_Recordset2 = sprintf("SELECT * FROM beauProd, beauSizes WHERE beauSizes.SizeProdID = beauProd.SizeProdID AND beauProd.SizeProdID = %s", GetSQLValueString($colname_Recordset2, "int"));
$Recordset2 = mysql_query($query_Recordset2, $beau) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);

<select name="os0" class="text" id="Cos0">
    <option value="select Category">Select Size</option>
    <?php
do { 
?>
    <option value="<?php echo $row_Recordset2['SizeProdID']; ?>"><?php echo $row_Recordset2['from'] . " - " . $row_Recordset2['to'] ; ?></option>
    <?php
} while ($row_Recordset2 = mysql_fetch_assoc($Recordset2));
  $rows = mysql_num_rows($Recordset1);
  if($rows > 0) {
      mysql_data_seek($Recordset2, 0);
            $row_Recordset2 = mysql_fetch_assoc($Recordset2);
  }
?>
  </select>

 

this is basically what i need to achieve but currently the select list looking for the produts is just showing the product the page is for and the size list is showing nothing

 

any help would be greatly appreciated

Link to comment
Share on other sites

OK i will try and explain more clearly, want just the products in that category to be displayed. From the main product page i am linking to the detail page via the product ID but when i am on that product page i need to call all other products in a select list from the same category.

 

When a new product is selected from the select list i need to send it to that said product.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.