Mysql edit

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
asai
Forum Commoner
Posts: 43
Joined: Tue May 04, 2010 6:24 am
Location: Norway

Mysql edit

Post 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?
User avatar
manohoo
Forum Contributor
Posts: 201
Joined: Wed Dec 23, 2009 12:28 pm

Re: Mysql edit

Post 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
";
 
Post Reply