anket php mysql sayaç

0 Cevap php

I am working on a small php/mysql survey. I have all my questions/answers/cateogries stored in a mysql db. I also have my categories stored in an array in my php script. categories array=("Person","A Mom","A Student","Somebody",etc) each category have 4 questions and 4 answers. there are 8 categories. a user answers the survey by moving from category 1, to the next category etc...

here is a sql query that i have hard coded the category 2, so that i can display the 4 questions that is associated with category 2: select a., b. from category a, questions b where a.id = b.id and a.id='2'

benim soru i dinamik "2" numarayı yapmak ister erecek. "NEXT" butonuna tıkladığında, ben bu gibi olmak için yeni sql sorgusu istiyorum zaman dinamik anlamı, burada:

a. , b. kategori A, sorular b nerede a.id = b.id ve a.id = '3 'seçeneğini

clicking on next button again goes to: select a., b. from category a, questions b where a.id = b.id and a.id='4' etc...

Aşağıda bir kod parçacığını:

 <?php
    $categories = array ("Person","A Mom","A Student","Somebody");

    $sql="select a.*, b.* from category a, questions b where a.id = b.id and a.id='2'";
    $result=mysql_query($sql,$db_connection);
    if (!$result)
    {
   die('Error: ' . mysql_error());
    }    
 ?>
  <tr>
    <td height="32" colspan="5" bgcolor="#ECA4DD"><b><?php echo $result['name'];?></b></td></tr>
  <tr>
  <tr>
    <td colspan="5" class="content_2"><?php echo $result['description'];?></td>
  </tr>
  <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

     <?php
    while ($row = mysql_fetch_assoc($result)) 
    {

 ?>

   <tr>
    <td class="content_2"><?php echo "Question1"; ?></td>
    <td align="center" valign="middle"><input type="radio" name="q1" id="s1" value="<?php echo $row['q1']; ?>"/> Rare </td>
    <td align="center" valign="middle"><input type="radio" name="q1" id="s1" value="<?php echo $row['q1']; ?>"/> Sometimes</td>
    <td align="center" valign="middle"><input type="radio" name="q1" id="s1" value="<?php echo $row['q1']; ?>"/> True</td>
    <td align="center" valign="middle"><input type="radio" name="q1" id="s1" value="<?php echo $row['q1']; ?>"/> Always</td>
  </tr>
  <tr>
       <td height="108"></td>
       <td align="center" valign="middle">&nbsp;</td>
       <td align="center" valign="middle">&nbsp;</td>
       <td colspan="2" align="right" valign="middle"><input type="submit" name="save" value="NextButton"/>
       </td>
      </tr>

   <?php
   mysql_free_result($result);
   }
  ?>      

 </form>

0 Cevap