Edna duma: Difference between revisions

From Ilianko
No edit summary
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
edna duma sa [[dve]] dumi
<pre>
 
<?php
 
$con = mysql_connect('localhost', 'root', '3403a');
mysql_select_db("test", $con);
 
$tochki = 0;
 
if($_GET)
{
$result = mysql_query('SELECT * FROM `vyprosi` WHERE `status` = 1');
  while($row = mysql_fetch_assoc($result))
  {
    $query = 'SELECT * FROM `otgovori` WHERE id_vyprosi='.$row['id'].' AND status = 1';
    $result2= mysql_query($query);
    $otgovor = mysql_fetch_assoc($result2);
 
print $_GET[$row['id']].' == '.$otgovor['id'].'<br>';
 
    if ( $_GET[$row['id']] == $otgovor['id'])
    {
        $tochki++;
    }
     
  }
  print $tochki;
  exit();
}
 
 
?>
 
 
 
 
 
 
<form name="input" action="" method="get">
 
 
 
 
 
 
<?php
 
$result = mysql_query('SELECT * FROM `vyprosi` WHERE `status` = 1 ORDER BY RAND()');
 
$i=1;
while($row = mysql_fetch_assoc($result))
{
 
  print $i++.$row['vypros'].'<br />';
 
  $query = 'SELECT * FROM `otgovori` WHERE id_vyprosi='.$row['id'].' ORDER BY RAND()';
 
  $result2 = mysql_query($query);
     
         
  while($row1 = mysql_fetch_assoc($result2))
  {
print '<input type="radio" name="'.$row['id'].'" value="'.$row1['id'].'" />';   
 
print $row1['otgovor'].'<br />';
  }
             
}
 
?>
<input type="submit" value="Submit" />
</form>
 
</pre>
 
 
[[Category:ММС]]

Latest revision as of 15:20, 14 October 2011


<?php

$con = mysql_connect('localhost', 'root', '3403a');
mysql_select_db("test", $con);

$tochki = 0;

if($_GET)
{
$result = mysql_query('SELECT * FROM `vyprosi` WHERE `status` = 1');
  while($row = mysql_fetch_assoc($result))
  {
     $query = 'SELECT * FROM `otgovori` WHERE id_vyprosi='.$row['id'].' AND status = 1';
     $result2= mysql_query($query);
     $otgovor = mysql_fetch_assoc($result2); 

print $_GET[$row['id']].' == '.$otgovor['id'].'<br>';

     if ( $_GET[$row['id']] == $otgovor['id'])
     {
        $tochki++;
     }
       
  }
  print $tochki;
  exit();
}

 

?>






<form name="input" action="" method="get">






<?php

$result = mysql_query('SELECT * FROM `vyprosi` WHERE `status` = 1 ORDER BY RAND()');

$i=1;
while($row = mysql_fetch_assoc($result))
{

  print $i++.$row['vypros'].'<br />'; 
  
  $query = 'SELECT * FROM `otgovori` WHERE id_vyprosi='.$row['id'].' ORDER BY RAND()';

  $result2 = mysql_query($query);
      
           
  while($row1 = mysql_fetch_assoc($result2))
  {
print '<input type="radio" name="'.$row['id'].'" value="'.$row1['id'].'" />';     

print $row1['otgovor'].'<br />'; 
  }
              
}

?>
<input type="submit" value="Submit" />
</form>