select estrarre i dati dal database - max4001976, per estrarre i dati contenuti nella tebella del nostro database - max4001976

« Older   Newer »
  Share  
max_400
view post Posted on 6/5/2011, 00:23     +1   -1






CODICE
<meta  http-equiv="Content-Type" content="text/html; charset=utf-8">

<?php

$query = "SELECT * FROM `nome_tabella`";

mysql_connect("localhost", "username", "password") or die ("Could not connect to database");
mysql_select_db("my_username") or die ("Connot select database");
$risultato = mysql_query($query) or die (mysql_error());

echo "<table border=1 width=\"50%\">";
echo "<tr>";

for($i =1; $i <= mysql_num_fields($risultato,$i); $i++)
  {
  echo "<td>".mysql_field_name($risultato, $i)."</td>";
  }
   
echo "<tr>";

while($fetch = mysql_fetch_array($risultato, $i))
    {
    echo "<tr>";
    foreach($fetch as $var)
           {
           echo "<td>".$var."</td>\n";
           }
    echo "</tr>";
    }

echo "</table>";

?>



per aggiungere le intestazioni nome citta punti modificate questa riga
for($i =1; $i <= mysql_num_fields($risultato,$i); $i++)

in
for($i =0; $i <= mysql_num_fields($risultato,$i); $i++)

se non dovessero comparire aggiungete altri 2 campi nella vostra tabella

tipo
nome, citta, punti, email, forum


 
Top
max_400
view post Posted on 17/2/2012, 03:20     +1   -1




quest č lo script per estrarre i dati dalla vostra tabella mentre con

INSERT INTO "table_name" ("column1", "column2", ...)
VALUES ("value1", "value2", ...)

inseriamo i dati sulla tabella. column1 ecc sono i campi nella nostra tabella
mentre value il valore che proviene dal nostro form
 
Top
1 replies since 6/5/2011, 00:23   43 views
  Share