PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE firsttable(id bigint); CREATE TABLE secondtable(id bigint);
Copy Clear
Copy Format Clear
<?php function random_num($length) { $text = ""; if($length < 5) { $length = 5; } $len = rand(4,$length); for ($i=0; $i < $len; $i++) { $text .= rand(0,9); } return $text; } $id = random_num(20); echo "random number is $id".PHP_EOL; $query = "insert into firsttable (id) values ('$id')"; mysqli_query($mysqli, $query); $query2 = "insert into secondtable (id) values ('$id')"; mysqli_query($mysqli, $query2); $query3 = "select * FROM firsttable"; $result = mysqli_query($mysqli, $query3); $row = mysqli_fetch_assoc($result); echo "First table: ".$row["id"]; echo PHP_EOL; $query4 = "select * FROM secondtable"; $result2 = mysqli_query($mysqli, $query4); $row2 = mysqli_fetch_assoc($result2); echo "Second table: ".$row2["id"]; echo PHP_EOL;
Show:  
Copy Clear