Example #1
0
  <link rel='stylesheet' href='/css/index.css'>
  <?php 
include 'res/head.php';
?>
  <title>PC Masterratings</title>

</head>
<body>
  <?php 
include 'res/nav.php';
//if is post
if (isset($_POST['btnSearch'])) {
    $games = [];
    $limit = 10;
    try {
        $games = GBApi::searchForGames($_POST['txtSearch'], $limit);
    } catch (GBApiException $e) {
        //VERY rudimentary error handling - change this!!
        echo '<h3>', $e, '<h3>';
        exit;
    }
    $cols = 3;
    //change to whatever, but you'll have to mess with bootstrap classes to make it display properly
    $rows = ceil(count($games) / $cols);
    //Try to generate search results
    //This is a gross way of generating html
    echo "<h1>Results</h1>\n      <div class='container'>";
    for ($i = 0; $i < $rows; $i++) {
        echo "<div class='row'>";
        for ($k = 0; $k < $cols; $k++) {
            $index = $cols * $i + $k;