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
https://forums.phpfreaks.com/topic/284040-php-addremove-table-postgresql/
Share on other sites

Archived

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

×
×
  • 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.