Page 1 of 1

Mysql edit

Posted: Sun Nov 20, 2011 9:52 am
by asai
Hi,

I have this php file that list the content of a table in a database:

Code: Select all

<html>
<head>
<title>REGNSKAP</title>

<link href="css/style.css" rel="stylesheet" type="text/css" media="screen" />

</head>
</style>
</head>

<?php

include './config/config.php';
include './config/opendb.php';

$result = mysql_query("SELECT * FROM Kontoplan") 
or die(mysql_error());  

echo "<table border='0'>";
echo "<tr> <th>Kontonr</th> <th>Kontonavn</th> <th>Kontotype</th> <th>Saldo</th></tr>";
while($row = mysql_fetch_array( $result )) {

	echo "<tr><td>"; 
	echo $row['Kontonummer'];
	echo "</td><td>"; 
	echo $row['Kontonavn'];
	echo "</td><td>";
                echo $row['Kontotype'];
	echo "</td><td>";
                echo $row['Saldo'];
	echo "</td><td></tr>";
} 

echo "</table>";

include './config/closedb.php';

?>
</html>
My question is: Is there a simple way to make a direct link from the result of the query to edit posts in the table?

Re: Mysql edit

Posted: Tue Nov 22, 2011 1:23 pm
by manohoo
2 ways to go about it: PHP or MySQL
I prefer MySQL, assume that the hyperlink field is 'name' and the target file is 'details.php':

Code: Select all

$query = "
   SELECT concat('<a href=details.php?name=',name,'>',name,'</a>') as link
   FROM table
";