Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.