ajax-live-search
ajax-live-search copied to clipboard
Love this!! But how to add a hyperlink to a column in search results?
Again love this search feature. It's brilliant. I have 3 columns 'id', fname and sname. How can I edit the search results array so the id column can be clicked and it opens up the customers record?
At the moment on a static table that displays the entire dub I'm using<href ./patients.php?edit&id=" . $id . "> how can replicate this or create a similar task using the results from this ajax search box? I've looked and looked and cannot find a suitable place in the code to create a hyperlink for any column.
Thank you in anticipation.
I answered my own question I figured it out. If anyone wants to know stop me a message it's very very easy. A lot easier than any other answer on here
@kkiernan09369 - How did you manage this? Also looking to link through to results 😅
i would also love to know...please share with us
I hope this was tackled in the docs as well. not everyone can figure this out.
This is what I did, probably a better way of doing it but it works. In templates/default.php
I changed
$html .= "<td>{$column}</td>";
To
// the column name you want changed
if($columnName == 'name')
{
$columnlink = str_replace(' ','-',$column);
$html .= "<td><a href='/whatever/{$columnlink}.php'>{$column}</a></td>";
}
else {
$html .= "<td>{$column}</td>";
}
This script is awesome @GarryMM Thanks! Is there a way for me to use this script, but tweak it to allow a user to click on any column and for it to redirect using the ID in the URL?
So for example, I have ID, Col1 Col2 and Col3. I have ID hidden, so If they click Col 1, Col2 or Col3 it should print the ID into the URL instead of the value of the Col they click.
Thanks
Absolutely. Let me know exactly what you need and I can modify
Sent from my iPhone
On 10 Oct 2019, at 16:11, Matt [email protected] wrote:
This script is awesome @GarryMM Thanks! Is there a way for me to use this script, but tweak it to allow a user to click on any column and for it to redirect using the ID in the URL?
So for example, I have ID, Col1 Col2 and Col3. I have ID hidden, so If they click Col 1, Col2 or Col3 it should print the ID into the URL instead of the value of the Col they click.
Thanks
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
@kkiernan09369 yep exactly that! Just need it so that a user searches their query, and click on the result and it loads to a new url like http://url.com/?id=
Okay so I have done exactly this....
I’ll send you a copy of my code, in which case you would just amend it to suit your database credentials.
What are your database name and the table names and how do you want the tables displayed in the search results?
Also, do you want the search query to search just one table or multiple tables?
For instance you have three tables “name” “surname” “address”
You can search for just the peoples name or you can type “Mary” and it will display all the Mary’s or type “new York” and it will display people living in New York etc etc
Sent from my iPhone
On 10 Oct 2019, at 16:29, Matt [email protected] wrote:
@kkiernan09369 yep exactly that! Just need it so that a user searches their query, and click on the result and it loads to a new url like http://url.com/?id=
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
So the database should have a primary key “id” for example set to auto increment. That way we can configure the search bar to whichever result they click will pass the corresponding “id” variable in to the url.
Sent from my iPhone
On 10 Oct 2019, at 16:29, Matt [email protected] wrote:
@kkiernan09369 yep exactly that! Just need it so that a user searches their query, and click on the result and it loads to a new url like http://url.com/?id=
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
Happy to send you a massage to email @kkiernan09369 with a link to my setup already, as I’ve got it all working. I just can’t hyperlink with the item ID. Lleyton me know, cheers
This is what I did, probably a better way of doing it but it works. In templates/default.php
I changed
$html .= "<td>{$column}</td>";
To
// the column name you want changed if($columnName == 'name') { $columnlink = str_replace(' ','-',$column); $html .= "<td><a href='/whatever/{$columnlink}.php'>{$column}</a></td>"; } else { $html .= "<td>{$column}</td>"; }
how can I change the default.php file into like the code above that the whole row is clickable to the specific id, something like the google search. When the search finds for example 5 results, so I want to scroll with the down arrow key on my keyboard to push the result, not only one
I really need help to solve this. Would anybody be super kind and show me how to add a unique url to each of my results? Oh go on...