Hello I am trying to echo out a variable $address into a google map url as such:
<iframe width="640" height="480" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.it/maps?q=<?php echo $address; ?>&output=embed"></iframe>
I can't get the variable to echo out in the <?php echo $address; ?>
Here is my pagination script, (depricated) I know.
This is the same script that I want the address to be echoed out into the url, so everytime someone searches if an address is brought up then it automatically generates a Static Map.
<?php
// Connects to your Database
mysql_connect("xxx", "xxx", "xxx") or die(mysql_error());
mysql_select_db("xxx") or die(mysql_error());
error_reporting(0);
//This checks to see if there is a page number. If not, it will set it to page 1
if (!(isset($pagenum)))
{
$pagenum = 1;
}
//Here we count the number of results
//Edit $data to be your query
$data = mysql_query("SELECT * FROM bus WHERE fname
LIKE '%" . mysql_real_escape_string($name) . "%' AND Address
LIKE '%" . mysql_real_escape_string($address) . "%' City
LIKE '%" . mysql_real_escape_string($city) . "%' AND state
LIKE '%" . mysql_real_escape_string($state) . "%' AND zip
LIKE '%" . mysql_real_escape_string($zip) . "%' AND phone
LIKE '%" . mysql_real_escape_string($phone) . "%' AND hours
LIKE '%" . mysql_real_escape_string($hours) . "%'") or die(mysql_error());
$rows = mysql_num_rows($data);
//This is the number of results displayed per page
$page_rows = 10;
//This tells us the page number of our last page
$last = ceil($rows/$page_rows);
//this makes sure the page number isn't below one, or more than our maximum pages
if ($pagenum > $last) {
$pagenum = $last;
}
if ($pagenum < 1) {
$pagenum = 1;
}
//This sets the range to display in our query
$max = 'limit ' .((($pagenum == 0) ? 1 : $pagenum) - 1) * $page_rows .',' .$page_rows;
//This is your query again, the same one... the only difference is we add $max into it
$data_p = mysql_query("SELECT * FROM bus WHERE fname
LIKE '%" . mysql_real_escape_string($name) . "%' AND Address
LIKE '%" . mysql_real_escape_string($address) . "%' City
LIKE '%" . mysql_real_escape_string($city) . "%' AND state
LIKE '%" . mysql_real_escape_string($state) . "%' AND zip
LIKE '%" . mysql_real_escape_string($zip) . "%' AND phone
LIKE '%" . mysql_real_escape_string($phone) . "%' AND hours
LIKE '%" . mysql_real_escape_string($hours) . "%' $max") or die(mysql_error());
//This is where you display your query results
while($info = mysql_fetch_array( $data_p ))
{
echo "<hr width=500><table width=500><td id=table1><br>Business Name: ";
echo $info['fname'];
echo "<br>Address: ";
echo $info['Address'];
echo "<br>City: ";
echo $info['City'];
echo "<br>State: ";
echo $info['state'];
echo "<br>Zip Code: ";
echo $info['zip'];
echo "<br>Phone: ";
echo $info['phone'];
echo "<br>Hours: ";
echo $info['hours'];
echo "<br></td></table><hr width=500>";
}
// This shows the user what page they are on, and the total number of pages
echo " --Page $pagenum of $last-- <p>";
// First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page.
if ($pagenum == 1)
{
}
else
{
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> ";
echo " ";
$previous = $pagenum-1;
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> ";
}
//just a spacer
echo " ---- ";
//This does the same as above, only checking if we are on the last page, and then generating the Next and Last links
if ($pagenum == $last)
{
}
else {
$next = $pagenum+1;
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> ";
echo " ";
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last -></a> ";
}
?>
<?php
?>
<?php
//This counts the number or results - and if there wasn't any it gives them a little message explaining that
$anymatches=mysql_num_rows($data_p);
if ($anymatches == 0)
{
echo "Sorry, but we can not find an entry to match your query<br><br>";
}
//And we remind them what they searched for
echo "<b>Searched For:
</b> " .$fname;
?>
From php 4.0 you need to divine fields from a post with $_POST['field_name']. So you need to change it to $_POST['address'].
As the address for Google Maps can be anything from full address(zip,house number, street,area,town,region,state,country etc) to any combination of these your approach is wrong.
You should decide what elements you want and have a separate input for each of them. You can then build up the search address from these
Related
Php beginner here. I have php loop on page to display images (basically a gallery) and each image has a title displayed below. Those titles are links to second page where only one image is shown.
The problem is that every link has a different name (value of name is specific /ID of image).
<form action="image_link.php" method="post">
<?php>
$sql_select = "SELECT * FROM images ORDER BY data DESC";
$sql_table_selected = mysql_query($sql_select);
while ($table_row = mysql_fetch_array($sql_table_selected)){
echo "<div class=\"galery-1-3\"><figure>";
echo "<img src=\"" . $table_row['file_path'] . "\" />";
echo "<figcaption>" . $table_row['tytul'] . "</figcaption></figure></div>";
}
?>
I'm getting a single image displayed but no matter what title I click, I always get last image from the table. How can I catch a specific ID on image_link.php, or should I use some flexible kind of address like /image_link.php?id=34. I don't know where to start.
image_link.php contains basically the same code without the loop:
$sql_select = "SELECT * FROM images WHERE ID = $SomehowGetID";
$sql_table_selected = mysql_query($sql_select);
$table_row = mysql_fetch_array($sql_table_selected);
echo "<div class=\"galery-big\"><figure>";
echo "<img src=\"" . $table_row['file_path'] . "\" />";
echo "<figcaption>" . $table_row['tytul'] . "</figcaption></figure></div>";
Thanks in advance for help.
No need for a form
first script :
<?php
$sql_select = "SELECT * FROM images ORDER BY data DESC";
$sql_table_selected = mysql_query($sql_select);
while ($table_row = mysql_fetch_array($sql_table_selected)){
echo "<div class=\"galery-1-3\"><figure>";
echo "<img src=\"" . $table_row['file_path'] . "\" />";
echo "<figcaption><a href=\"image_link.php?id=" . $table_row['ID']
. "\" name=\"" . $table_row['ID']
. "\">" . $table_row['tytul'] . "</a></figcaption></figure></div>";
}
?>
second script
$SomehowGetID=$_GET['id'];
$sql_select = "SELECT * FROM images WHERE ID = $SomehowGetID";
$sql_table_selected = mysql_query($sql_select);
$table_row = mysql_fetch_array($sql_table_selected);
echo "<div class=\"galery-big\"><figure>";
echo "<img src=\"" . $table_row['file_path'] . "\" />";
echo "<figcaption>" . $table_row['tytul']
. "</figcaption></figure> </div>";
I'd advice you though to use prepared statement instead of simple query constructions.
Change query to:
$sql_select = "SELECT * FROM images WHERE ID =" $_GET['id'];
echo
"<figcaption>
<a href='image_link.php?id=$table_row[ID]' name='$table_row[ID]'>"
.$table_row['tytul'] ."
</a>
</figcaption>
</figure></div>";
You need to pass the id as a parameter in your href with $table_row[ID] as value.
In image_link.php
Use:
$sql_select = "SELECT * FROM images WHERE ID = '$_GET[ID]'";
You had the right idea by saying that you want to pass the id of the image.
your code should looks like this :
<form action="image_link.php" method="post">
<?php>
$sql_select = "SELECT * FROM images ORDER BY data DESC";
$sql_table_selected = mysql_query($sql_select);
while ($table_row = mysql_fetch_array($sql_table_selected)){
echo "<div class=\"galery-1-3\"><figure>";
echo "<img src=\"" . $table_row['file_path'] . "\" />";
echo "<figcaption>" . $table_row['tytul'] . "</figcaption></figure></div>";
}
?>
image_link.php:
$sql_select = "SELECT * FROM images WHERE ID =" . mysql_real_escape_string($_GET['id']);
$sql_table_selected = mysql_query($sql_select);
$table_row = mysql_fetch_array($sql_table_selected);
echo "<div class=\"galery-big\"><figure>";
echo "<img src=\"" . $table_row['file_path'] . "\" />";
echo "<figcaption>" . $table_row['tytul'] . "</figcaption></figure></div>";
Please note that the use of mysql_* function is highly deprecated, you should use mysqli extention instead
i'am working on a social project and we've just startet the registration for members.
Our members could recriute new members, so we have a database where is a field "recruit_by".
The DB fiels looks like this:
id | name | email | code | recruit_by
We now want to generate a list of the structure, who recruited whom on all levels.
I've tried to get this done, but it seems my skills are to less to get this done.
I get a list, but this is totaly unsorted :-(
Thanks for your help!
<?PHP
mysql_connect("www.mysqlserver.net", "database1", "password") or die(mysql_error());
mysql_select_db("project_db1") or die(mysql_error());
echo "<ul>";
$result = mysql_query("SELECT * FROM registration") or die(mysql_error());
while($row = mysql_fetch_array($result))
{
echo "<li class=\"level0\">" . $row['id'] . " - " . $row['name'] . " - " . $row['email'] . " - " . $row['recruit_by'] . "</li>";
// 1. Level
$result2 = mysql_query("SELECT * FROM registration WHERE recruit_by LIKE " . $row['id']) or die(mysql_error());
while($row2 = mysql_fetch_array($result2))
{
echo "<li class=\"level1\">1. " . $row2['id'] . " - " . $row2['name'] . " - " . $row2['email'] . " - " . $row2['recruit_by'] . "</li>";
// 2. Level
$result3 = mysql_query("SELECT * FROM registration WHERE recruit_by LIKE " . $row2['id']) or die(mysql_error());
while($row3 = mysql_fetch_array($result3))
{
echo "<li class=\"level2\">2. " . $row3['id'] . " - " . $row3['name'] . " - " . $row3['email'] . " - " . $row3['recruit_by'] . "</li>";
// 3. Level
$result4 = mysql_query("SELECT * FROM registration WHERE recruit_by LIKE " . $row3['id']) or die(mysql_error());
while($row4 = mysql_fetch_array($result4))
{
echo "<li class=\"level3\">3. " . $row4['id'] . " - " . $row4['name'] . " - " . $row4['email'] . " - " . $row4['recruit_by'] . "</li>";
// 4. Level
$result5 = mysql_query("SELECT * FROM registration WHERE recruit_by LIKE " . $row4['id']) or die(mysql_error());
while($row5 = mysql_fetch_array($result5))
{
echo "<li class=\"level4\">4. " . $row5['id'] . " - " . $row5['name'] . " - " . $row5['email'] . " - " . $row5['recruit_by'] . "</li>";
}
}
}
}
}
echo "</ul>";
?>
First, you are selecting all registrations, that results all the recuited users also.
I would suggest selecting only non-recuited users, assuming recruit_by is NULL, when this user is not recruited:
$result = mysql_query("SELECT * FROM registration WHERE recruit_by IS NULL") or die(mysql_error());
Secondly it is good to structure second level of recruits in another <ul></ul> tags like this:
<ul>
<li>User #1
<ul>
<li>User #103, recruited by user #1</li>
<li>User #142, recruited by user #1</li>
<li>User #93, recruited by user #1
<ul>
<li>User #992, recruited by user #93</li>
</ul>
</li>
</ul>
</li>
</ul>
This already gives you much better structure to work with and you can easily loop it in you PHP code (DRY - don't repeat yourself).
<?php
function createTree($level = 0, $recruiter_id = 0) {
$return = "";
if (!$recruiter_id) {
$results = mysql_query("SELECT * FROM registration WHERE recruit_by IS NULL") or die(mysql_error());
} else {
$results = mysql_query("SELECT * FROM registration WHERE recruit_by LIKE " . $recruiter_id) or die(mysql_error());
}
// Check if there is any recruits at all?
if (pg_num_rows($results) > 0) $return .= "<ul>\n";
else return "";
while ($row = mysql_fetch_array($results)) {
$return .= "<li class=\"level".$level."\">\n";
$return .= $level.". " . $row['id'] . " - " . $row['name'] . " - " . $row['email'] . " - " . $row['recruit_by']."\n";
// Add sub-recruits
$return .= createTree($level+1, $row['id']);
// Finish up the <li>
$return .= "</li>\n";
}
$return .= "</ul>\n";
return $return;
}
?>
I am trying to make an advanced search engine, one in which you can search by first name, last name, zip, city, state, phone, cell phone and email.
I have managed to get it to search by first name, but you have to type the first name correctly as with anything else, I took out everything else but the first name search to find my problem yet, I have yet to find it, Here is a MySQL version of my search code that I am trying to convert to PDO.
MySQL:
<?php
//This is only displayed if they have submitted the form
if ($searching =="yes") {
echo "<h2>Results</h2><p>";
//If they did not enter a search term we give them an error
if ($find == "")
if ($f == "")
if ($info == "")
if ($zip == "")
if ($state == "")
if ($email == "")
{
echo "<p>You forgot to enter a search term";
exit;
}
// Otherwise we connect to our Database
mysql_connect("xxx", "xxxx", "xxx") or die(mysql_error());
mysql_select_db("xxxx") or die(mysql_error());
// We preform a bit of filtering
//Now we search for our search term, in the field the user specified
$data = mysql_query("SELECT * FROM users WHERE fname
LIKE '%" . mysql_real_escape_string($find) . "%' AND lname
LIKE '%" . mysql_real_escape_string($f) . "%' AND info
LIKE '%" . mysql_real_escape_string($info) . "%' AND zip
LIKE '%" . mysql_real_escape_string($zip) . "%' AND state
LIKE '%" . mysql_real_escape_string($state) . "%' AND email
LIKE '%" . mysql_real_escape_string($city) . "%' AND city
LIKE '%" . mysql_real_escape_string($email) . "%'");
?>
<?php
//And we display the results
while($result = mysql_fetch_array( $data ))
{
echo "<hr><br>First Name: ";
echo $result['fname'];
echo "<br>Last Name: ";
echo $result['lname'];
echo "<br>Home Phone: ";
echo $result['info'];
echo "<br>Cell Phone: ";
echo $result['cp'];
echo "<br>City: ";
echo $result['city'];
echo "<br>State: ";
echo $result['state'];
echo "<br>Zip: ";
echo $result['zip'];
echo "<br>Email: ";
echo $result['email'];
echo "<br><hr>";
}
//This counts the number or results - and if there wasn't any it gives them a little message explaining that
$anymatches=mysql_num_rows($data);
if ($anymatches == 0)
{
echo "Sorry, but we can not find an entry to match your query<br><br>";
}
//And we remind them what they searched for
echo "<b>Searched For:
</b> " .$find;
}
?>
Now here is my PDO version:
<?
$dsn = 'mysql:host=xxx;dbname=xxx;charset=utf8';
$opt = array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
);
$pdo = new PDO($dsn,'xxx','xxx', $opt);
$stmt = $pdo->prepare("SELECT * FROM users WHERE fname= ?");
if ($stmt->execute(array($fname)));
while ($row = $stmt->fetch()) {
print $row['fname'] . "<br>";
print $row['lname'] . "\t<br>";
print $row['info'] . "\n<br>";
print $row['cp'] . "\n<br>";
print $row['state'] . "\n<br>";
print $row['city'] . "\n<br>";
print $row['zip'] . "\n<br>";
print $row['email'] . "\n<br>";
}
?>
Tips, advice, and comments are welcome and appreciated.
I guess you would build a sql-string and use parameters.
You would not include into your sql fields that the user left empty.
// **EDIT** check if there's any user-input...
if (!isset($_POST['fname']) && !isset($_POST['lname'])) { // add all your input-fields
echo "<p>please enter a search term!</p>";
echo 'try again";
exit();
}
$sql = '';
$bind = array();
if (strlen($_POST[‘firstname‘]) > 0) { // assuming your form-method is "post"
$sql .= 'AND fname LIKE :fname ';
$bind['fname'] = '%'.$_POST['firstname'].'%';
}
if (strlen($_POST['lastname']) > 0)
$sql .= 'AND lname LIKE :lname ';
$bind['lname'] = '%'.$_POST['lastname'].'%';
}
// ...
// do this will all of your input-fields...
$sql = 'SELECT * FROM users WHERE ' . trim($sql, 'AND') . ' ORDER BY lname';
$stmt = $pdo->prepare($sql);
$stmt->execute(array($bind));
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
// go ahead and display your results with foreach...
Your biggest problem is you’re using AND instead of OR in your WHERE clause. Change it to this:
SELECT *
FROM `table`
WHERE `name` LIKE '%string%'
OR `zip` LIKE '%string%'
// AND SO ON
I was using this script and everything was great except for the fact that when the actual search was executed and "No Results" was the answer, I wanted the script to display such.
When doing research to see where the FAIL was I discovered that I should be using MySQLi. I have been at this script for 2 days and I seem to be getting further instead of closer. A little help here fellas?
What I am using:
if(empty($_GET['query'])){
header ("Location: /same_page");
}
else{
//connect
include 'connection_script.php';
//Get the "Term" from the search box
$query=mysql_real_escape_string($_GET['query']);
$page_str = "SELECT * FROM $tblname WHERE name like '%$query%' or clan like '%$query%'";
$page_query = mysqli_query($con,$page_str)or die(mysql_error($con));
while($page_result = mysqli_fetch_assoc($page_query)){$datarow .= " <ul>
<li>Banned player : <a target='_blank' href=\"http://path/tosomething/here=" . $page_result[name] . " \">" . $page_result[name] . "</a></li>
<li>Clan Name : " . $page_result[clan] . "</li>
<li>Reason : " . $page_result[reason] . "</li>
<li>Posted By : " . $page_result[moderator] . "</li>
<li>Date & Time : " . $page_result[dateandtime] . "</li>
<li>Evidence : <a target='_blank' href=\"$page_result[evidence]\">Here</a></li>
</ul><br />";
}
echo $datarow;
echo "<br />";
include 'dbclose.php';
}
mysql_close($con);
You can retrieve the count of the rows with:
mysqli_num_rows($page_query);
Simply verify that it is >0 to chose what to display, the error message or the results
Just add a condition to display something if your query returns 0
if(empty($_GET['query'])){
header ("Location: /same_page");
}
else{
//connect
include 'connection_script.php';
//Get the "Term" from the search box
$query=mysql_real_escape_string($_GET['query']);
$page_str = "SELECT * FROM $tblname WHERE name like '%$query%' or clan like '%$query%'";
$page_query = mysqli_query($con,$page_str)or die(mysql_error($con));
if (mysqli_num_rows($page_query) > 0){
while($page_result = mysqli_fetch_assoc($page_query)){$datarow .= " <ul>
<li>Banned player : <a target='_blank' href=\"http://path/tosomething/here=" . $page_result[name] . " \">" . $page_result[name] . "</a></li>
<li>Clan Name : " . $page_result[clan] . "</li>
<li>Reason : " . $page_result[reason] . "</li>
<li>Posted By : " . $page_result[moderator] . "</li>
<li>Date & Time : " . $page_result[dateandtime] . "</li>
<li>Evidence : <a target='_blank' href=\"$page_result[evidence]\">Here</a></li>
</ul><br />";
}
echo $datarow;
echo "<br />";
} else {
echo 'Your search returned 0 results';
}
include 'dbclose.php';
}
mysql_close($con);
The list just stayed at ten items with no pagination to get the rest of the other list, this sucks, But thanks Guys, maybe i need more practice i really need this one to be working so i can learn from this one, any way the first code worked, the second works but stops at ten items, you said try the ceil i did with some code that i had already, the next and back and number of pages came up but no list, tried it again no next and back but ten items came up, i'm beginning to get a bit frustrated here.
<DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Residential</title>
</head>
<body>
<section>
<form method="post" action="index.php?go" id="searchform">
<input type="text" id="sf" name="name" class="inputtext" >
<input type="submit" name="submit" id="sb" alt="Btn" value="GO">
</form>
</section>
<div class="results">
<?php
error_reporting(0);
if(isset($_POST['submit'])) {
if(isset($_GET['go'])) {
if(preg_match("/[A-Z | a-z]+/", $_POST['name'])){ //"/[A-Z | a-z]+/",
$name=$_POST['name'];
//connect to the database
$db=mysql_connect ("localhost", "root", "") or die ('I cannot connect to the database because: ' . mysql_error());
//-select the database to use
$mydb=mysql_select_db("residential");
This is the beginning of the changed code
//////////pagination////////////
$sql=mysql_query("SELECT userId, FirstName, LastName FROM residentialbackup WHERE FirstName ='" . $name . "' OR LastName = '" . $name ."'");
//-count results
$numrows=mysql_num_rows($sql);
// Get the value of the last page in the pagination result set
$lastPage = ceil($numrows / $itemsPerPage);
$itemsPerPage = 10;
$page = $_GET['page'];
if (!$page) $page = 1;
$offset = ($page - 1) * $itemsPerPage;
$sql2=mysql_query("SELECT userId, FirstName, LastName FROM residentialbackup WHERE FirstName = '" . $name . "' OR LastName = '" . $name ."' LIMIT ". $offset . ", ". $itemsPerPage);
$paginationDisplay = ""; // Initialize the pagination output variable
// This code runs only if the last page variable is ot equal to 1, if it is only 1 page we require no paginated links to display
if ($lastPage != "1") {
// This shows the user what page they are on, and the total number of pages
$paginationDisplay .= 'Page <strong>' . $page . '</strong> of ' . $lastPage. ' ';
// If we are not on page 1 we can place the Back button
if ($page != 1) {
$previous = $page - 1;
$paginationDisplay .= ' Back ';
}
// Lay in the clickable numbers display here between the Back and Next links
$paginationDisplay .= '<span class="paginationNumbers">' . $centerPages . '</span>';
// If we are not on the very last page we can place the Next button
if ($page != $lastPage) {
$nextPage = $page + 1;
$paginationDisplay .= ' Next ';
}
}
echo $paginationDisplay;
///////////////pagination end////////////
i'm stuck up to here!
//echo "<p>" .$numrows . " results found for " . stripslashes($name) . "</p>";
//-create while loop and loop through result set
while($row=mysql_fetch_array($sql2)) {
$FirstName =$row['FirstName'];
$LastName=$row['LastName'];
$userId=$row['userId'];
//-display the result of the array
echo "<ul>\n";
echo "<li>" . "" .$FirstName . " " . $LastName . " </li>\n";
echo "</ul>";
}
}
else {
echo "<p>Please enter a search query</p>";
}
}
/*
if(isset($_GET['by'])){
$name=$_GET['by'];
include "connectres.php";
//-query the database table
$sql="SELECT userId, FirstName, LastName FROM residentialbackup WHERE FirstName LIKE '%" . $name . "%' OR LastName LIKE '%" . $name ."%'";
//-run the query against the mysql query function
$result=mysql_query($sql);
//-count results
$numrows=mysql_num_rows($result);
echo "<p>" .$numrows . " results found for " . $name . "</p>";
//-create while loop and loop through result set
while($row=mysql_fetch_array($result)){
$FirstName =$row['FirstName'];
$LastName=$row['LastName'];
$userId=$row['userId'];
//-display the result of the array
echo "<ul>\n";
echo "<li>" . " " . $LastName . " " . $FirstName . " </li>\n";
echo "</ul>";
}
}
*/
if(isset($_GET['id'])) {
$userId=$_GET['id'];
//connect to the database
include "connectres.php";
//-query the database table
$sql="SELECT * FROM residentialbackup WHERE userId=" . $userId;
//-run the query against the mysql query function
$result=mysql_query($sql);
//-create while loop and loop through result set
while($row=mysql_fetch_array($result)) {
$FirstName =$row['FirstName'];
$LastName=$row['LastName'];
$PhoneNumber=$row['PhoneNumber'];
$Address=$row['Address'];
//-display the result of the array
echo "<ul>\n";
echo "<li>" . "<img src=\"../images/person.png\"/>" . $FirstName . " " . $LastName . " </li>\n";
echo "<li>" . "<img src=\"../images/tell.png\"/>" . " " . "" . $PhoneNumber . "</li>\n";
echo "<li>" . "<img src=\"../images/house.png\"/>" . " " . $Address . "</li>\n";
echo "</ul>";
}
}
?>
</div>
</div>
</body>
</html>
Your query has wildcards in it, remove them to only fetch exact matches
$sql="SELECT userId, FirstName, LastName FROM residentialbackup WHERE FirstName ='" . $name . "' OR LastName = '" . $name ."'";
You can make a pagination like this:
$itemsPerPage = 10;
$page = $_GET['page'];
if (!$page) $page = 1;
$offset = ($page - 1) * $itemsPerPage;
$sql="SELECT userId, FirstName, LastName FROM residentialbackup WHERE FirstName = '" . $name . "' OR LastName = '" . $name ."' LIMIT ". $offset . ", ". $itemsPerPage;