Ciao ragazzi,

sn alle prime armi con php/mysql !

stavo scrivedno qualcosina per esercitarmi. Lo scopo che mi sono posto è quello di inserire tramite un form dei dati in un database e poi visualizzarli in un altra pagina !
Bene questa prova è andata a buon fine!

ho complicato un tantino la cosa, inserisco i dati sempre dallo tesso form però voglio che quello che ho inserito in precedenza vada in pace e rimanga solo l'ultimo appena inserito !

POSTO le pagine usate

FILE: Ndbconnect.php
Codice PHP:
<?php
mysql_connect
("localhost","root","") or
    die(
"Could not connect to database");
mysql_select_db("news") or
    die(
"Could not select the database");
?>

FILE: create_news.php
Codice PHP:
<?php
include ("Ndbconnect.php");
    
$azione $_POST['azione'];
    
$news $_POST['news'];
    if(
$azione==$aggiorna){
                
$query="UPDATE notizie SET testo='$news'";
                
mysql_query($query) or die (mysql_error());
                echo 
"<a href=\"admin.php\">NEWS AGGIORNATA >>> TORNA</a>";
                
$mod=mysql_affected_rows();
                echo (
"

$mod");}
    else{echo 
"Errore: nessun parametro ricevuto ! ! ! !";}
?>

FILE: new_news.php
Codice PHP:
<html>
<
body>
<
h2>Gestisci News</h2>
<
form method=post action="create_news.php" enctype="multipart/form-data">
<
table>
    <
tr>
        <
td width="79" height="101" valign="top">Inserire nel campo di testo qui di fiancole news !</td>
        <
td width="375" valign="top"><textarea cols=60 rows=6 name=news>testo</textarea></td>
    </
tr>
</
table>
    <
input type=submit name=azione value="aggiorna">
    <
input type=reset name=reset value="annulla">
</
form>    
</
body>
</
html

FILE: notizie.php
Codice PHP:
<html>
<head>
<title>NEWS</title>
</head>
<body>
<?php
    
include ("Ndbconnect.php");
?>
<table>
<tr>
<td>NOTIZIE:
<?php 
$query 
"SELECT testo FROM notizie WHERE testo!=0";
$result mysql_query ($query);
$name_row mysql_fetch_row($result);
if(
$name_row){
echo(
"$name_row[0]");}
else{
echo (
"non c siamo");
}
?>
</td>
</tr>
</table>
</body>
</html>
Grazie a quanti mi aiuteranno ! ! !