I want to know the php code to make an telephone diary..i mean exactly
.,suppose the in database the name stored is " Manoj mishra ",but in the form by typing only"manoj" we can see the details of manoj mishra..how could we do it..?pls giv an example for clear understanding..
6 1250
Question moved to PHP forum.
I want to know the php code to make an telephone diary..i mean exactly
.,suppose the in database the name stored is " Manoj mishra ",but in the form by typing only"manoj" we can see the details of manoj mishra..how could we do it..?pls giv an example for clear understanding..
What database?
MySQL?
I want to know the php code to make an telephone diary..i mean exactly
.,suppose the in database the name stored is " Manoj mishra ",but in the form by typing only"manoj" we can see the details of manoj mishra..how could we do it..?pls giv an example for clear understanding..
Supposing you're using MySQL
Try something like this -
$name = $_POST['name']; //from a form the user filled in?
-
-
$query = "SELECT * from `insert your table name` WHERE `table cell you want to check` like '%$name'";
-
/*this selects everything from the table you want where user input is something like a name you pulled out of table
-
-
The % is a wildcard - that means it'll pull soemthing that's like what you want in relation to where you put the %
-
-
e.g. mark % would get: mark skilbeck, mark jameson etc. % mark would get: john mark, chris mark etc. % mark % would (i think) get: something mark something etc. You get the picture :)*/
-
-
$checkQuery = mysql_query($query); //run a mysql_query
-
-
$numRows = mysql_numrows($checkQuery); /*gets numbers of rows from table where data in $query is true*/
-
-
echo "
-
<table>
-
<tr><th>name</th><th>age</th><th>email</th></tr>";
-
if($numRows => 1){ // if number of rows is equal-to or greater-than: run script
-
while($row = mysql_fetch_array($query)){
-
/* will keep fetching data until it returns false (reaches end) */
-
echo "<tr><td>$row['name']</td><td>$row['age']</td><td>$row['email']</td></tr>";
-
}
-
} else {
-
echo "<tr><td colspan=\"3\">Your search returned no results</td></tr>";
-
}
-
echo "</table>";
-
/*the bit above creates a table. The $row is what you will use to access your data in the MySQL table. Just change the ['name'] etc. to reflect the names of the cells in your MySQL table.*/
-
That should work but i haven't tested it and i am only 17 and i had a heavy night last night.
Less of the excuses - hope this helped :)
-
$name = $_GET['name']; //from a form the user filled in?
-
-
$query = "SELECT * from `example` WHERE `name` like '%$name'";
-
/*this selects everything from the table you want where user input is something like a name you pulled out of table
-
-
The % is a wildcard - that means it'll pull soemthing that's like what you want in relation to where you put the %
-
-
e.g. mark % would get: mark skilbeck, mark jameson etc. % mark would get: john mark, chris mark etc. % mark % would (i think)
-
-
get: something mark something etc. You get the picture :)*/
-
-
$checkQuery = mysql_query($query); //run a mysql_query
-
-
$numRows = mysql_numrows($checkQuery); //gets numbers of rows from table where data in $query is true
-
?>
-
<table><tr><th>name</th><th>age</th><th>email</th></tr>
-
<?php
-
if($numRows >= 1){ // if number of rows is equal-to or greater-than: run script
-
while($row = mysql_fetch_array($checkQuery)){
-
/* will keep fetching data until it returns false (reaches end) */
-
echo "<tr><td>".$row['name']."</td><td>".$row['email']."</td><td>".$row['age']."</td></tr>";
-
}
-
} else {
-
echo "<tr><td colspan=\"3\">Your search returned no results</td></tr>";
-
}
-
echo "</table>";
-
/*the bit above creates a table. The $row is what you will use to access your data in the MySQL table. Just change the
-
-
['name'] etc. to reflect the names of the cells in your MySQL table.*/
-
?>
-
There was a few typos in there ;)
But it works just fine :)
Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).
Sign in to post your reply or Sign up for a free account.
Similar topics
by: John |
last post by:
Hi everyone !
This is a first time I post a message here. If I post my message in a
wrong group. Please ignore it.
I am trying to build a website which allows users (can be thousands of...
|
by: ebernedo |
last post by:
Hey guys, I'm new here
and also pretty new to access
I'm creating a database at work, and need to be able to search things within it to find the right part number in our case...
heres a sample...
|
by: napsters |
last post by:
Hello...I want to make something in VB (Version 9) that reads multiple data from specified file (Access 2007) and displays content in list box. If file doesn't exist, alert user.
More...
|
by: Alexnb |
last post by:
This is similar to my last post, but a little different. Here is what I would
like to do.
Lets say I have a text file. The contents look like this, only there is A
LOT of the same thing.
() A...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |