It looks like Birdie wants to take a word and run an sql query to return all rows that have a phrase LIKE the word but is doing it in parts, adding a letter to the word in the query each time (the substr part using $amount). This is alot of work for a database to be doing as it sends a fresh sql query every time so you may want to minimize the amount of work/queries if you can. Would be best if we knew what you were trying to do and possibly why, so we can help with how to go about it
$query = mysql_query("SELECT * FROM `ctrade_alpya` WHERE `phrase` LIKE '%$search%' ORDER BY `times DESC");
if(!$query || mysql_num_rows($query) < 1)
//failure - output error, log error, etc
//loop through all returned rows
while($row = mysql_fetch_assoc($query))
//fields/columns from the query are stored in the $row array accessible by $row['columnname']
echo $row['phrase']."<br/>\n"; //for example, echo out the phrase and put an html br tag after
That's an example of how I would search for any phrases 'like' the given criteria and output each one (no limit included in the example). Without knowing exactly what you are looking to do, it's a little more difficult to tailor it but it gives a starting point.
Also, VERY IMPORTANT NOTE, be VERY careful not to create an infinite loop. Using the number of rows will create an infinite loop because it will always be greater than 0 unless no rows were returned. If you have 1 row in the database and use $numrows > 0 as criteria, you're basically saying "if it's greater than 0, keep going...and going...and going...". If you ever do something like that, always make sure the variable will increase/decrease as necessary. If you use mysql_fetch_assoc for example, each loop takes the internal pointer to the next row returned so it will always decrease until there are none left.
Hope this helps,