hi
ive been working on a new project to create an extensive database of islamic texts which users can include on their portal/forum systems without any restraints as to which portal or forum it is.
Now I have gotten pretty far..
- The DB is created and running A-OK
- The search function (http://path-to-peace.net/community/) works A-OK
But now I just cant figure out how to create an index for the data base to display each chapter stored in the DB and link to it as well....
to explain better, first have a look at this page (http://path-to-peace.net/community/testindex.php), where I used GROUP BY chapter number to produce a list of all the chapters in the DB
Now what I want to do next is that:
1 - the listing is displayed in 2 columns instead of one
2 - Each chapter is individually linked to show the ENTIRE content of that chapter
I do know how I can do that for a single chapter - but I need a more 'general code' so that it can be used for every chapter instead of using 114 bits of codes for 114 chapters.
Can someone help me with this please?
The DB structure is as follows: (comments in brackets [] to explain here)
Table is called: Quran
id int(11) NOT NULL auto_increment, [primary key]
sura varchar(12) default NULL, [This is the chapter name]
surano tinyint(4) default NULL, [this is the chapter number]
ayatno smallint(6) default NULL, [this is the verse number]
ayat mediumtext, [this is the text for the verses]
The code for the listing files is as follows:
<?
mysql_connect("**********","****","*****");
mysql_select_db("******");
//select table
$result = mysql_query("select surano,sura from quran GROUP BY surano");
echo"<table border='1' width='100%' id='table1' style='border-collapse: collapse' bordercolor='#000000'>";
//grab all the content
while($r=mysql_fetch_array($result))
{
$title=$r["surano"];
$message=$r["sura"];
//display the row
echo "<tr><td>$title - $message </td></tr>";
}
echo "</table>";
?>
any help appretiated please
aku
It's easiest to do columns this way:
Change
while($r=mysql_fetch_array($result))
{
$title=$r["surano"];
$message=$r["sura"];
//display the row
echo "<tr><td>$title - $message </td></tr>";
}
to
$i = 1;
while($r=mysql_fetch_array($result))
{
$title=$r["surano"];
$message=$r["sura"];
//display the row
if ($i%2)
echo "<tr><td>$title - $message </td>";
else
echo "<td>$title - $message </td></tr>";
++$i;
}
Normally, I'd also have to make allowances for if that last cell is empty, but in this case we know how many chapters there are and that there is an even number, so it's not a factor.
As for code for the full text of the chapters, if you've got it for one, you've got it for all. :) When you create your link to the chapter, add
;surano=##to the link, with ## being the number of the chapter. Near the beginning of your code, use
isset($_GET['surano']) ? $surano = $_GET['surano'] : $surano = 0;and when you do your search, use
if ($surano)
{
$result = mysql_query("SELECT * FROM quran WHERE surano = $surano ORDER BY ayatno");
}From the code you posted, it looks like you should be able to proceed from there.
Thanks! :D
I hope u dont mind if I put u in the credits list once im done? :D
I'm trying to learn this step by step and I havent even come to the really hard part yet and im cracking around the seams already..lol
As soon as I figure out the query for displaying a specific chapter only (since before I was using WHERE sura=1 (2,3 etc) in the query ) im gona try and join 2 tables and display the results from them
Then im gona use a count function to display the number of verses in each chapter
Then i intend to make a more complex search function where u can search BY chapter or simply have a whole chapter displayed using a drop down list
Then the final thing which I intend to do is to link to audio files using the chapter numbers in the query to correspond with the file names
and then to finish off - make a nice layout for it all in HTML and echo it out to display the final script - Free for all :D
--------------------------
Its my first ever php/mysql project but its fun....
Project Objectives:
- Create a fully searchable Quran in English and Arabic with Audio which can be used with any system since it will be in plain php
Wish me luck!
I would be honored to be listed in your credits. You seem to have a handle on where you're going and it's wise to take it one step at a time. Easier to find errors that way. :)
You know, you can have all of the code in one TP php article. The search and the list and the display and everything. I've just finished writing the code to display, search, list, add and edit reprints of magazine articles. All in one php article. I wouldn't begin to compare my fandom to your faith, but in the coding, it's the same idea, although you wouldn't have to worry about adding and editing your text.
Everything in the code I wrote is transferable to plain php code, except for the way I access the database (I use the SMF structure), and using the login information to restrict access to editing and adding articles. It really can all be done in one page.
If you need any more help, I'll be glad to see what I can do. You have quite a project ahead, especially for your first, but you'll come out of it being a real php expert. :)
Wow - so ur working on a module, thats great! Best wishes on that project of yours.
For me, now everythings come to a snail pace - since im havin much trouble makin simple queries i've decided to hit the books for a while :D
If i need any help I will just post here to let u know - thanks for ur offer :D