pass the value of reference as an argument to your 'deleteCategory()' and 'renameCategory()' functions: <script type="text/javascript"> function deleteCategory(refVal) { ... do something with refVal ... } function renameCategory(refVal) { ... do something with refVal ... } </script> $table = "<table>\n"; while($row = mysql_fetch_array($result > > ,MYSQL_ASSOC)) { > $table .= "<tr>\n"; > $table .= "<td>" . stripslashes($row['category_name']) . "</td>\n"; > $table .= "<td><input type=\"button\" name=\"submit\" > id=\"delete\" > value=\"Delete Category\" onclick=\"deleteCategory('" . $row['reference'] > . "');\"></td>\n"; > $table .= "<td><input type=\"button\" name=\"submit\" > id=\"rename\" > value=\"Rename Category\" onclick=\"renameCategory('" . $row['reference'] > . "');\"></td>\n"; > $table .= "</tr>\n"; > } > $table .= "</table>\n"; hope that helps. -- matt On Sat, May 3, 2008 at 1:00 PM, Ron Piggott <ron.php@xxxxxxxxxxxxxxxxxx> wrote: > > In the PHP script below I need to be able to pass on the value of > 'reference' within the shopping_cart_product table when the "Delete > Category" and "Rename Category" buttons are clicked. How do I do this? > Ron > > > > mysql_connect('localhost',$username,$password); > @mysql_select_db($database) or die( "Unable to select database"); > > $query = "SELECT * > FROM shopping_cart_category c > LEFT OUTER JOIN shopping_cart_product p > ON c.reference = p.reference > ORDER BY c.category_name ASC"; > > $result = mysql_query($query); > > if(!$result) die('error: ' . mysql_error()); > > mysql_close(); > > $table = "<table>\n"; > while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { > $table .= "<tr>\n"; > $table .= "<td>" . stripslashes($row['category_name']) . "</td>\n"; > $table .= "<td><input type=\"button\" name=\"submit\" > id=\"delete\" > value=\"Delete Category\" onclick=\"deleteCategory();\"></td>\n"; > $table .= "<td><input type=\"button\" name=\"submit\" > id=\"rename\" > value=\"Rename Category\" onclick=\"renameCategory();\"></td>\n"; > $table .= "</tr>\n"; > } > $table .= "</table>\n"; > > echo $table; > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >