Jump to content

Archived

This topic is now archived and is closed to further replies.

Wstar

POSTING PROBLEM

Recommended Posts

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|

Share this post


Link to post
Share on other sites
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.

Regards
Rich

Share this post


Link to post
Share on other sites
Thank you!  I've always wondered why and how you did that witht he url.  Thanks for the help, works perfectly!

|Wstar|

Share this post


Link to post
Share on other sites

×

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.