Wstar Posted September 7, 2006 Share Posted September 7, 2006 Alright, I'm new to these forums so I hope I can explain my problem right.WHAT I WANT is a table that displays information gathered from a database. Each item in the table can be clicked on to edit the item. Each item is the database has a product_id and prodcut_name. The table is generated by the following code.[code] <table class="sort-table" id="table-1" cellspacing="0" align="center"> <col style="text-align: center" /> <col style="text-align: left" /> <thead> <tr> <td>ID</td> <td>Product</td> </tr> </thead> <tbody> <?php // open connection to the server @mysql_pconnect("","","") or die("Could not connect to MySQL server!"); //open connection to the database @mysql_select_db("") or die("Could not select database!"); // start inserting into database $products_table__query = "SELECT products_id, products_name FROM products_description ORDER BY products_id"; $products_table = mysql_query($products_table__query); for($count=0; $count <= (mysql_numrows($products_table)-1); $count++){ echo '<tr>'; ?> <td><A HREF="reviews.php"><?php echo mysql_result($products_table, $count, "products_id") ?></A></td> <td><A HREF="reviews.php"><?php echo mysql_result($products_table, $count, "products_name") ?></A></td> <?php echo '</tr>'; } ?> </tbody> </table>[/code]When the user clicks on a product name, php file loads again and gives the user fields to type in and edit the product. What I'm having trouble with is knowing what product link the user clicked on. When the file loads again, all he variables are reset.I've tryed onlclick="" and had no luck. What else can I do?Thank you for any information you can give!|Wstar| Quote Link to comment https://forums.phpfreaks.com/topic/20042-posting-problem/ Share on other sites More sharing options...
HuggieBear Posted September 7, 2006 Share Posted September 7, 2006 You could pass it in the url...So have the code from the db generate links like this...[code]<a href="reviews.php?id=1">Product 1</a><a href="reviews.php?id=2">Product 2</a>[/code]Then have you next page (reviews.php) do another select from the database based on the $_GET['id']and propogate the forms accordingly.RegardsRich Quote Link to comment https://forums.phpfreaks.com/topic/20042-posting-problem/#findComment-87945 Share on other sites More sharing options...
Wstar Posted September 8, 2006 Author Share Posted September 8, 2006 Thank you! I've always wondered why and how you did that witht he url. Thanks for the help, works perfectly!|Wstar| Quote Link to comment https://forums.phpfreaks.com/topic/20042-posting-problem/#findComment-88412 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.