Jump to content

[SOLVED] output names beginning with certain letters...


Dragen

Recommended Posts

Hi,

I've got this code, which gets the names of all the data from a table where the category equals $category. It's ordered by name.

How do I get it so that it only outputs the results where name starts with a certain letter? for example.. only show results like:

apple

allan

but not

bob

cod

zebra

 

here's my code

<?php
	$sql = "SELECT * FROM downloads WHERE category = '$category' ORDER BY name DESC"; // finds the newest 2 items from $dispcategory
	if ($result = mysql_query($sql)) {
		if (mysql_num_rows($result)) {
		    while ($row = mysql_fetch_assoc($result)) {
			echo $row['name'] . "<br />";
			}
		}else{
			echo "unavailable";
		}
	}else{
		echo "Query failed<br />$sql<br />".mysql_error()."</td>\n";
	}
	?>

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.