note 79633 added to function.shuffle
| From: | Insomnia at osu1 dot php dot net | Date: | Thu, 06 Dec 2007 05:56:24 +0000 |
| Subject: | note 79633 added to function.shuffle | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132875@lists.php.net to get a copy of this message | ||
<?php
function MY_SEL($query)
{
$ret="";
$ret.= "<hr><table border=1>";
$result=mysql_query($query);
$fejlec=true;
while($sor = mysql_fetch_assoc($result))
{
if($fejlec)
{
$fejlec=false;
$ret.= "<tr>";
foreach($sor as $k => $e)
{
$ret.= "<td>".$k."</td>";
}
$ret.= "</tr>";
}
$ret.= "<tr>";
foreach($sor as $k => $e)
{
$ret.= "<td>".$e."</td>";
}
$ret.= "</tr>";
}
$ret.= "</table>";
return $ret;
}
// Connecting, selecting database
$link = mysql_connect('localhost', 'proba', 'l')
or die("Could not connect: " . mysql_error());
echo "Connected successfully<br/>";
//dropping mydb database, no errorhandling
$query = "DROP DATABASE mydb";
if( mysql_query($query)){
echo "sikerült törölni mydb<br>";
}else{
echo "nem siekrült". mysql_error();
}
//creating mydb database with errorhandling
$query = "CREATE DATABASE mydb";
if( mysql_query($query) ) {
echo "DB Created successfully.";
} else {
echo "DB not created, error: " . mysql_error();
}
//You must select the db before launching any db-related queries
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 "Dropped auto table.";
}else{
echo "No table to drop: " . mysql_error() . "<br>";
}
$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 "Késza tábla.";
} else {
echo "No tabla no sister: " . mysql_error();
}
echo "<br>";
$q="INSERT INTO auto VALUES
('GVE-200','Fiat',".rand(1995,2007).")";
mysql_query($q);
$kuszob=date("n");
echo "Dátum baszod: " . $kuszob . "<br>";
$front = 'AAABBBCCCDDDEEEFFFGGGHHHJJJ';
$back = '00111222333444555666777888999';
for($i=0; $i<3; $i++)
{
$query="INSERT INTO auto VALUES ('". substr(str_shuffle($front),0,3) ."-".
substr(str_shuffle($back),0,3) ."','Lada',".rand(1995,2007).")";
mysql_query($query);
}
for($i=0; $i<3; $i++)
{
$query="INSERT INTO auto VALUES ('". substr(str_shuffle($front),0,3) ."-".
substr(str_shuffle($back),0,3)
."','Mazaretti',".rand(1995,2007).")";
mysql_query($query);
}
for($i=0; $i<3; $i++)
{
$query="INSERT INTO auto VALUES ('". substr(str_shuffle($front),0,3) ."-".
substr(str_shuffle($back),0,3)
."','Polski',".rand(1995,2007).")";
mysql_query($query);
}
$query="SELECT * FROM auto";
echo MY_SEL($query);
$query="UPDATE auto SET tipus='skoda' WHERE evjarat<2000";
if( mysql_query($query) ) {
echo "SIKERÃLT a update";
}else{
echo "NOT siekrült a update";
}
$query="SELECT * FROM auto ";
echo MY_SEL($query);
echo "<br>";
$query="DELETE FROM auto WHERE tipus LIKE 'skoda'";
if( mysql_query($query) ) {
echo "SIKERÃLT a törlés";
}else{
echo "NOT siekrült a törlés";
}
$query="SELECT * FROM auto";
echo MY_SEL($query);
// Closing connection
mysql_close($link);
?>
----
Server IP: 195.56.193.13
Probable Submitter: 84.3.18.143
----
Manual Page -- http://www.php.net/manual/en/function.shuffle.php
Edit -- https://master.php.net/note/edit/79633
Del: integrated -- https://master.php.net/note/delete/79633/integrated
Del: useless -- https://master.php.net/note/delete/79633/useless
Del: bad code -- https://master.php.net/note/delete/79633/bad+code
Del: spam -- https://master.php.net/note/delete/79633/spam
Del: non-english -- https://master.php.net/note/delete/79633/non-english
Del: in docs -- https://master.php.net/note/delete/79633/in+docs
Del: other reasons-- https://master.php.net/note/delete/79633
Reject -- https://master.php.net/note/reject/79633
Search -- https://master.php.net/manage/user-notes.php