note 79632 deleted from ref.session by nlopess

From: Date: Thu, 06 Dec 2007 11:16:43 +0000
Subject: note 79632 deleted from ref.session by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-132886@lists.php.net to get a copy of this message
Note Submitter: Insomnia ---- <?php session_start(); $_SESSION['fasz']=1; $link = mysql_connect('localhost', 'proba', 'hope') or die("Could not connect: " . mysql_error()); echo "Connected successfully<br/>"; $query = "DROP DATABASE mydb"; if( mysql_query($query) ) { echo "Toroltem a mydb adatbazist"; } else { echo "Nem tudtam torolni a mydbt metr nem létezik"; } $query = "CREATE DATABASE mydb"; if( mysql_query($query) ) { echo "DB Created successfully."; } else { echo "DB not created, error: " . mysql_error(); } // kivalsztás mysql_select_db('mydb') or die("Could not select database"); echo "<br/>DB selected successfully.<br/>"; //dropping table auto, no errorhandling $query = "DROP TABLE auto"; if ( mysql_query($query) ) { echo "Sikerult eldobni az auto tablat"; } else { echo "Nem tudtam eldobni, mert nem létezik bazdmeg: ".mysql_error(); } $query = " CREATE TABLE auto ( rendszam char(7) NOT NULL, PRIMARY KEY(rendszam), tipus varchar(30), evjarat int(4) ) "; //sending the mysql query if( mysql_query($query) ) { echo "Table auto created successfully."; } else { echo "Table auto not created, error: " . mysql_error(); } $q="INSERT INTO auto VALUES ('GVE-200','Fiat','".rand(1997,2000)."')"; mysql_query($q); $q="INSERT INTO auto VALUES ('DEE-200','Fiat','".rand(1997,2000)."')"; mysql_query($q); $q="INSERT INTO auto VALUES ('ASD-300','Punto','".rand(1997,2000)."')"; mysql_query($q); ?> <table> <tr> <td>Rendszám</td> <td>Gyártmány</td> <td>Évjárat</td>> </tr> <? $q="SELECT * FROM auto ORDER BY evjarat"; $r=mysql_query($q); for ($i=0;$i<mysql_num_rows($r);$i++) { $rendszam=mysql_result($r,$i,rendszam); $tipus=mysql_result($r,$i,tipus); $evjarat=mysql_result($r,$i,evjarat); ?> <tr> <td><?=$rendszam?></td> <td><? echo $tipus; ?></td> <td><?=$evjarat?></td> </tr> <? echo "<TR>"; echo "<TD>$rendszam</TD>"; echo "<TD>$tipus</TD>"; echo "<TD>$evjarat</TD>"; echo "</TR>"; } ?> </table> <? $n=5; $q = " CREATE TABLE tabla ("; for ($i=0;$i<$n;$i++) { $q.="oszlop".$i." int(4) "; if ($i<$n-1) $q.=", "; } $q.=" ) "; echo $q; mysql_query($q); for ($i2=0;$i2<$n;$i2++) { $q="INSERT INTO tabla VALUES ("; for ($i=0;$i<$n;$i++) { $q.="'".rand(1000,9999)."'"; if ($i<$n-1) $q.=", "; } $q.=")"; mysql_query($q); } // Closing connection mysql_close($link); ?> <A href="sample3.php">lépés a másik oldalra</A>

« previous php.notes (#132886) next »