Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

How can I use jquery autocomplete plugin with smarty?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
mnpartner
Smarty n00b


Joined: 03 May 2017
Posts: 3

PostPosted: Wed May 03, 2017 6:18 am    Post subject: How can I use jquery autocomplete plugin with smarty? Reply with quote

I'm trying to use a autocomplete plugin, but I can not do it. Who can help me?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed May 03, 2017 6:27 am    Post subject: Reply with quote

jQuery is a JavaScript library. Smarty is a PHP library.
How's one related to the other?
Back to top
View user's profile Send private message
mnpartner
Smarty n00b


Joined: 03 May 2017
Posts: 3

PostPosted: Wed May 03, 2017 2:03 pm    Post subject: Reply with quote

AnrDaemon wrote:
jQuery is a JavaScript library. Smarty is a PHP library.
How's one related to the other?


It is Header.tpl

Code:
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Autocomplete textbox using jQuery, PHP and MySQL by CodexWorld</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  <script>
  $(function() {
    $( "#skills" ).autocomplete({
      source: 'search.php'
    });
  });
  </script>
</head>
<body>
 
<div class="ui-widget">
  <label for="skills">Skills: </label>
  <input id="skills">
</div>
</body>
</html>


It is search.php
Code:
<?php
$dbHost = 'localhost';
$dbUsername = 'root';
$dbPassword = '';
$dbName = 'codexworld';
//connect with the database
$db = new mysqli($dbHost,$dbUsername,$dbPassword,$dbName);
//get search term
$searchTerm = $_GET['term'];
//get matched data from skills table
$query = $db->query("SELECT * FROM skills WHERE skill LIKE '%".$searchTerm."%' ORDER BY skill ASC");
while ($row = $query->fetch_assoc()) {
    $data[] = $row['skill'];
}
//return json data
echo json_encode($data);
?>


It is mysql.sql

Code:
CREATE TABLE IF NOT EXISTS `skills` (
  `id` int(11) NOT NULL,
  `skill` varchar(255) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `skills`
--

INSERT INTO `skills` (`id`, `skill`) VALUES
(1, 'ActionScript'),
(2, 'AppleScript'),
(3, 'Asp'),
(4, 'BASIC'),
(5, 'C'),
(6, 'C++'),
(7, 'Clojure'),
(8, 'COBOL'),
(9, 'ColdFusion'),
(10, 'Erlang'),
(11, 'Fortran'),
(12, 'Groovy'),
(13, 'Haskell'),
(14, 'Java'),
(15, 'JavaScript'),
(16, 'Lisp'),
(17, 'MySQL'),
(18, 'Oracle'),
(19, 'Perl'),
(20, 'PHP'),
(21, 'Python'),
(22, 'Ruby'),
(23, 'Scala'),
(24, 'Scheme'),
(25, 'SQL');

In my script all the script files are in the module folder in the format .inc ,and the template files in the templates / olx folder
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed May 03, 2017 2:51 pm    Post subject: Reply with quote

That's great introspection, but it doesn't answer my question.
If you want to build a service that would feed your jQuery plugin request, then read the documentation on that and write service that return data in required format.
And i'm 99% sure it will have nothing to do with Smarty, pure
Code:
print json_encode()
Back to top
View user's profile Send private message
mnpartner
Smarty n00b


Joined: 03 May 2017
Posts: 3

PostPosted: Wed May 03, 2017 7:21 pm    Post subject: Reply with quote

AnrDaemon wrote:
That's great introspection, but it doesn't answer my question.
If you want to build a service that would feed your jQuery plugin request, then read the documentation on that and write service that return data in required format.
And i'm 99% sure it will have nothing to do with Smarty, pure
Code:
print json_encode()

Thanks, but I read a lot and did not find the answer to my question
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed May 03, 2017 8:57 pm    Post subject: Reply with quote

Because your question can't be answered.
PHP has nothing to do with JavaScript, they never meet in person.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP