Hey all,
A tad stuck on something I'm attempting to do with an existing script.
I have an autocomplete script which is searching within 3 rows, I'm trying to make it so that when the search happens, depending what row it's in, it will display something slightly different.
Here's the code I have (this isn't the complete code):
It's the in_array I'm having issues with, I need to check within either of three rows, title, artist or album. The code above doesn't work ... where am I going wrong? As far as I was aware they are arrays at that point.
Thanks,
Jason
A tad stuck on something I'm attempting to do with an existing script.
I have an autocomplete script which is searching within 3 rows, I'm trying to make it so that when the search happens, depending what row it's in, it will display something slightly different.
Here's the code I have (this isn't the complete code):
PHP Code:
<?php
if (!mysql_num_rows($getRecord)) {
echo "Sorry, I ain't got that!";
} else {
while ($row = mysql_fetch_array($getRecord)) {
if (in_array($searchq, $row["title"])) { echo "Title works"; echo '</ul>'; exit; }
elseif (in_array($searchq, $row["album"])) { echo "Album works"; echo '</ul>'; exit; }
elseif (in_array($searchq, $row["artist"])) { echo "Artist works"; echo '</ul>'; exit; }
?>
<li><a href="playlist.php?search=<?php echo $row['title']; ?>&dcat=title">Title: <?php echo $row['title']; ?></a><small><a href="playlist.php?search=<?php echo $row['artist']; ?>&dcat=artist">Artist: <?php echo $row['artist']; ?></a><a href="playlist.php?search=<?php echo $row['album']; ?>&dcat=album">Album: <?php echo $row['album']; ?></a></small></li>
<?php
}
}
Thanks,
Jason
Comment