Expand|Select|Wrap|Line Numbers
- <html>
- <head>
- <style type="text/css">
- A:link {text-decoration: none}
- A:visited {text-decoration: none}
- A:active {text-decoration: none}
- A:hover {text-decoration: underline overline; color: red;}
- table.second { margin-top:20px; margin-bottom:0px;}
- </style>
- <title>Implementing Paging with next and prev</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- </head>
- <body bgcolor="#99CC99">
- <table width="60%" align="center" bgcolor="#009966"><tr>
- <td><a href="insert.php">Veri Gir</a></td>
- <td><a href="query.php">Veri Görüntüle</a></td>
- <td><a href="search.php"> Veri Ara </a></td>
- <td><a href="update.php"> Veri Güncelle </a></td>
- <td><a href="logout.php"> Ç?k?? </a></td>
- </tr></table>
- <?php
- include 'connect.php';
- $orderby = $_POST['orderby'];
- $type = $_POST['type'];
- if (isset($orderby)) {
- echo "orderby is set\n";
- } else {
- echo "orderby is not set\n";
- }
- if (isset($type)) {
- echo "type is set\n";
- } else {
- echo "type is not set\n";
- }
- // how many rows to show per page
- $rowsPerPage = 5;
- // by default we show first page
- $pageNum = 1;
- // if $_GET['page'] defined, use it as page number
- if(isset($_GET['page']))
- {
- $pageNum = $_GET['page'];
- }
- // counting the offset
- $offset = ($pageNum - 1) * $rowsPerPage;
- $query = " SELECT * FROM Kunde ORDER BY $orderby" .
- " LIMIT $offset, $rowsPerPage";
- $result = mysql_query($query) or die('Error, query failed');
- // start of the query *******************************************************************************
- ?>
- <div><table class='second' border='1'><tr><td>ID</td><td>?sim Soyad</td><td>Firma</td><td>S?n?f</td><td>Ürünler</td><td>Adres</td><td>?ehir</td><td>Ülke</td><td>Türü</td><td>?? Telefonu</td><td>Fax</td><td>Cep</td><td>Mail</td><td>Web</td><td>Tarih</td></b></tr>
- <?php
- while($row = mysql_fetch_array($result))
- {
- ?>
- <tr><td><?php echo $row['KundeID']; ?> </td>
- <td> <?php echo $row['KundeVorName']." ".$row['KundeNachName']; ?> </td>
- <td> <?php echo $row['KundeFirma']; ?> </td>
- <td> <?php echo $row['KundeKategorie']; ?> </td>
- <td> <?php echo $row['KundeProdukte']; ?> </td>
- <td> <?php echo $row['KundeAdresse']; ?> </td>
- <td> <?php echo $row['KundeOrt']; ?> </td>
- <td> <?php echo $row['KundeLand']; ?> </td>
- <td> <?php echo $row['KundeArt']; ?> </td>
- <td> <?php echo $row['KundeFestnetz']." "; ?> </td>
- <td> <?php echo $row['KundeFax']." "; ?> </td>
- <td> <?php echo $row['KundeMobile']." "; ?> </td>
- <td> <?php $mail = $row['KundeMail']; ?><a href="mailto:<?php echo "$mail"; ?>"><?php echo $row['KundeMail']." "; ?> </a></td>
- <td> <?php $web = $row['KundeWeb']; ?> <a href="http://<?php echo "$web"; ?>" Target="blank"> <?php echo $row['KundeWeb']." "; ?></a> </td>
- <td> <?php echo $row['KundeRegDatum']." "; ?> </td></tr>
- <?php } ?>
- </table>
- <?php
- // end of the query *******************************************************************************
- // how many rows we have in database
- $query = "SELECT COUNT(KundeID) AS numrows FROM Kunde ";
- $result = mysql_query($query) or die('Error, query failed');
- $row = mysql_fetch_array($result, MYSQL_ASSOC);
- $numrows = $row['numrows'];
- // how many pages we have when using paging?
- $maxPage = ceil($numrows/$rowsPerPage);
- // print the link to access each page
- $self = $_SERVER['PHP_SELF'];
- $nav = '';
- for($page = 1; $page <= $maxPage; $page++)
- {
- if ($page == $pageNum)
- {
- $nav .= " $page "; // no need to create a link to current page
- }
- else
- {
- $nav .= " <a href=\"$self?page=$page\">$page</a> ";
- }
- }
- // creating previous and next link
- // plus the link to go straight to
- // the first and last page
- if ($pageNum > 1)
- {
- $page = $pageNum - 1;
- $prev = " <a href=\"$self?page=$page\">[Prev]</a> ";
- $first = " <a href=\"$self?page=1\">[First Page]</a> ";
- }
- else
- {
- $prev = ' '; // we're on page one, don't print previous link
- $first = ' '; // nor the first page link
- }
- if ($pageNum < $maxPage)
- {
- $page = $pageNum + 1;
- $next = " <a href=\"$self?page=$page\">[Next]</a> ";
- $last = " <a href=\"$self?page=$maxPage\">[Last Page]</a> ";
- }
- else
- {
- $next = ' '; // we're on the last page, don't print next link
- $last = ' '; // nor the last page link
- }
- // print the navigation link
- echo $first . $prev . $nav . $next . $last;
- // and close the database connection
- ?>
- </body>
- </html>
I get orderby is not set ,type is not set and query error messages.
How can I fix my problem with the variables?