Nieuw lid |
|
Ik heb een script waarbij random id's uit een select worden gehaald. Er is een limit van 10 resultaten. Dit lukt prima het probleem is echter dat ik de id's in de volgende volgorde wil echoen:
5, 9, 1,2, 3,4,7,8,6, 10
uitwerking staat op: http://www.pentagram.nl/tarot_beta.php
Hoe doe ik dit:
script is:
<?
include ("connect.php");
?>
<head>
<script>
function setKaart(id) {
var totaal,teller,tjek,value;
totaal = 10;
devalue = "";
for (teller=1;teller<totaal+1;teller++) {
if (document.getElementById('kaart'+teller).value==""&&devalue=="") {
document.getElementById('kaart'+teller).value=id;
devalue = teller;
}
}
if (devalue==totaal) {
document.getElementById('submit').style.display='inline';
}
}
</script>
</head>
<body>
<?
$teller=1;
foreach ($_POST AS $name => $value) {
$query = mysql_query("SELECT * FROM tarot where id = '$value' " );
$i=0;
echo "<table><tr><td></td></tr>";
while($obj = mysql_fetch_object($query)){
echo "<tr><td>";
echo "<img src='images/tarot/$obj->id.jpg' align='left' width='120' height='213'>";
echo $obj->kaart;
echo "<br>";
echo $obj->omschrijving;
echo "</p></tr></td>";
}
}
echo "</table>";
?>
<form method="post" name="form" action="tarot_beta.php">
<?
$aantal = 10;
$i=0;
for ($i=1;$i<$aantal+1;$i++) {
?>
<input type="hidden" READONLY name="kaart<?=$i?>" id="kaart<?=$i?>">
<?
}
$query = mysql_query("SELECT * FROM tarot ORDER BY RAND()" );
$i=0;
echo "<table width='470' cellpadding='7' cellspacing='2'><tr>";
while($obj = mysql_fetch_object($query)){
$i++;
?>
<input type="submit" id="submit" name="submit" label="uitslag" style="display:none;">
</form>
<td onClick="setKaart('<? echo $obj->id; ?>'); this.style.backgroundColor='#4C96E5';"><input type="image" name="kaart<?=$i?>" id="kaart<?=$i?>" src="images/card_back.jpg" border="0"></td>
<? if ($i == 15 ) {
echo "<tr></tr>";
}
?>
<? if ($i == 30) {
echo "<tr></tr>";
}
?>
<? if ($i == 45) {
echo "<tr></tr>";
}
?>
<? if ($i == 60) {
echo "<tr></tr>";
}
?>
<? if ($i == 75) {
echo "<tr></tr>";
}
?>
<? } ?>
</tr>
</body>
</html>
<? include ("connect.php"); ?> <head> <script> function setKaart(id) { var totaal,teller,tjek,value; totaal = 10; devalue = ""; for (teller=1;teller<totaal+1;teller++) { if (document.getElementById('kaart'+teller).value==""&&devalue=="") { document.getElementById('kaart'+teller).value=id; devalue = teller; } } if (devalue==totaal) { document.getElementById('submit').style.display='inline'; } } </script> </head> <body> <? $teller=1; foreach ($_POST AS $name => $value) { $query = mysql_query("SELECT * FROM tarot where id = '$value' " ); $i=0; echo "<table><tr><td></td></tr>"; echo "<img src='images/tarot/$obj->id.jpg' align='left' width='120' height='213'>"; } } ?> <form method="post" name="form" action="tarot_beta.php"> <? $aantal = 10; $i=0; for ($i=1;$i<$aantal+1;$i++) { ?> <input type="hidden" READONLY name="kaart<?=$i?>" id="kaart<?=$i?>"> <? } $query = mysql_query("SELECT * FROM tarot ORDER BY RAND()" ); $i=0; echo "<table width='470' cellpadding='7' cellspacing='2'><tr>"; $i++; ?> <input type="submit" id="submit" name="submit" label="uitslag" style="display:none;"> </form> <td onClick="setKaart(' <? echo $obj->id; ?>'); this.style.backgroundColor='#4C96E5';"><input type="image" name="kaart <?=$i? >" id="kaart <?=$i? >" src="images/card_back.jpg" border="0"></td> <? if ($i == 15 ) { } ?> <? if ($i == 30) { } ?> <? if ($i == 45) { } ?> <? if ($i == 60) { } ?> <? if ($i == 75) { } ?> <? } ?> </tr> </body> </html>
Twopeak-edit Gebruik nou eens [ code] tags!!!!!!!!!!!!
|