<html> <head> <title>Formhtml</title> </head> <body> <form name="cucak" method="post" action="action.php"> Name:<br> <input name="name" type="text" size="25"><br> Surname:<br> <input name="surname" type="text" size="25"><br> Email:<br> <input name="email" type="text" size="25"><br> <input type="submit" value="Ok"> </form> </body> </html> 

This is my html form.

 <html> <head><title>Formhtml</title></head> </html> <?php $db_hostname='localhost'; $db_database='formtest'; $db_username='root'; $db_password=''; $db_server=mysql_connect($db_hostname, $db_username, $db_password); if(!$db_server) die ("unable to connect mysql:".mysql_error()); mysql_select_db($db_database) or die("unable to select database".mysql_error()); if(isset($_POST['name'])) $Name=$_POST['name']; if(isset($_POST['surname'])) $Surname=$_POST['surname']; if(isset($_POST['email'])) $Email=$_POST['email']; echo "Your name is: $Name<br/> Your surname is: $Surname<br/> Your email is: $Email<br/>"; $query="INSERT INTO basa(name, surname, email) VALUES('$Name','$Surname','$Email')"; $result=mysql_query($query); if(!$result) die("error to connect date base: ".mysql_error()); $fh=fopen("textfile.txt",'a+') or die("file didn't create"); $text=" Your name is: $Name Your surname is: $Surname Your email is: $Email"; fwrite($fh,$text) or die("error"); fclose($fh); ;?> 

And this is the action.php program. How can I display the database files as a list on the browser page?

  • 2
    Correct the content, remove grammatical errors, separate the text from the code, reformulate. Nothing is clear. - stck
  • 2
    and explain normally what it means - "How can I display database files as a list on the browser page" and what exactly is "database files" - Grimon

1 answer 1

I join, form a normal question please ...
But I venture to show extrasensory abilities

 $result = mysql_query('SELECT * FROM table'); $data = array() // создаем массив чтобы в него положить результат mysql выборки while($row = mysql_fetch_assoc($result)) { //функция mysql_query возвращает данные типа resource, //соответственно нам необходимо преобразовать их в данные //с которыми можно работать, например в массив //о функции mysql_fetch_assoc() можете почитать на php.net //мне лениво так все описывать $data[] = $row; } //теперь в массиве $data у нас лежит результат выборки с БД // ну собственно что вы с этими данными будете делать дело ваше //для примера расспечатаем print_r($data); 

if this is not what you asked for - rewrite the question normally, I answered as I understood