Hello, Ive created a db for books,
In my form for book index register I dont know how many text boxes I have to put or how to do, when every time the index data is different, for example:
book_index
id,sub_id,chapter (table for chapters)
book_sub_index (table for a sub chapters)
id,sub_id(which will be = with book_index sub_id), sub_chapter.
in the form where the user will register the book index, I dont know how many textboxes or into db how many fields creat for this, becouse every time this will register different quantity pages or chapter etc...
Any advice and help please?
Thank you.
Book Index
Moderator: General Moderators
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Book Index
You could use a for loop based on a user entry.
e.g. use a text field so the user can enter in the quantity of fields they desire. Then use this quantity in the for loop:
With regard to the database, you could just use a sepearte record for each entry made by the user.
e.g. use a text field so the user can enter in the quantity of fields they desire. Then use this quantity in the for loop:
Code: Select all
for($x=0; $x<$field_qty; $x++){
//display text boxes
}Re: Book Index
You might want to save every chapter on a new table row depending on what the actual pages does.
[chapter]
id book_id chapter_text
[chapters]
id chapter_id name
Might want to have some kind of chapter # so you can change the order of the chapters afterwards.
[chapter]
id book_id chapter_text
[chapters]
id chapter_id name
Might want to have some kind of chapter # so you can change the order of the chapters afterwards.
-
Arsench2000
- Forum Commoner
- Posts: 38
- Joined: Sat Sep 15, 2007 8:18 pm
Re: Book Index
thank you very much friend for your replay, as Im a new in php world, can you please give the example with a little more details?aceconcepts wrote:You could use a for loop based on a user entry.
e.g. use a text field so the user can enter in the quantity of fields they desire. Then use this quantity in the for loop:
With regard to the database, you could just use a sepearte record for each entry made by the user.Code: Select all
for($x=0; $x<$field_qty; $x++){ //display text boxes }
regards
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Book Index
Code: Select all
for($x=0; $x<$field_qty; $x++){
//display text boxes
}
This is how a for loop typically works: for(set the counter; number of times to loop; increment counter)
if you never really know how many fields are required you could simply have the user specify how many they need - just like i've illustrated about with $field_qty.
Do you understand this?