0

I want to get a specific row from a table with an id. My table has 5 columns named: id, title, active, position, content

for example, if i give id 5 then the database must give me the row where ID = 5

now i have this

$result = mysql_query("SELECT * FROM klant1");

    $contents = mysql_fetch_array($result); 
            $rows = mysql_num_rows($result);

            for($i = 0; $i <= $rows - 1; $i ++){
                echo "<div id='block'>";
                echo "<table id='titleTab'>";
                echo "<tr id='title'>";
                echo "<td>Title</td><td>Active</td><td>Remove</td><td>Position</td><td></td></tr></table>";

                echo "<table id='sub'><tr><td>Menu</td>";
                echo "<td><input style='float: left;' type='checkbox'/></td>";
                echo "<td><img style='height:11px;'src='img/delete.png'/></td>";
                echo "<td><select><option value='1'>1</option></select></td>";
                echo "<td><img style='float: right; height: 20px;' src='img/save.png'/></td>";
                echo "</tr></table> </div>";
            }

I want to change keywords such as Title in the right title of the current row.

Sorry for my bad english by the way

1T-933k
  • 11
  • 1

2 Answers2

1

Add a WHERE and use PDO. mysql_query is deprecated.

$pdo = new PDO(...);
$statement = $pdo->prepare("SELECT * FROM klant1 WHERE id = ?");
$statement->bindParam(1, $id);
$statement->execute();
NobleUplift
  • 5,631
  • 8
  • 45
  • 87
0

mysql_query is deprecated. This extension is not available in php 5.5 and will be removed for all upcoming php versions.

See here: http://at1.php.net/manual/en/function.mysql-query.php

Warning This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include: mysqli_query()

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Mubo
  • 1,078
  • 8
  • 16