php - How to automatically fill a template webpage with information? -
i looking initial direction on 1 because cannot seem find way it. let me explain... user enters title of song in the search bar search results filtered instant search. form, in index page:
<script type = "text/javascript "src = "jquery.js"> <form class="navbar-form navbar-left" > <div class="form-group"> <input type="text" class="form-control" id="search" placeholder="search songs, artists" autocomplete="off"> <div id = "searchresults"> </div> <script type="text/javascript" src = "search.js"></script> </div> </form>
search.js file has 2 tasks; check if result has been clicked , if user has pressed key. this:
$('#search').keyup(function() { var searchterm = $ ('#search').val(); if (searchterm != ''){ $.post('search.php', {searchterm:searchterm}, function(data){ $('#searchresults').html(data); }); } else{ $('#searchresults').html(''); } }); $('#mylink').click(function(){ var wanted = $('#mylink').val(); $.post('/web/ztemplate.php', {wanted:wanted}); });
the ztemplate.php file template page populated information basing on result user clicks. it's this:
$search = $_post['wanted']; $find = mysql_query("select * search title '%$search%'"); $row = mysql_fetch_assoc($find); $title = $row["title"];
and search.php file this:
$search = mysql_real_escape_string(trim($_post['searchterm'])); if ($search == '' && ' '){ echo 'no results found'; } else { $find_videos = mysql_query("select * search keywords '%$search%'"); $count = mysql_num_rows($find_videos); if ($count ==0){ echo 'no results found '.$search; } else { while($row = mysql_fetch_assoc($find_videos)){ $title = $row["title"]; $link = $row["link"]; echo "<a href = '$link'><h5 id = 'mylink'> $title <h5> </a> <hr /> "; } } }
the link column in table has link ztemplate.php. aim is: i don't want make separate .php file each song. (eg: song1.php, song2.php, etc...). there should 1 php template file, outputs webpage songs. when try searching opens ztemplate.php file want fills file title of first row in table if have searched first song in database. getting notice
undefined index:wanted
even though see declared in search.js file.
any appreciated.
Comments
Post a Comment