Hi guys. Need some help, i want to do my search. For example i have a tab with a bit list in my list1.php list2.php and list3.php and i need to make a search.php where i can find line from tab with keyword. For example:
list1
Indie Resource
Indie Games
Batman Returns
list2
Indie Team
Spiderman Returns
in Search: Indie
Result:
Indie Resource
Indie Games
Indie Team
EDIT: and is there a way without database, without cms and etc a function or script or smth to add a line in a list without editing list1.php? like add.php
EDIT2: and is there a way to include filter to show my tab by abc?:D
[how?] PHP search
[how?] PHP search
Last edited by Nerfintas on Wed Sep 25, 2013 5:06 am, edited 1 time in total.
- vitinho444
- Posts: 2819
- Joined: Mon Mar 21, 2011 4:54 pm
Re: PHP search
Ok, for the search thing i made this a while ago for my college review website.
So what you need to take from my code, is to change the TABLE to the name of the table you want to search, and the FIELD to the name of the field.
With this code if you input Indie and search on List1 you would get every row that contains the title Indie
Example:
Indie zone
Indie resource
resource Indie
Ugly Indie
DumIndiemy
AFJIFJAIndieDFSAUFNAF
etc
Hope it helps.
About the first edit:
I think you mean how to insert values into a table using php?
Just do a query
What this will do is Insert the values "vitor" and "indie" into field1 and field2.
I think that's what you want
About your EDIT2:
It's easy, whenever you do a query
Let's say this is the query:
and you want to display the results sorted by some field, lets say by date
so you do:
What this does, is getting all rows from TABLE and order them by date.
Note: date field must be an actual field from the table "TABLE".
Just realized that i've helped a lot.. so this is how jacko and the guys that help a lot feel.. damn its good.
Code: Select all
if(isset($_POST["keyword"]))
{
$needle = $_POST["keyword"];
$searchT = Query("SELECT * FROM `TABLE` WHERE `FIELD` LIKE ?", "%".$needle."%");
}
else
{
echo "
<form method='POST' action='search.php'>
<p>Search for:<input type='text' name='keyword' class='search'> <input type='submit' class='searchButton'></p>
</form>
";
}
With this code if you input Indie and search on List1 you would get every row that contains the title Indie
Example:
Indie zone
Indie resource
resource Indie
Ugly Indie
DumIndiemy
AFJIFJAIndieDFSAUFNAF
etc
Hope it helps.
About the first edit:
I think you mean how to insert values into a table using php?
Just do a query
Code: Select all
"INSERT INTO `TABEL` ('field1', 'field2') VALUES ('vitor', 'indie')"I think that's what you want
About your EDIT2:
It's easy, whenever you do a query
Let's say this is the query:
Code: Select all
SELECT * FROM `TABLE`so you do:
Code: Select all
SELECT * FROM `TABLE` ORDER BY `date` DESCNote: date field must be an actual field from the table "TABLE".
Just realized that i've helped a lot.. so this is how jacko and the guys that help a lot feel.. damn its good.
Last edited by vitinho444 on Wed Sep 18, 2013 7:32 pm, edited 1 time in total.
Re: PHP search
thanks! a lot of information 
Re: PHP search
You're always helping! YAY youvitinho444 wrote: Just realized that i've helped a lot.. so this is how jacko and the guys that help a lot feel.. damn its good.
- vitinho444
- Posts: 2819
- Joined: Mon Mar 21, 2011 4:54 pm
Re: PHP search
OH STOP YOU GUYS
LOVE THIS COMMUNITY
- vitinho444
- Posts: 2819
- Joined: Mon Mar 21, 2011 4:54 pm
Re: PHP search
you guys are making me shy

Re: PHP search
i was tried but im green in it.. can u make me a working example? for search.php and for list1.php ?;/