PDA

View Full Version : سوال: مشکل با دستور mysql_result



aratoos
چهارشنبه 14 خرداد 1393, 22:31 عصر
سلام ، من با دستور mysql-result ، 20 فیلد رو به طور تصادفی از دیتا بیسم میخوندم ، کد مشکلی نداشت جز اینکه یک سطر null تو دیتا بیس بود که اونو دوبتر تکرار می کرد ، وقتی اون سطرو حذف کردم کد دیگه کار نمیکنه
یعنی 20 تا فیلد متفاوت نمیخونه ، همون فیلد اول رو میبینه
<?php

$Question="select soal from soalat";
if (!$Question) die ('ارور کوئری');
$RunQuestion=mysql_query($Question);
$min=0; $max=mysql_num_rows($RunQuestion); $count=11;
function nonRepaetRandom($min,$max,$count)
{
if($max-$min <$count){
return false;
}

$nonrepeatarray = array();
for($i = 0; $i < $count; $i++)
{
$rand = rand($min,$max);

while(in_array($rand,$nonrepeatarray))
{
$rand = rand($min,$max);
}

$nonrepeatarray[$i] = $rand;
}
return $nonrepeatarray;
}
$random1=nonRepaetRandom($min,$max,$count);


?>
<label> 1-<?php echo mysql_result($RunQuestion,$random1[1] )."<br/>";?> </label> <br /> <br />
<?php $soal1= mysql_result($RunQuestion,$random1[1] );
$Qsoal1="select answera,answerb,answerc,answerd from soalat where soal='$soal1'";
if (!$Qsoal1) die ('ارور کوئری');
$RunQsoal1=mysql_query($Qsoal1);
while($s1=( mysql_fetch_array($RunQsoal1)))
{
?>
<input type="radio" name="r1" value="a" /><?php echo $s1['answera'] ?><br /> <br />
<input type="radio" name="r1" value="b" /><?php echo $s1['answerb'] ?><br /> <br />
<input type="radio" name="r1" value="c" /><?php echo $s1['answerc'] ?><br /> <br />
<input type="radio" name="r1" value="d" /><?php echo $s1['answerd'];} ?><br /> <br />

<!--/////////////////////////End OF Question 1///////////////////////////////////// -->


<label> 2-<?php echo mysql_result($RunQuestion,$random1[2])."<br/>"; ?></label> <br /> <br />
<?php $soal2= mysql_result($RunQuestion,$random1[2] );
$Qsoal2="select answera,answerb,answerc,answerd from soalat where soal='$soal2'";
if (!$Qsoal2) die ('ارور کوئری');
$RunQsoal2=mysql_query($Qsoal2);
while($s2=( mysql_fetch_array($RunQsoal2)))
{
?>
<input type="radio" name="r2" value="a" /><?php echo $s2['answera'] ?><br /> <br />
<input type="radio" name="r2" value="b" /><?php echo $s2['answerb'] ?><br /> <br />
<input type="radio" name="r2" value="c" /><?php echo $s2['answerc'] ?><br /> <br />
<input type="radio" name="r2" value="d" /><?php echo $s2['answerd']; } ?><br /> <br />

<!--/////////////////////////End OF Question 2///////////////////////////////////// -->



اینم کدمه ، ایرادش چیه الان ؟ :ناراحت: