Incremental Search

Different file. I called mine api.php.

You then use an ajax call and replace the inner html of the playlist.php with the output.

That is greek to me lol but I will try to understand what you are saying.

Ok, I’m lost like I said, I’m new at this the file you created do I add that to the original file i posted yesterdy? Or do I add ajax to the file you sent? And what is the inner html of my playlist.php and out put?

Samples:

Doesn’t matter where you put these AS LONG AS they are in the same directory.
api.php
[php]<?php

$action = isset( $_GET[‘action’] ) ? $_GET[‘action’] : null;

switch ( strtolower( $_GET[‘action’] ) )
{
case ‘search’:
search( $_GET[‘value’] );
break;
default:
// your homepage
}

function search( $val ){
echo “

You clicked me {$val} times

”;
}[/php]

sample.html
[php]

Sample File Click Me!
[/php]

Go to the sample.html file and click the button.

Sorry, I’m just going to end up paying someone to accomplish this task for me. I appreciate ALL your help but I just don’t understand all of this stuff, you might say I’m in to deep, but once again, thanks much appreciated.

I created a file called sample.html, copied the code into it save it and created a file called api.php and copied the content into it and saved it and both of these files reside in the same directory. I have no idea what to do from this point on, so at this time, I will just say thank you for your help, I am not expierenced enough to do all this coding, commands and everything, so once again thanks anyway for your help!

[member=72272]astonecipher[/member], I actually wrote the original code for bnickles1951 with the select list because it was not as easy as it should have been to accomplish what he wanted to do.

Basically what he is wishing to accomplish is an lookup text field that allows you to type in a letter or artist name and see the results pulled from a MySQL database.

His database is stored on the same server as the script will be, so the original query and code just need to be implemented into a file that will allow him to do an ajax call on keypress of the input field, and then echo a list of results below it using autocomplete with jQuery.

This may be bordering on out of scope for this particular section of the forum, but still falls under MySQL.

Other than the database seemingly being of bad design, did you have issues implementing the solution?

Maybe even do an ETL script to fix the database issues…

The database is not the issue. The problem is designing a script that allows the visitor to query the database table and get an artist lookup on keypress. Using the existing query.

I’m not sure how you can say the database is of a poor design based on a simple query.

Nevermind on the design, I looked at the screenshot. I was thinking that the artist and the song were in the same column.

The sample scripts I posted is what you are after, with some slight modifications:
sample.html
[php]



<script>
	$('#btnTest').keyup(function() {

		$.get('api.php?action=search', {
			value : $('#btnTest').val()
		}, function(data) {

			$('#content').html(data);

		});

	});[/php]

api.php
[php] <?php

$pdo = new PDO(‘mysql:host=localhost; dbname=test’, ‘root’);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$action = isset($_GET[‘action’]) ? $_GET[‘action’] : null;

switch (strtolower($_GET[‘action’])) {

case 'search':
    
    search( $pdo, $_GET['value']);
    
    break;

default:

// your homepage

}

function search(PDO $pdo, $val)
{
$stmt = $pdo->prepare(“SELECT playerName FROM player WHERE playerName LIKE ?”);
$stmt->execute(array("$val%"));
while ( $result = $stmt->fetch(PDO::FETCH_ASSOC) ){
echo “

{$result[‘playerName’]}

”;
}

}[/php]

Updating on each keypress.

Updated:: This shows a working example that I can throw on a server if needed.

Update: I am finished with this project it is NOT possible to accomplish.

I believe you have a PM.

If I do I have no idea where to go to see it

Just checked and I don’t have a PM

Sponsor our Newsletter | Privacy Policy | Terms of Service