PDA

View Full Version : newbie -


shaunah
09-16-2002, 08:01 PM
Hello,

I'm having difficulty making a modification to my script. I am not a programmer and am not sure on all things structure related.

I want to take this bit of code (that lists all items and their details for a particular category) but I want to modify the script to pull a selection list of colors and sizes from another table where the produt id matches.

Here is the original code (with some size and color placeholders)...

$query = "select * from sos_products WHERE disabled='0' AND categoryid='".$id."'".$addquery;
$resultselect = mysql_query($query);
while ($j < mysql_num_rows($resultselect)) {
$productid = mysql_result($resultselect, $j,"id");
$name = mysql_result($resultselect, $j,"name");
$name2 = mysql_result($resultselect, $j,"name2");
$price = mysql_result($resultselect, $j,"price");
$idnum = ($page-1)*$sos_itemsperpage+$j+1;
$returnstr .= '<tr><input type=hidden name="price'.$productid.'" value="'.$price.'">'.
'<td><center>'.$idnum.'</td>'.
'<td>'.$name.'</td>'.
'<td><center>'.$sos_currency.$price.'</td>'.
'<td><center><select name="size">
<option value="Red">Red</option>
<option value="Blue">Blue</option>
</select></td>'.
'<td><center><select name="size">
<option value="S">S</option>
<option value="M">M</option>
<option value="L">L</option>
<option value="XL">XL</option>
<option value="XXL">XXL</option>
</select></td>'.
'<td><center><input type=text value=1 size=3 name="number'.$productid.'"></td>'.
'<td><center><input type="checkbox" name="item_ids[]" value="'.$productid.'" /></center></td>'.
'</tr>';
$j++;
}
mysql_close();

Here is the code I've tried to write to access the sizes and colors tables:

$query = "select * from sos_products WHERE disabled='0' AND categoryid='".$id."'".$addquery;
$resultselect = mysql_query($query);
while ($j < mysql_num_rows($resultselect)) {
$productid = mysql_result($resultselect, $j,"id");
$name = mysql_result($resultselect, $j,"name");
$name2 = mysql_result($resultselect, $j,"name2");
$price = mysql_result($resultselect, $j,"price");
$idnum = ($page-1)*$sos_itemsperpage+$j+1;
$returnstr .= '<tr><input type=hidden name="price'.$productid.'" value="'.$price.'">'.
'<td><center>'.$idnum.'</td>'.
'<td>'.$name.'</td>'.
'<td><center>'.$sos_currency.$price.'</td>'.
'<td><center><select name="size">'.



$SQL = "SELECT * FROM sos_color WHERE id = '$id'";
$resultcolors = mysql_query($SQL);
while ($j < mysql_num_rows($resultcolors)) {

$returnstr .= '<option value="'.
$color
'">'.
$color
'</option>'.



'</select></td>'.
'<td><center><input type=text value=1 size=3 name="number'.$productid.'"></td>'.
'<td><center><input type="checkbox" name="item_ids[]" value="'.$productid.'" /></center></td>'.
'</tr>';
$j++;
}
mysql_close();

craigh@mac.com
09-17-2002, 11:57 PM
so what is the problem?