Jump to content

Better Way to Show While List


abeswede

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/220564-better-way-to-show-while-list/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.