0

这是代码:

$sorular_hepsi = mysql_query("select * from tblsorular where hafta=1 order by rand() limit 1");
$soru_ust = mysql_fetch_assoc($sorular_hepsi);
$soru_id = $soru_ust_rs["id"];
$soru_grup_id = $soru_ust["sId"];
$sorular = mysql_query("select * from tblsorular where sId=$soru_grup_id");
$sorular_rs=mysql_fetch_array($sorular);

这是我的数据库架构:

id   soru   sId   hafta
==   ====   ===   =====
1    xxxx    4      1
2    yyyy    4      1
3    zzzz    5      1

我的查询

<?php       
$soru1 = $sorular_rs["soru"];
$soru2 = $soru_ust["soru"];
?>

编辑 我想得到 soru1=xxxx 和 soru2=xxxx 值,但我知道我必须在第二个查询中提出一些额外的请求,就像查询.... and id<>$id的 en 一样。它无法工作。

编辑-2

我做了类似的事情:

$sorular_hepsi = mysql_query("select * from tblsorular group by sId order by rand() limit 2");
    while($soru_ust = mysql_fetch_assoc($sorular_hepsi)) {

    echo "<pre>";
    print_r($soru_ust);

这是结果:

Array
(
    [id] => 45
    [soru] => İznik Çinisi
    [sId] => 23
    [hafta] => 1
)
Array
(
    [id] => 31
    [soru] => Maraş Biberi
    [sId] => 16
    [hafta] => 1
)

在这里您可以看到 sId 值。23 和 16。我只想列出相同的组元素。

苦苦挣扎!

有什么建议么?

4

0 回答 0