PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE OwlypiaSCTopics ( Id INT AUTO_INCREMENT PRIMARY KEY, TopicNo INT, Age varchar(10), Topic varchar(255) UNIQUE ); INSERT INTO OwlypiaSCTopics VALUES (1, 1, "OWLIN", "OWLIN-1"); INSERT INTO OwlypiaSCTopics VALUES (2, 2, "OWLIN", "OWLIN-2"); INSERT INTO OwlypiaSCTopics VALUES (3, 3, "OWLIN", "OWLIN-3"); INSERT INTO OwlypiaSCTopics VALUES (4, 4, "OWLIN", "OWLIN-4");
Copy Clear
Copy Format Clear
<?php use Carbon\Carbon; $now = Carbon::now()->format('d/m/Y'); printf("Today is %s\nCurrent PHP version: %s \n\n", $now, phpversion()); $query = "SELECT VERSION() as version;"; // get DB version using PDO $stmt = $pdo->prepare($query); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_ASSOC); printf('DB version (PDO): %s ' . PHP_EOL, $row['version']); // Run query using mysqli $result = $mysqli->query($query); $version = $result->fetch_object(); printf('DB version (mysqli): %s ' . PHP_EOL, $version->version); $sql = 'SELECT Topic FROM OwlypiaSCTopics Where Age = "OWLIN" ORDER BY RAND() LIMIT 3'; $results = $mysqli->query($sql); $arr = $results->fetch_all(); $jsonString = '{"Room1":["OWLIN-3","OWLIN-1","OWLIN-4"]}'; if (true) { $topicsArray = json_decode($jsonString, true)[str_replace(' ', '', "Room 1")]; $topics = []; for ($x = 0; $x < sizeof($topicsArray); $x++) { $topics[$x] = array($topicsArray[$x]); } print_r(count($topicsArray)); } else { echo "false"; }
Show:  
Copy Clear