I'm having some listing data issues.
Database Schema :
Here is my code :
SQL Query :
SELECT tblquestions.Question,
tblhints.hint,
tblhints.pic,
tblquestions.Id
FROM tblquestions INNER JOIN tblhints ON tblquestions.GroupId = tblhints.GroupId ORDER BY RAND() LIMIT 57
It gives an output like:
in tblquestions the fields recording like :
Php Code :
<?php
$i=0;
$t=0;
for ($i=0; $i < 57 ; $i++) {
while($kayitlar_rs = mysql_fetch_array($kayitlar)) {
// $toplamkayit = mysql_num_rows($kayitlar);
$soruGroupId = $kayitlar_rs["GroupId"];
$hint = $kayitlar_rs["hint"];
$sorufoto = $kayitlar_rs["pic"];
// $sorubtntxt = array();
$sorusql = mysql_query("select * from tblquestions where GroupId=".$soruGroupId);
while($soruRs = mysql_fetch_array($sorusql)) {
$sorubtntxt[] = $kayitlar_rs["Question"];
}
// die();
$i = $i+1;
$t = $t+1;
?>
HTML/DIVs :
<div id="soru<?=$i?>">
<span class="hint hintbg hintyazi">İPUCU: <b class="orange"><?=$hint?></b></span>
<div class="sorufoto"><img src="../assets/ulke/<?=$sorufoto?>"></div>
<span class="soruId"><?=$soruId?></span>
<div id="sorubtn" class="font">
<div id="soruBtnSol"><a class="sorubtn<?=$i?>" href="#"><span class="sorubtnTxtSol"><?=$sorubtntxt[0]?></span></a></div>
<div id="soruBtnSag"><a class="sorubtn<?=$t?>" href="#"><span class="sorubtnTxtRight"><?=$sorubtntxt[1]?></span></a></div>
</div>
</div>
What i want to do is :
1) To get datas from **tblhints**
and connect them to tblquestions GroupId to take records which has same GroupId .. Each record has to list hint
, pic
from tblhints. And every single record has two options to list like in the 3th. image (tblquestions). I've tried to do but i couldn't make it.
2) There is also $i
and $t
attributes to count every record on my page. $i
is counting each record, $t for two options which we get from tblquestions.
None of them are working properly.
Any suggestions?