Jump to content
Killersites Forums

farah

New Members
  • Posts

    3
  • Joined

  • Last visited

farah's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Thank you very much for your time and reading my question..thank you =D
  2. can you see my coding???i dnt knw how to use and where to put "limit" in my coding... <?php // connect to the database mysql_connect("localhost","root",""); mysql_select_db("hospital"); // number of results to show per page $per_page = 10; // figure out the total pages in the database if(isset($_POST['searchvalue2'])){ $searchtype=$_POST['searchtype2']; $searchvalue=$_POST['searchvalue2']; $result = mysql_query("SELECT patientname,RN,IC,age,gender,race,discipline,dateofincident,timeofincident,dateofreport,monthofreport,namastaff,brief,action,status,namelocation,category FROM registerstaff,location,incident WHERE $searchtype LIKE '%$searchvalue%' and location.id=registerstaff.location_id and incident.id=registerstaff.incident_id"; $total_results = mysql_num_rows($result); $total_pages = ceil($total_results / $per_page); // check if the 'page' variable is set in the URL (ex: view-paginated.php?page=1) if (isset($_GET['page']) && is_numeric($_GET['page'])) { $show_page = $_GET['page']; // make sure the $show_page value is valid if ($show_page > 0 && $show_page <= $total_pages) { $start = ($show_page -1) * $per_page; $end = $start + $per_page; } else { // error - show first set of results $start = 0; $end = $per_page; } } else { // if page isn't set, show first set of results $start = 0; $end = $per_page; } // display pagination echo "<p><a href='view.php'>View All</a> | <b>View Page:</b> "; for ($i = 1; $i <= $total_pages; $i++) { echo "<a href='view-paginated.php?page=$i'>$i</a> "; } echo "</p>"; // display data in table echo "<table border='1' cellpadding='10'>"; echo "<tr> <th>Patient's Name</th> <th>RN Number</th> <th>IC Number</th> <th>Age</th> <th>Gender</th> <th>Race</th> <th>Location</th><th>Discipline</th> <th>Date of Incident </th> <th>Time of Incident</th> <th>Date of Report</th> <th>Month of Report</th> <th>Staff Report</th><th>Incident Issue</th> <th>Brief</th> <th>Action</th> <th>Status</th></tr>"; // loop through results of database query, displaying them in the table for ($i = $start; $i < $end; $i++) //$result = mysql_query($sqlStatement) or die(mysql_error()); //$count = mysql_num_rows($result) or die(mysql_error()); { // make sure that PHP doesn't try to show results that don't exist if ($i == $total_results) { break; } //$result = mysql_query($sqlStatement) or die(mysql_error()); //$count = mysql_num_rows($result) or die(mysql_error()); // echo out the contents of each row into a table echo "<tr>"; echo '<td>' . mysql_result($result, $i, 'patientname') . '</td>'; echo '<td>' . mysql_result($result, $i, 'RN') . '</td>'; echo '<td>' . mysql_result($result, $i, 'IC') . '</td>'; echo '<td>' . mysql_result($result, $i, 'age') . '</td>'; echo '<td>' . mysql_result($result, $i, 'gender') . '</td>'; echo '<td>' . mysql_result($result, $i, 'race') . '</td>'; echo '<td>' . mysql_result($result, $i, 'location_id') . '</td>'; echo '<td>' . mysql_result($result, $i, 'discipline') . '</td>'; echo '<td>' . mysql_result($result, $i, 'dateofincident') . '</td>'; echo '<td>' . mysql_result($result, $i, 'timeofincident') . '</td>'; echo '<td>' . mysql_result($result, $i, 'dateofreport') . '</td>'; echo '<td>' . mysql_result($result, $i, 'monthofreport') . '</td>'; echo '<td>' . mysql_result($result, $i, 'namastaff') . '</td>'; echo '<td>' . mysql_result($result, $i, 'incident_id') . '</td>'; echo '<td>' . mysql_result($result, $i, 'brief') . '</td>'; echo '<td>' . mysql_result($result, $i, 'action') . '</td>'; echo '<td>' . mysql_result($result, $i, 'status') . '</td>'; // echo '<td><a href="edit.php?id=' . $row['id'] . '">Edit</a></td>'; // echo '<td><a href="delete.php?id=' . $row['id'] . '">Delete</a></td>'; echo "</tr>"; } // close table> echo "</table>"; // pagination ?>
  3. how do combine function "search" and "view-paginated"??
×
×
  • Create New...