Search code part 2
<?php
/*set varibles from form */
$searchterm = $_POST['searchterm'];
Trim ($searchterm);
/*check if search term was entered*/
If (!$searchterm){
echo 'Please enter a search term.';
}
/*add slashes to search term*/
If (!get_magic_quotes_gpc())
{
$searchterm = addslashes($searchterm);
}
/* connects to database */
@ $dbconn = new mysqli('localhost', 'root', '', 'sample1');
If (mysqli_connect_errno())
{
Echo 'Error: Could not connect to database. Please try again later.';
Exit;
}
/*query the database*/
$query = "select * from sheet1 where IndexNo like '%".$searchterm."%'";
$result = $dbconn->query($query);
/*number of rows found*/
$num_results = $result->num_rows;
echo '<p>Found: '.$num_results.'</p>';
/*loops through results*/
For ($I=0; $I <$num_results; $I++)
{
$num_found = $I + 1;
$row = $result->fetch_assoc();
Echo "$num_found. ".($row['IndexNo'])." <br />";
Echo "<table border='1'>
<tr>
<th>IndexNo</th>
<th>Name</th>
<th>Marks</th>
<th>Rank</th>
</tr>";
echo "<tr>";
echo "<td>" . $row['IndexNo'] . "</td>";
echo "<td>" . $row['Name'] . "</td>";
echo "<td>" . $row['Marks'] . "</td>";
echo "<td>" . $row['Rank'] . "</td>";
Echo "</tr>";
}
Echo "</table>";
/*free database*/
$result->free();
$dbconn->close();
?>
Related posts
Popular posts
-
Damber Nepali Songs
Top & Famous Songs Aja Aakash Ma Euta Tara Tara Antim Palta Bhetna Aau Sabai Sathi Gaye Bigreko Manche Ma Ke Samjhi Khelyau Timro Pauju ...
-
ACKNOWLEDGEMENT and table of content of E-shopping
ACKNOWLEDGEMENT This report has been prepared for the Final Year Project on topic “E-shoppin...
-
Questions for boring minds
1) Without touching,how will you kill a Plant ? a) By Knife b) By Rope and Gun c) By Scolding d) None 2) I was in Dream. In Dream I visited ...
Featured Post
EPF, CIT and SSF: Where the Retirement Deduction on Your Payslip Goes
If you have a salaried job in Nepal, your payslip probably has a line that quietly takes a chunk of your pay before you see it. It might ...
Popular Posts
-
Damber Nepali Songs
Top & Famous Songs Aja Aakash Ma Euta Tara Tara Antim Palta Bhetna Aau Sabai Sathi Gaye Bigreko Manche Ma Ke Samjhi Khelyau Timro Pauju ...
-
ACKNOWLEDGEMENT and table of content of E-shopping
ACKNOWLEDGEMENT This report has been prepared for the Final Year Project on topic “E-shoppin...
-
Questions for boring minds
1) Without touching,how will you kill a Plant ? a) By Knife b) By Rope and Gun c) By Scolding d) None 2) I was in Dream. In Dream I visited ...
-
Click on the link and get the most beautiful templates to download for free
Click To download the tempalte 1
-
What i have talked with my friends on 2011-04-12
Respected Sir, Things I have done on the DGC packs are: · CSV upload for the tax and city · Calculation of the total amo...
-
RIHANNA LYRICS S.O.S. (Rescue Me) Lyrics with video
[Intro] Lalala lalala la la lala la Ohhh You know... I never felt like this before Lalala lalala la la lala la Ohhh Feels like.. so real [Ve...
-
Drupal JavaScripts to hide and show resources
{# 1. Main slider paragraph template #} {# File: templates/paragraph--slider-with-resources.html.twig #} <div class="slider-with-res...
-
The main object of this lab is to be familiar with the DML(Data Manipulation Language)
DBMS LAB 4 The main object of this lab is to be familiar with the DML(Data Manipulation Language) Dele...
-
Happy Birthday Video.. have fun
--> funny accident, funny birthday accident Happy Birthday to You, dance performed by Chipmunks Alvin, Theodore and Simon; music is taken...
-
DataReader Class note which is very easy
The DataReader Class The DataReader object represents a read-only, forward-only stream of data, which...
No comments:
Post a Comment