ok. Im in the process of making a game. Well actually havent really started but heres what im asking now.
How can i select a random "monster" that is the users "level" to be displayed
the structure of the monster table is :
INSERT INTO `monsters` (`mon_id`, `mon_name`, `mon_level`, `mon_hp`, `mon_dam`, `mon_xp`) VALUES
(1, 'Level 1 a', '1', '50', '12', '10'),
(2, 'Level 1 b', '1', '75', '8', '10'),
(2, 'Level 1 c', '1', '60', '10', '10');
heres what i have so far :
<?php
include("/../../wamp/www/test/includes/db_connect.php");
include("/../../wamp/www/test/includes/userauth.php");
//if(isset($_POST['fight']) {
$sql = "SELECT * from monsters where mon_level = $userlevel";
$query = mysql_query($sql);
$randmon = mysql_num_rows($query);
$monid = rand(1,$randmon);
echo $monid;
?>
This will only work for "level" 1 "monsters" because it selects a random number between 1 and the number of rows in the query.
I was wonderign if there was a way to assign a variable to the lowest mon_id and the highest mon_id with a query or something.
Thanks in advance 😃