Advertisement
| 10.04.2008 at 04:52PM PDT, ID: 23787949 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: |
==================================== pagination_code_only.php
<head>
<link rel="stylesheet" media="all" type="text/css" href="css/tasks.css" />
<link rel="stylesheet" media="all" type="text/css" href="css/main_page_styles.css" />
<script src="js/sorttable.js" type="text/javascript"></script>
<script src="js/showhide_div.js" type="text/javascript"></script>
<?php
include ("connectiondb.php");
$tbl_tasks="currenttasks_ctk";
$tbl_projects="projects_pro";
?>
</head>
<body>
<center><h3>Tasks Database</h3></center>
<?php
/* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Pagination Section:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx */
/*******************************************************************************
1: Get the required page number:
*******************************************************************************/
if (isset($_GET['pageno'])) {
$pageno = $_GET['pageno'];
} else {
$pageno = 1;
}
echo "The current page number is: " . $pageno . "<br>";
/*******************************************************************************
2: Identify how many database rows are available:
This code will count how many rows will satisfy the current query.
*******************************************************************************/
$query="SELECT count(*) FROM `$tbl_tasks`, `$tbl_projects` where fk_id_pro_ctk = id_pro order by id_ctk asc";
$result = mysql_query($query);
$query_data = mysql_fetch_row($result);
$numrows = $query_data[0];
echo "The number of rows is: " . $numrows;
/*******************************************************************************
3: Calculate the number of the $lastpage:
This code uses the values in $rows_per_page (that you specify you want to show)
and $numofrows in order to identify the number of the last page.
*******************************************************************************/
$rows_per_page = 15;
$lastpage = ceil($numrows/$rows_per_page);
echo "The value of the last page in this case will be: " . $lastpage . "<br>";
/*******************************************************************************
4: Ensure that $pageno is within range:
This code checks that the value of $pageno is an integer between 1 and $lastpage
*******************************************************************************/
$pageno = (int)$pageno;
if ($pageno > $lastpage) {
$pageno = $lastpage;
}
if ($pageno < 1) {
$pageno = 1;
}
/*******************************************************************************
5: Construct LIMIT clause eg. How many rows to view for each page. eg. 10
This code will construct the LIMIT clause for the sql SELECT statement.
*******************************************************************************/
$limit = 'LIMIT' . ($pageno - 1) * $rows_per_page . ',' . $rows_per_page;
/*******************************************************************************
6. Issue the database query:
*******************************************************************************/
// This has been done already as below:
$query="SELECT * FROM `$tbl_tasks`, `$tbl_projects` where fk_id_pro_ctk = id_pro order by id_ctk asc $limit";
$result=mysql_query($query);
/*******************************************************************************
7. Construct pagination hyperlinks:
Finally, we must construct the hyperlinks which will allow the user to SELECT
other pages. We start with the links for any previous pages.
*******************************************************************************/
// a) If on page 1, it wont provide hyperlinks (yet), it will just echo FIRST PREV
if ($pageno == 1) {
echo " FIRST PREV ";
} else {
printf("<a href='%s'>FIRST</a>", "{$_SERVER['PHP_SELF']}?pageno=1");
$prevpage = $pageno-1;
printf("<a href='%s'>PREV</a>", "{$_SERVER['PHP_SELF']}?pageno={$prevpage}");
}
// b) We now inform the user of his current position in the sequence of available pages:
echo " ( Page $pageno of $lastpage ) ";
// c) This code will provide the links for any following pages:
if ($pageno == $lastpage) {
echo " NEXT LAST ";
} else {
$nextpage = $pageno+1;
printf("<a href='%s'>NEXT</a>", "{$_SERVER['PHP_SELF']}?pageno=$nextpage");
printf("<a href='%s'>LAST</a>", "{$_SERVER['PHP_SELF']}?pageno=$lastpage");
}
?>
==================================== display_records_only.php
<head>
<link rel="stylesheet" media="all" type="text/css" href="css/tasks.css" />
<link rel="stylesheet" media="all" type="text/css" href="css/main_page_styles.css" />
<script src="js/sorttable.js" type="text/javascript"></script>
<script src="js/showhide_div.js" type="text/javascript"></script>
<?php
include ("connectiondb.php");
$tbl_tasks="currenttasks_ctk";
$tbl_projects="projects_pro";
?>
</head>
<body>
<center><h3>Tasks Database</h3></center>
<!-- START OF DISPLAY RECORDS: on its own, the following displays all records no problem ############# -->
<?php
$query="SELECT * FROM `$tbl_tasks`, `$tbl_projects` where fk_id_pro_ctk = id_pro order by id_ctk asc $limit";
$result=mysql_query($query);
$numrows=mysql_num_rows($result);
?>
<table id="table_sort_all" class="sortable">
<thead><tr><td><b>ID</b></td><td><b>Task Name</b></td><td><b>Project</b></td><td><b>Description</b></td></tr></thead>
<tbody>
<?php
for ($i=0; $i < $numrows; $i++) {
$rows=mysql_fetch_array($result); // get a row from our result set
if($i % 2) { // if there is a remainder
?>
<tr class="altRow_0">
<?php
}
else { // if there is not a remainder we will do the else ?>
<tr class="altRow_1">
<?php
} ?>
<td id="viewtasksidall"><?php echo $rows['id_ctk']; ?></td>
<td id="viewtasksnameall"><?php echo stripslashes($rows['name_ctk']); ?></td>
<td id="viewtasksprojectall"><?php echo stripslashes($rows['name_pro']); ?></td>
<td id="viewtasksdescriptionall"><?php echo $rows['description_ctk']; ?></td>
</tr> <?php } ?>
</tbody>
<tfoot></tfoot>
</table>
<!-- END OF DISPLAY RECORDS: ############# -->
</body>
==================================== both_pagination_and_records.php
<head>
<link rel="stylesheet" media="all" type="text/css" href="css/tasks.css" />
<link rel="stylesheet" media="all" type="text/css" href="css/main_page_styles.css" />
<script src="js/sorttable.js" type="text/javascript"></script>
<script src="js/showhide_div.js" type="text/javascript"></script>
<?php
include ("connectiondb.php");
$tbl_tasks= "currenttasks_ctk";
$tbl_projects="projects_pro";
?>
</head>
<body>
<center><h3>Tasks Database</h3></center>
<?php
/* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Pagination Section:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx */
/*******************************************************************************
1: Get the required page number:
*******************************************************************************/
if (isset($_GET['pageno'])) {
$pageno = $_GET['pageno'];
} else {
$pageno = 1;
}
echo "The current page number is: " . $pageno . "<br>";
/*******************************************************************************
2: Identify how many database rows are available:
This code will count how many rows will satisfy the current query.
*******************************************************************************/
$query="SELECT count(*) FROM `$tbl_tasks`, `$tbl_projects` where fk_id_pro_ctk = id_pro order by id_ctk asc";
$result = mysql_query($query);
$query_data = mysql_fetch_row($result);
$numrows = $query_data[0];
echo "The number of rows is: " . $numrows;
/*******************************************************************************
3: Calculate the number of the $lastpage:
This code uses the values in $rows_per_page (that you specify you want to show)
and $numofrows in order to identify the number of the last page.
*******************************************************************************/
$rows_per_page = 15;
$lastpage = ceil($numrows/$rows_per_page);
echo "The value of the last page in this case will be: " . $lastpage . "<br>";
/*******************************************************************************
4: Ensure that $pageno is within range:
This code checks that the value of $pageno is an integer between 1 and $lastpage
*******************************************************************************/
$pageno = (int)$pageno;
if ($pageno > $lastpage) {
$pageno = $lastpage;
}
if ($pageno < 1) {
$pageno = 1;
}
/*******************************************************************************
5: Construct LIMIT clause eg. How many rows to view for each page. eg. 10
This code will construct the LIMIT clause for the sql SELECT statement.
*******************************************************************************/
$limit = 'LIMIT' . ($pageno - 1) * $rows_per_page . ',' . $rows_per_page;
/*******************************************************************************
6. Issue the database query:
*******************************************************************************/
// This has been done already as below:
$query="SELECT * FROM `$tbl_tasks`, `$tbl_projects` where fk_id_pro_ctk = id_pro order by id_ctk asc $limit";
$result=mysql_query($query);
/*******************************************************************************
7. Construct pagination hyperlinks:
Finally, we must construct the hyperlinks which will allow the user to SELECT
other pages. We start with the links for any previous pages.
*******************************************************************************/
// a) If on page 1, it wont provide hyperlinks (yet), it will just echo FIRST PREV
if ($pageno == 1) {
echo " FIRST PREV ";
} else {
printf("<a href='%s'>FIRST</a>", "{$_SERVER['PHP_SELF']}?pageno=1");
$prevpage = $pageno-1;
printf("<a href='%s'>PREV</a>", "{$_SERVER['PHP_SELF']}?pageno={$prevpage}");
}
// b) We now inform the user of his current position in the sequence of available pages:
echo " ( Page $pageno of $lastpage ) ";
// c) This code will provide the links for any following pages:
if ($pageno == $lastpage) {
echo " NEXT LAST ";
} else {
$nextpage = $pageno+1;
printf("<a href='%s'>NEXT</a>", "{$_SERVER['PHP_SELF']}?pageno=$nextpage");
printf("<a href='%s'>LAST</a>", "{$_SERVER['PHP_SELF']}?pageno=$lastpage");
}
?>
<!-- START OF DISPLAY RECORDS: on its own, the following displays all records no problem ############# -->
<?php
$query="SELECT * FROM `$tbl_tasks`, `$tbl_projects` where fk_id_pro_ctk = id_pro order by id_ctk asc $limit";
$result=mysql_query($query);
// $numrows=mysql_num_rows($result);
?>
<br>
<table id="table_sort_all" class="sortable">
<thead><tr><td><b>ID</b></td><td><b>Task Name</b></td><td><b>Project</b></td><td><b>Description</b></td></tr></thead>
<tbody>
<?php
for ($i=0; $i < $numrows; $i++) {
$rows=mysql_fetch_array($result);
if($i % 2) { // if there is a remainder
?>
<tr class="altRow_0">
<?php
}
else { // if there is not a remainder we will do the else ?>
<tr class="altRow_1">
<?php
}?>
<td id="viewtasksidall"><?php echo $rows['id_ctk']; ?></td>
<td id="viewtasksnameall"><?php echo stripslashes($rows['name_ctk']); ?></td>
<td id="viewtasksprojectall"><?php echo stripslashes($rows['name_pro']); ?></td>
<td id="viewtasksdescriptionall"><?php echo $rows['description_ctk']; ?></td>
</tr> <?php } ?>
</tbody>
<tfoot></tfoot>
</table>
<!-- END OF DISPLAY RECORDS: ############# -->
</body>
|
Advertisement