too long

That's the function which I'm using to print the contents of 'username' table:

function showtable()
{
  ob_start();  

  $db = new PDO("sqlite:test.db");

  $query = "SELECT * FROM " . $_SESSION['username'] . " ORDER BY `a` DESC;";
  $result = $db->prepare($query);
  $result = $db->query($query);

  print "<table>";
  print "<tr><td>First Column</td><td>Second Column</td><td>Third column</td></tr>";
  foreach ($result as $row)
  {
    print "<tr><td>" . $row['a'] . "</td><td>" . $row['b'] . "</td><td>Here stays the button</td></tr>";
  }  
  print "</table>";

  unset($db);

  ob_end_flush();
}

So, how should look a function so when creating each row of the html table, a button for updating the corresponding sqlite table row is inserted in the third cell (named 'Here stays the button' for easier reading)? I'm calling my function when opening the test.php (with added required_once('functions.php')) file in main browser window, nothing special in that.

That's the UPDATE query:

$query = "UPDATE " . $_SESSION['username'] . " SET `c` = '1'" . " WHERE `a` = " . $row['a'] . ";";

a column is integer primary key

b column is text

c column is integer, all fields hold 0 value

P.S. Don't talk about AJAX, I'm not ready for it (and don't like it, a lot of pages that use AJAX lag the browser). Just asking for ideas about a simple php function, that adds UPDATE TABLE functionality through buttons for each row.

Thanks in advance :)

What is the updating for? what will happen if C = 1?

anyway for your question, my suggestion is to use an anchor tag. i.e

in the "Here stays the button" will be <a href="test.php?a_new='".$row['a']."'">Update</a>

in your test.php

if($_GET['a_new'] != '')
{
$query = "UPDATE " . $_SESSION['username'] . " SET `c` = '1'" . " WHERE `a` = ".$_GET['a_new']."";
}

p.s you have excess ";" in your query. you only add the query on the end of the query statement not inside it i.e $sql = "select * from"; not $sql = "select * from;";