List Info

Thread: pleeez !! so easy but???!




pleeez !! so easy but???!
user name
2006-02-11 23:04:11
hi
I have this function to print each question and it`s answar
/ actually
from 2 tables answers and questions /

I am taking the "question id"   to be the
"answer parent_id",so that I
can know each question and its answers..... ok!!

the quey like this:

function display (){
$sql="SELECT * from answers,questions WHERE
answers.parent_id=questions.question_id";
$exe=mysql_query($sql);
while ($row=mysql_fetch_assoc($exe))
{
				echo $row['answer']."<br>";
				echo $row['quest']."<br>";

}
}
display();

the problem is.. in this way the question will be printed
more than one
time , in another word the questios will be printed each
time its
answer printed !!!

SO how I can print the question just one time???!!!
pleeeez !!!
thank you very much my frnds !!!

pleeez !! so easy but???!
user name
2006-02-12 02:55:34
Easy answer:

$ct=0;
while ($row=mysql_fetch_assoc($exe))
{
                    &nbsp;          echo $row['answer']."<br>&quot;;
&nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; if($ct = 0) {
                    &nbsp;          &nbsp; &nbsp;  echo $row['quest'].&quot;<br&gt;";
 &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; $ct++;

}



On 2/11/06, Beshoo <gmail.com">basheermorogmail.com> wrote:

hi
I have this function to print each question and it`s answar / actually
from 2 tables answers and questions /

I am taking the "question id"&nbsp;  to be the "answer parent_id&quot;,so that I
can know each question and its answers..... ok!!

the quey like this:

function display (){
$sql=&quot;SELECT * from answers,questions WHERE
answers.parent_id=questions.question_id";
$exe=mysql_query($sql);
while ($row=mysql_fetch_assoc($exe))
{
 &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;  echo $row['answer']."&lt;br>&quot;;
 ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp; echo $row['quest'].&quot;<br&gt;";

}
}
display();

the problem is.. in this way the question will be printed more than one
time , in another word the questios will be printed each time its
answer printed !!!

SO how I can print the question just one time???!!!
pleeeez !!!
thank you very much my frnds !!!




--
Gary Every
&quot;Pay it Forward!&quot;
pleeez !! so easy but???!
user name
2006-02-24 12:11:45
hi,

Question is why are there two tables? is it possible to have
 more than
one answer for a question? If not, then one table with a
Question_ID,Question,Answer would probably help.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Professional PHP Developers"
group.
To post to this group, send email to Professional-PHPgooglegroups.com
To unsubscribe from this group, send email to
Professional-PHP-unsubscribegooglegroups.com
For more options, visit this group at http:
//groups.google.com/group/Professional-PHP
-~----------~----~----~----~------~----~------~--~---

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )