claro Posted October 19, 2011 Share Posted October 19, 2011 Hi there! I'm trying to put 2 variables using href. Ive got it already, but when I tried to insert the page=1, which is the the variable for my paginated code.It doesn't work. When I used the codes below, from other page (I don't used variable) it works <a href='module_viewpaginated.php?page=1' but when I used this code, I've got the variable $course and $program, but I don't know how to insert page for my pagination <a href='module_viewpaginated.php?course=".$courseid."&program=".$program." ' I hope my problem is clear. I want to combine the two. Any help would be greatfull!! Link to comment https://forums.phpfreaks.com/topic/249371-href-variables/ Share on other sites More sharing options...
voip03 Posted October 19, 2011 Share Posted October 19, 2011 You can Try echo "<a href='module_viewpaginated.php?course=".$courseid."&program=".$program." '>link</a>'"; Link to comment https://forums.phpfreaks.com/topic/249371-href-variables/#findComment-1280429 Share on other sites More sharing options...
claro Posted October 19, 2011 Author Share Posted October 19, 2011 Here is my actual code. I need to insert the Quote 'module_viewpaginated.php?page=1' echo "<p><b>View All</b> | <a href='module_viewpaginated.php?course=".$courseid."&program=".$program." ' target='lama'>View Paginated</a></p>"; Link to comment https://forums.phpfreaks.com/topic/249371-href-variables/#findComment-1280432 Share on other sites More sharing options...
voip03 Posted October 19, 2011 Share Posted October 19, 2011 Quote Here is my actual code. I need to insert the Quote 'module_viewpaginated.php?page=1' echo "<p><b>View All</b> | <a href='module_viewpaginated.php?course=".$courseid."&program=".$program." ' target='lama'>View Paginated</a></p>"; To Where? Link to comment https://forums.phpfreaks.com/topic/249371-href-variables/#findComment-1280436 Share on other sites More sharing options...
voip03 Posted October 19, 2011 Share Posted October 19, 2011 try to echo the $courseid and $program Link to comment https://forums.phpfreaks.com/topic/249371-href-variables/#findComment-1280443 Share on other sites More sharing options...
claro Posted October 19, 2011 Author Share Posted October 19, 2011 Below are my actual codes for pagination. I can echo the $course and $program already. <?php $course1 = $_GET['course']; //from selection box $program = $_GET['program'];//from selection box //my queries here $courses = mysql_query ("SELECT * FROM tbl_course WHERE course_Id = '$course1'") or die (mysql_error()); // connect to the database include('connect-db.php'); // number of results to show per page $per_page = 1; // figure out the total pages in the database echo "<br></br>"; echo "<td><b> Course: <i>".$course."</i></b></td><br/>"; echo "<td><b> Program: <i>".$program." "."Class</b></i></td>"; if (mysql_num_rows($result)> 0 ) { $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='module2.php'>View All</a> | <b>View Page:</b> "; for ($i = 1; $i <= $total_pages; $i++) { echo "<a href='view-paginated_admin.php?course=".$courseid."&program=".$program."'>$i</a> "; } echo "</p>"; // display data in table echo "<table border='1' cellpadding='10'>"; echo "<tr>"; echo "<td></td><td></td><td></td><td></td><th>Student's Name</th><th>Year</th><th>Cleared</th><th>Not Cleared</th>"; echo "</tr>"; // loop through results of database query, displaying them in the table for ($i = $start; $i < $end; $i++) { // make sure that PHP doesn't try to show results that don't exist if ($i == $total_results) { break; } // echo out the contents of each row into a table //data data echo " <input type='submit' name = 'Submit' value='Submit'>"; } } else { echo "<br/><br/>no students enrolled"; } // close table> echo "</table>"; ?> Link to comment https://forums.phpfreaks.com/topic/249371-href-variables/#findComment-1280477 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.