Jump to content

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|
Link to comment
https://forums.phpfreaks.com/topic/20042-posting-problem/
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
Link to comment
https://forums.phpfreaks.com/topic/20042-posting-problem/#findComment-87945
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.