Search the Community
Showing results for tags 'view'.
-
Good day Php Friends, i have manage to make a searchbox which displayed the student according to their first name. But after it is being displayed i added with view, edit, delete links. Now my problem is when i click the links it will not direct to the specific student. here are the code for your reference. Admin_Home.php </head> <?php include 'Header.php';?> <body> <script language="javascript" type="text/javascript"> function ajaxFunction(){ var ajaxRequest; try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); }catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); }catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); }catch (e){ alert("Your browser broke!"); return false; } } } ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var ajaxDisplay = document.getElementById('ajaxDiv'); ajaxDisplay.innerHTML = ajaxRequest.responseText; } } var first_name = document.getElementById('first_name').value; var queryString = "?first_name=" + first_name ; ajaxRequest.open("GET", "ajax.php" + queryString, true); ajaxRequest.send(null); } </script> <table width="547" align="center"> <tr> <td width="135"><button class="submit" type="submit"> <span class="style8"><a href="Admin_Home.php">Home</a> </button> </span></span></td> <td width="173"><button class='submit' type='submit'> <span class="style8"><a href="Admin_Add_Student.php">Add Learner </a> </button> </span></span></td> <td width="126"><button class="submit" type="submit"> <span class="style8"><a href="index.php">Logout</a> </button> </span></span></td> </tr> </table> <div class="center"> <form name='myForm' align='center'> <span class="style5">First Name:</span> <input type='text' id='first_name' class="lab" /> <input type='button' class="search" onclick='ajaxFunction()' value='Search Learner'/> </form> </div> <div class="style4" id='ajaxDiv'> </div> <p> </p> <p> </p> </body> </html> ajax.php include 'Connect.php'; //Connect to MySQL Server mysql_connect($host, $dbusername, $dbpassword); //Select Database mysql_select_db($dbname) or die(mysql_error()); // Retrieve data from Query $first_name = $_GET['first_name']; // Escape User Input to help prevent SQL Injection $first_name = mysql_real_escape_string($first_name); $query = "SELECT * FROM student_information WHERE first_name = '$first_name'"; $qry_result = mysql_query($query) or die(mysql_error()); $display_string = "<table border='1' cellpadding='10' cellspacing='1' align='center'>"; $display_string .= "<tr align='center'>"; $display_string .= "<th>LR Number</th>"; $display_string .= "<th>F i r s t N a m e</th>"; $display_string .= "<th>L a s t N a m e</th>"; $display_string .= "<th>Grade</th>"; $display_string .= "<th>Section</th>"; $display_string .= "<th>View</th>"; $display_string .= "<th>Update</th>"; $display_string .= "<th>Delete</th>"; $display_string .= "</tr>"; // Insert a new row in the table for each person returned while($row = mysql_fetch_array($qry_result)){ $display_string .= "<tr>"; $display_string .= "<td>$row[LRN]</td>"; $display_string .= "<td>$row[first_name]</td>"; $display_string .= "<td>$row[last_name]</td>"; $display_string .= "<td>$row[grade]</td>"; $display_string .= "<td>$row[section]</td>"; $display_string .= "<td><a href='View_Profile.php'>View</a> </td>"; $display_string .= "<td><a href='Admin_Edit_Student_Info.php'>Update</a></td>"; $display_string .= "<td><a href='Admin_Delete_Student.php'>Delete</a></td>"; $display_string .= "</tr>"; } $display_string .= "</table>"; echo $display_string; ?> i think i miss some codes on the ajax.php VIEW/EDIT/DELETE reference links. Please correct and give me some suggestions. If you need other codes in my page which is necessary just tell me so that i can post it.