PHP SOLUTIONS: DYNAMIC (Php web hosting) WEB DESIGN MADE EASY 2.

PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY 2. You now need to run the new SQL query. The code goes immediately after the code in the preceding step, but differs according to the type of MySQL connection. If you re using the original MySQL extension, add this: // submit query and store result as $totalPix $total = mysql_query($getTotal); $row = mysql_fetch_row($total); $totalPix = $row[0]; This introduces a new function, mysql_fetch_row(), which gets a single record from a result set as an indexed array (one that refers to elements by numbers). The result of SELECT COUNT(*) contains just one field, so you access it as $row[0]. For MySQL Improved, use this: // submit query and store result as $totalPix $total = $conn->query($getTotal); $row = $total->fetch_row(); $totalPix = $row[0]; This uses the MySQLI equivalent of mysql_fetch_row() just described. The result set for the query has been saved as $total, so $total->fetch_row() gets the record as an indexed array. For PDO, use this: // submit query and store result as $totalPix $total = $conn->query($getTotal); $row = $total->fetchColumn(); $totalPix = $row[0]; $total->closeCursor(); This is the same as in the previous chapter, using fetchColumn() to get a single result, and closeCursor() to free the database connection for the next query. 3. Next, set the value of $curPage. The navigation links that you will create later pass the value of the required page through a query string, so you need to check whether curPage has been set in the $_GET array. If it has, use that value. Otherwise, set the current page to 0. Insert the following code immediately after the code in the previous step: // set the current page $curPage = isset($_GET[’curPage’]) ? $_GET[’curPage’] : 0; This uses the conditional operator (see Chapter 3). If you find the conditional operator hard to understand, use the following code instead. It has exactly the same meaning. if (isset($_GET[’curPage’])) { $curPage = $_GET[’curPage’]; } else { $curPage = 0; }
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

Leave a Reply