hai....

there is thousands of products is there. now we want to see as a directory wise means (A-Z wise) devide. how to do this.

[B][U]A[/U][/B]

Apple
Ant
Aeroplane


[B][U]B[/U][/B]

Bat
Ball
Book

like this......up to z. how to do this?
adv thnks.

hai....

there is thousands of products is there. now we want to see as a directory wise means (A-Z wise) devide. how to do this.

[B][U]A[/U][/B]

Apple
Ant
Aeroplane


[B][U]B[/U][/B]

Bat
Ball
Book

like this......up to z. how to do this?
adv thnks.

just write a query like this..

select * from table order by product

hope this will help u....

just write a query like this..

select * from table order by product

hope this will help u....

thanks for your reply.
i am not looking for above solution. i am looking for short script for this.

why because i am not displaying only two(A,B) directories.
i am displaying (A-z) directories. for that i will write 26 querys for each directory as you said. i am looking for short codes for this solution.
is there any solution to do this ?

what is the difference between these.

<?
for($i='A';$i<'Z';$i++)
{
echo $i;
//i will write select query using $i;
}
?>

above code displaying A to Y. its correct.
but below code displaying more.just see once. is it useful for my directory script which i was specified above.

<?
for($i='A';$i<='Z';$i++)
{
echo $i;
}
?>

see this one.

<?
for($i='A';$i<='Z';$i++)
{
echo $i; echo "<br>";
echo "write query here";echo "<br>";
if($i=='Z')
{
exit;
}
}
?>

up to here correct . but there is no products in the product which stats with 'V' i dont want to display the Directory.

i think you are trying for this. hope this will help you.

at the top of the page you connect to your database.

<?
for($i='A';$i<='Z';$i++)
{
$select1=mysql_query("select * from product where productname like '$i%'");
$count=mysql_num_rows($select1);

if($count!=0)
{
echo $i; echo "<br>";
while($fetch=mysql_fetch_array($select1))
{
echo $fetch['productname']; echo "<br>";

} 
echo "<br>";

}
if($i=='Z')
{
exit;
}
}
?>

i think you are trying for this. hope this will help you.

at the top of the page you connect to your database.

<?
for($i='A';$i<='Z';$i++)
{
$select1=mysql_query("select * from product where productname like '$i%'");
$count=mysql_num_rows($select1);

if($count!=0)
{
echo $i; echo "<br>";
while($fetch=mysql_fetch_array($select1))
{
echo $fetch['productname']; echo "<br>";

} 
echo "<br>";

}
if($i=='Z')
{
exit;
}
}
?>

thanks pushpa.....i am trying for this only.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.