Jump to content

PHP add/remove table Postgresql


krzysiekleb

Recommended Posts

Hi I have data from database in postgresql. I show them like this

<form name="delete" id="delete action="<?php echo $PHP_SELF?>" onsubmit="return sprawdz()" method="post" >
<?php
echo"Aktualne terminy rezerwacji.";
$results=pg_query($connection,"select * from ulice_miasta");

    echo "<table border=1>\n";
    echo"<tr><td>Ulica</td><td>Miasto</td><td></td></tr>";
    $i=0;
    for($lt = 0; $lt < pg_num_rows($results); $lt++) {
        echo "<tr>\n";
          for($gt = 1; $gt < pg_num_fields($results); $gt++) {
            echo "<td>" . pg_result($results, $lt, $gt) . "</td>\n";
        }
        for($gt = 0; $gt < 1; $gt++) {
             $abc=pg_result($results,$lt,0);
             echo
        "<td>
        <input type='submit' name='submit' value='delete'/>$abc</td>
        <input type='hidden' name='delete' value=$abc/>";
             }
        
        
        echo "</tr>\n";
    }
    echo "</table>\n";

?>
</form>

 

On the line " <input type='submit' name='submit' value='delete'/>$abc</td>"  the number is correct but after clicking on "delete" it send by POST the last number from the list.

 

Any advice ?

 

The table colums are like "ID", Street, City

"USUN" is a "Delete" button

 

post-166468-0-86576900-1384816530_thumb.png

Link to comment
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.