abeswede Posted December 3, 2010 Share Posted December 3, 2010 I have a site I am building that pulls in questions related to a book. In my database I have up to 21 questions for each book and a type associated with each question (personal, philosophical, etc.). I have a check box next to each question that gets marked each time the user asks the question. The way I am serving it up right now means that if a book has 12 questions it will show 9 blank boxes after the question. How do I get rid of those boxes if there are less than 21 questions? If it helps I also have a field in my database for "question_count" Here is my current method for getting the questions from the database: $result = mysql_query("SELECT photo,author_1,publisher,published_year,title,isbn10,question_1,question_1_type,question_2,question_2_type,question_3,question_3_type,question_4,question_4_type,question_5,question_5_type,question_6,question_6_type,question_7,question_7_type,question_8,question_8_type,question_9,question_9_type,question_10,question_10_type,question_11,question_11_type,question_12,question_12_type,question_13,question_13_type,question_14,question_14_type,question_15,question_15_type,question_16,question_16_type,question_17,question_17_type,question_18,question_18_type,question_19,question_19_type,question_20,question_20_type,question_21,question_21_type,question_count FROM book_list where isbn13=$isbn"); ?> Here is how I call each of the questions from the database to display them (right now I have this happening 21 times): <div class="question_<?php mysql_data_seek( $result, 0 ); while($row = mysql_fetch_row($result)) { echo $row[7];}?>"><img class="delete" border="0"/><div class="questiontype"><?php mysql_data_seek( $result, 0 ); while($row = mysql_fetch_row($result)) { echo $row[7];}?></div><div class="question"><?php mysql_data_seek( $result, 0 ); while($row = mysql_fetch_row($result)) { echo $row[6];}?></div></div> Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/220564-better-way-to-show-while-list/ Share on other sites More sharing options...
fenway Posted December 5, 2010 Share Posted December 5, 2010 You need to re-think your table design first. Quote Link to comment https://forums.phpfreaks.com/topic/220564-better-way-to-show-while-list/#findComment-1143278 Share on other sites More sharing options...
abeswede Posted December 5, 2010 Author Share Posted December 5, 2010 Any tips for how to better organize a table like that that has up to 20 questions with each question having a category type? Quote Link to comment https://forums.phpfreaks.com/topic/220564-better-way-to-show-while-list/#findComment-1143357 Share on other sites More sharing options...
fenway Posted December 5, 2010 Share Posted December 5, 2010 You need another table of cateorgies, and another of questions. Quote Link to comment https://forums.phpfreaks.com/topic/220564-better-way-to-show-while-list/#findComment-1143369 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.