$user = "******"; $pw = ""; $db = "cookbooknetwork"; $conn = new mysqli($server, $user, $pw, $db); if ($conn->connect_error) { echo 'Connection failed: ' . $conn->connect_error; } $sql = "\tSELECT recipe_id, recipe_title, rating FROM recipe WHERE recipe_id IN (SELECT DISTINCT(recipe_id) FROM flag)"; $result = $conn->query($sql); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $flagCount = getFlagCount($row["recipe_id"]); $title = $row["recipe_title"]; echo '<tr> <td><a href="flags_of_recipe.php?recipe_id=' . $row["recipe_id"] . '&flag_no=' . $flagCount . '&title=' . $title . '">' . $title . '</a></td> <td>' . printFlags($flagCount) . '</td> <td><img src="images/star' . $row["rating"] . '.png" /></td> </tr>'; } } else { echo '<h2>No Flags Found</h2>'; } $conn->close(); function getFlagCount($id) { $server = "localhost"; $user = "******"; $pw = ""; $db = "cookbooknetwork"; $conn = new mysqli($server, $user, $pw, $db); if ($conn->connect_error) {
<?php if (!Yii::$app->user->isGuest) { ?> <div id="logout"><?php echo Html::a(Html::img('@web/images/logout.png', array('alt' => 'logout', 'title' => Yii::t('messages', 'layout.logout'))), array('site/logout', 'lang' => $lang)); ?> </div> <?php } ?> <div id="home"><?php echo Html::a(Html::img('@web/images/home.png', array('alt' => 'home', 'title' => Yii::t('messages', 'layout.gobackmainsite'))), Yii::$app->urlManagerFrontEnd->baseUrl); ?> </div> <div id="flags"><?php printFlags($lang, $this->context->paramKeys, $this->context->paramValues, $this->context->languages); ?> </div> <?php if (!Yii::$app->user->isGuest) { ?> <div id="welcome"><?php echo Yii::t('messages', 'layout.welcome') . ' ' . Yii::$app->user->identity->username; ?> !</div> <?php } ?> <div class="clear"></div> </header> <nav>