0

I have a complete list of a topics.
I have to create a Index for A B C D E ...
On Clicking those buttons without navigating to another page it shows only topics wich starts from that letter...
How to code it in php???

4
Contributors
17
Replies
18
Views
7 Years
Discussion Span
Last Post by kirtan_thakkar
Featured Replies
  • Hi, This should get you started. [CODE] <?php if ($handle = opendir(foldername)) { while (false !== ($file = readdir($handle))) { if(substr($file,0,1) == $_GET["start"]) echo $file."\n"; } closedir($handle); } ?> [/CODE] Your link should be like this, [url]http://www.website.com/open.php?start=a[/url] for letter A. And change the foldername to your folder. Regards, Al Read More

0

suppose your page is post.php
So for A button link should be http://doimain.com/post.php?start=a

So your query will be dynamic like below:

<?php
if(isset($_GET['start']))
{
    $sql ="select * from table name WHERE name LIKE '".$_GET['start']."%'";
}
else
{
   $sql="select * from table";
}
?>

Hope this helps
Avinash

0

suppose your page is post.php
So for A button link should be http://doimain.com/post.php?start=a

So your query will be dynamic like below:

<?php
if(isset($_GET['start']))
{
    $sql ="select * from table name WHERE name LIKE '".$_GET['start']."%'";
}
else
{
   $sql="select * from table";
}
?>

Hope this helps
Avinash

Thanks for the post but i am not using mysql...
Is there any other way to do this..

0

So what are you using for your backend???

I have created text files and using php to open it and show that text into webpage.
There are categories for the topics so I have to create it on the index page..

0

Hi,

Do you have naming conventions for this text files?

Regards,
Al

naming conventions?? What's that??

0

You can have a CSS (style) based system if you're not using a backend (files/DB) of any type. This means that you use php to set a classname on a div. This method isn't advised though because all your data is loaded into the page, but only a particular section (say div B) is visible to the user.

If you don't want to use a DB - an include file system would be your best bet, linked with a querystring ($_GET).

Edited by diafol: n/a

0

You can have a CSS (style) based system if you're not using a backend (files/DB) of any type. This means that you use php to set a classname on a div. This method isn't advised though because all your data is loaded into the page, but only a particular section (say div B) is visible to the user.

If you don't want to use a DB - an include file system would be your best bet, linked with a querystring ($_GET).

I am trying to say tha As if I have list of Countrys As like this:

australia
canada
europe
japan
usa
france
germany
italy
spain
asia
china
mexico
oceania
africa
netherlands
india
switzerland
sweden
singapore
ireland
brazil
england
invisible
austria
parties
belgium
thailand
norway
malaysia
finland
denmark
birthdays
uk
taiwan
college
russia
portugal

And on the page I will put A B C D ..
on clicking on A script should have to show the names which are starting from A...
And also With Hyperlink on it..

1

Hi,

This should get you started.

<?php
if ($handle = opendir(foldername)) {
    while (false !== ($file = readdir($handle))) {
	if(substr($file,0,1) == $_GET["start"])
		echo $file."\n";
    }

    closedir($handle);
}
?>

Your link should be like this, http://www.website.com/open.php?start=a for letter A.

And change the foldername to your folder.

Regards,
Al

Edited by ivatanako: n/a

0

Hi,

This should get you started.

<?php
if ($handle = opendir('joomla')) {
    while (false !== ($file = readdir($handle))) {
	if(substr($file,0,1) == "c")
		echo $file."\n";
    }

    closedir($handle);
}
?>

Regards,
Al

Oh thanks I have understood...
Thank you so much buddy..

Edited by kirtan_thakkar: n/a

0

hey..
Is there any way to put a hyperlink on that list like..
After clicking on "A" I got Australia and Austria. Is there any way to put a link on Australia and Austria..
If I have created folders like these..
country > Australia, Austria
And in each folder I have index.php file.
So can I put a link like it <a href=mysite.com/country/$file>
That $file is the directory which he has fond on the country directory..

0

Yes,

echo "<a href='mysite.com/country/".$file."'>".$file."</a>\n";

Edited by ivatanako: n/a

0

Yes,

echo "<a href='mysite.com/country/".$file."'>".$file."</a>\n";

Thanks........................

0

Every one of you are bonkers. I didn't follow a single lime of the last couple of threads. But there again, I'm exceedingly ....

0

Every one of you are bonkers. I didn't follow a single lime of the last couple of threads. But there again, I'm exceedingly ....

What was that???

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.