Jump to content
MakeWebGames

Random Multiple


Blade Maker

Recommended Posts

Sources forom Kirby:

<?php

include "globals.php";


$array = array($_POST['hidden']);
$rand_keys = array_rand(array_flip($array), 1);

echo $rand_keys;



$get1 = mysql_query("SELECT * FROM `inventory` WHERE inv_userid=1 ORDER BY inv_itemid DESC LIMIT 9999");



?>

<form method='POST' >

<?php
while ($row = mysql_fetch_assoc($get1)) { ?>

<input type='hidden' name='hidden' value='<?php echo $row['inv_itemid'];?>' /><?php } ?></form>

 

basically what he want is being able to pick 1 item out of the inventory. This is how I would do it:

include "globals.php";
// Retreive how many items the user have and then get a row number randomly
$r=mysql_query("select floor(count(*)*rand()) from inventory where inv_userid=1");
$row=mysql_fetch_row($r);
$nb=$row[0];

$r=mysql_query("select * from inventory where inv_userid=1 limit $nb,1");
$row=mysql_fetch_assoc($r);
// ... you must then continue
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...