Jump to content

Shades

Members
  • Content Count

    17
  • Joined

  • Last visited

  • Days Won

    1

Shades last won the day on June 30

Shades had the most liked content!

Community Reputation

10 Good

1 Follower

About Shades

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Add this in your hospital page - $healcost = $r['level'] * 500; $cf = money_formatter($healcost); echo "[<a href='hospitalheal.php?ID={$r['userid']}'>Heal for {$healcost}</a>]"; create hospitalheal.php <?php define('PAGE_HEADER', 'Hospital: Heal'); require_once('globals.php'); echo "<h3><u>Hospital: Heal</u></h3>"; if ($ir['hopsital']) { echo "You cannot heal while in hospital."; exit($h->endpage()); } $_GET['ID'] = (isset($_GET['ID']) && is_numeric($_GET['ID'])) ? abs(intval($_GET['ID'])) : 0; $hospital_q = $db->query( "SELECT `userid`, `hospital`, `level`, `username` FROM `users` WHERE `userid` = {$_GET['ID']}"); if ($db->num_rows($hospital_q) == 0) { $db->free_result($hospital_q); echo "Invalid user."; exit($h->endpage()); } $r = $db->fetch_row($hospital_q); $db->free_result($hospital_q); if (!$r['hospital']) { echo "That user is not in hospital!"; exit($h->endpage()); } $cost = $r['level'] * 500; $cf = money_formatter($r['level'] * 500); if ($ir['money'] < $cost) { echo "Sorry, you do not have enough money to heal out {$r['username']}. You need {$cf}."; } echo "You successfully healed {$r['username']} out of hospital for {$cf}."; $db->query( "UPDATE `users` SET `money` = `money` - {$cost} WHERE `userid` = $userid"); $db->query( "UPDATE `users` SET `hospital` = 0 WHERE `userid` = {$r['userid']}"); event_add($r['userid'], "<a href='viewuser.php?u={$ir['userid']}'>{$ir['username']}</a> healed you out of hospital.", $c); $h->endpage(); ?> Hope this helps.
  2. Hello, from the help of @Magictallguy. THANK YOU!I have finally created two drop down lists which show the make and model of the vehicles from the database. However, know when I choose the make on the first drop down list I want it dynamically to show the second drop down list only specific for the make which has been chosen! However, I seem to be getting this wrong. If someone could help me out here would be appreciated search.php - <!DOCTYPE HTML> <head> <title>Car Search</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){ $('#cmMAKE').on('change', function(){ var cmMAKE = $(this).val(); if(cmMAKE){ $.ajax({ type:'POST', url:'searchAjax.php', data:'cmMAKE='+cmMAKE, success:function(html){ $('#cmMAKE').html(html); $('#cmMODEL').html('<option value="">Select make first</option>'); } }); }else{ $('#cmMAKE').html('<option value="">Select make first</option>'); $('#cmMODEL').html('<option value="">Select model first</option>'); } }); </script> </head> <?php error_reporting(E_ALL & ~E_NOTICE); require("config/config.php"); try { $database = new Connection(); $db = $database->openConnection(); $q = $db->prepare("SELECT COUNT(`avail`.`cID`) AS `total`, `make`.`cmMAKE` FROM `cars_available` AS `avail` INNER JOIN `car_makes` AS `make` ON `avail`.`cMAKE` = `make`.`cmID` GROUP BY `avail`.`cMAKE` ORDER BY `total` DESC, `make`.`cmMAKE` ASC"); $q->execute(); $data = $q->fetchAll(); ?> <table width = "50%"> <tr> <th><h3>SEARCH OUR CARS</h3></th> <th><h4>Make:</h4></th> <!-- <form name="searchcars" method="POST" action="searchsubmit.php"> --> <th> <select name="cmMAKE" id="cmMAKE"> <option value="">MAKE</option> <?php foreach ($data as $row): ?> <option><?=$row["cmMAKE"]?> (<?=$row["total"]?>)</option> <?php endforeach ?> </select> </th> <?php $q2 = $db->prepare("SELECT COUNT(`avail`.`cMODEL`) AS `total`, `model`.`cmoMODEL` FROM `cars_available` AS `avail` INNER JOIN `car_models` AS `model` ON `avail`.`cMODEL` = `model`.`cmoID` GROUP BY `avail`.`cMODEL` ORDER BY `total` DESC, `model`.`cmoMODEL` ASC"); $q2->execute(); $data2 = $q2->fetchAll(); ?> <th><h4>Model:</h4></th> <th> <select name="cmoMODEL" id="cmoMODEL"> <option value="">MODEL</option> <?php foreach ($data2 as $row2): ?> <option><?=$row2["cmoMODEL"]?> (<?=$row2["total"]?>)</option> <?php endforeach ?> </select> </th> <th><input type="submit" value="Submit"></th> </form> </tr> <table> <?php $database->closeConnection(); } catch (PDOException $e) { echo "There is some problem in connection: " . $e->getMessage(); } ?> </html> searchAjax.php - <?php error_reporting(E_ALL & ~E_NOTICE); require("config/config.php"); $cmMAKE = $_POST["cmMAKE"]; try { $database = new Connection(); $db = $database->openConnection(); if(!empty($_POST["cmMAKE"])) { // Fetch model data based on the specific make $q2 = $db->prepare("SELECT COUNT(`avail`.`cMODEL`) AS `total`, `model`.`cmoMODEL` FROM `cars_available` AS `avail` INNER JOIN `car_models` AS `model` ON `avail`.`cMODEL` = :cmMAKE GROUP BY `avail`.`cMODEL` ORDER BY `total` DESC, `model`.`cmoMODEL` ASC"); $q2->bindParam(":cmMAKE", $cmMAKE); $q2->execute(); $data2 = $q2->fetchAll(); ?> //$query = "SELECT * FROM states WHERE country_id = ".$_POST['country_id']." AND status = 1 ORDER BY state_name ASC"; //$result = $db->query($query); > // Generate HTML of state options list <?php foreach ($data as $row): ?> <option><?=$data2["cmoMODEL"]?> (<?=$row["total"]?>)</option> <?php endforeach ?> <? } $database->closeConnection(); } catch (PDOException $e) { echo "There is some problem in connection: " . $e->getMessage(); } ?>
  3. That's amazing Cruzer!
  4. It's alright anyway, I found my account details.
  5. The current providers have disappeared
  6. Does anyone have the latest files? I lost my account with the license. I can't get hold of it anymore 😞
  7. Shades

    Prison Reloaded

    Website, I registered twice...cause the first email wasn't appearing. I validated the account after the second signup. I can not login.
  8. Thank you so much! That works perfectly!!!
  9. DROP TABLE IF EXISTS `car_makes`; CREATE TABLE `car_makes` ( `cmID` int(11) NOT NULL AUTO_INCREMENT, `cmMAKE` varchar(50) NOT NULL DEFAULT '', PRIMARY KEY (`cmID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; LOCK TABLES `car_makes` WRITE; /*!40000 ALTER TABLE `car_makes` DISABLE KEYS */; INSERT INTO `car_makes` (`cmID`, `cmMAKE`) VALUES (1,'BMW'), (2,'Merc'), (3,'Toyoto'); /*!40000 ALTER TABLE `car_makes` ENABLE KEYS */; UNLOCK TABLES; # Dump of table car_models # ------------------------------------------------------------ DROP TABLE IF EXISTS `car_models`; CREATE TABLE `car_models` ( `cmoID` int(11) NOT NULL AUTO_INCREMENT, `cmoMODEL` varchar(50) NOT NULL DEFAULT '', PRIMARY KEY (`cmoID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; LOCK TABLES `car_models` WRITE; /*!40000 ALTER TABLE `car_models` DISABLE KEYS */; INSERT INTO `car_models` (`cmoID`, `cmoMODEL`) VALUES (1,'4 Series'); /*!40000 ALTER TABLE `car_models` ENABLE KEYS */; UNLOCK TABLES; # Dump of table cars_available # ------------------------------------------------------------ DROP TABLE IF EXISTS `cars_available`; CREATE TABLE `cars_available` ( `cID` int(11) NOT NULL AUTO_INCREMENT, `cMAKE` int(11) NOT NULL, `cMODEL` int(11) NOT NULL, PRIMARY KEY (`cID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; LOCK TABLES `cars_available` WRITE; /*!40000 ALTER TABLE `cars_available` DISABLE KEYS */; INSERT INTO `cars_available` (`cID`, `cMAKE`, `cMODEL`) VALUES (1,1,1), (2,2,1), (3,1,1); /*!40000 ALTER TABLE `cars_available` ENABLE KEYS */; UNLOCK TABLES;
  10. @Magictallguy- Hey, thanks again however, now besides it only shows 0 for each one. <?php error_reporting(E_ALL & ~E_NOTICE); require("config/config.php"); try { $database = new Connection(); $db = $database->openConnection(); $smt = $db->prepare("SELECT cm.cmID, cm.cmMAKE, COUNT(ca.cMAKE) AS total FROM car_makes AS cm LEFT JOIN cars_available AS ca ON cm.cmMAKE = ca.cMAKE GROUP BY cm.cmMAKE ORDER BY total DESC, cm.cmMAKE ASC"); $smt->execute(); $data = $smt->fetchAll(); ?> <select name="cmMAKE" id="cmMAKE"> <?php foreach ($data as $row): ?> <option><?=$row["cmMAKE"]?> (<?=$row["total"]?>)</option> <?php endforeach ?> </select> <?php $database->closeConnection(); } catch (PDOException $e) { echo "There is some problem in connection: " . $e->getMessage(); } ?>
  11. Hello @Magicaltallguy, thanks for the response. I still receive an error There is some problem in connection: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'cnt' in 'order clause'
  12. Hello all, so here I have is a drop down list of the `car_makes` e.g. BMW, Mercedes, Nissan, Audi and etc. So from another table called `cars_available` I want it to show the total of `car_makes` available. In the `cars_available` it has `cID`, `cMAKE`, `cMODEL` So where it says $total_rows I want it to show how many cars is available for each make. Please let me know how I would be able to do this or give me an example. <?php error_reporting(E_ALL & ~E_NOTICE); require("config/config.php"); try { $database = new Connection(); $db = $database->openConnection(); $smt = $db->prepare("SELECT * From `car_makes`"); $smt->execute(); $data = $smt->fetchAll(); ?> <select name="cmMAKE" id="cmMAKE"> <?php foreach ($data as $row): ?> <option><?=$row["cmMAKE"]?> (<?=$total_rows?>)</option> <?php endforeach ?> </select> <?php $database->closeConnection(); } catch (PDOException $e) { echo "There is some problem in connection: " . $e->getMessage(); } ?> <?php error_reporting(E_ALL & ~E_NOTICE); require("config/config.php"); try { $database = new Connection(); $db = $database->openConnection(); $smt = $db->prepare("SELECT * From `car_makes`"); $smt->execute(); $data = $smt->fetchAll(); $q = $db->prepare("SELECT `cmID`, `cMAKE`, COUNT(`ca`.`cMAKE`) AS `total` FROM `car_makes` AS `cm` INNER JOIN `cars_available` AS `ca` ON `cm`.`cmID` = `ca`.`cMAKE`"); $q->execute(); $query = $q->fetchAll(); ?> <?php foreach ($query as $info): ?> <?$count = $info["total"];?></option> <?php endforeach ?> <select name="cmMAKE" id="cmMAKE"> <?php foreach ($data as $row): ?> <option><?=$row["cmMAKE"]?> (<?=$count?>)</option> <?php endforeach ?> </select> <?php $database->closeConnection(); } catch (PDOException $e) { echo "There is some problem in connection: " . $e->getMessage(); } ?> Now I updated it, besides the car models it shows all of them as 2 available however, it should only be 2 available for one car model and the rest 0
  13. Try this, came across something similar to this. However, I don't know what I have outputted below will work. - <?php error_reporting(E_ALL & ~E_NOTICE); require("configuration/connect.php"); // Start XML file, create parent node $doc = new DOMDocument('1.0', 'UTF-8'); $node = $doc->createElement("markers"); try { $database = new Connection(); $db = $database->openConnection(); ///$sql = 'SELECT * FROM markers'; // Set the appropriate content-type header and output the XML //header('Content-type: text/xml'); $stmt = $db->prepare('SELECT * FROM markers'); $stmt->setFetchMode(PDO::FETCH_ASSOC); $stmt->execute(); $result = $stmt->fetchAll(); // Iterate through the rows, adding XML nodes for each foreach ($result as $row) { $entry = $doc->createElement('markers'); $entry->setAttribute('name', $row['bNAME']); $node->appendChild($entry); } $doc->appendChild($node); echo $doc->saveXML(); $database->closeConnection(); } catch (PDOException $e) { echo "There is some problem in connection: " . $e->getMessage(); } ?>
  14. Okay, seems like it would be better of with starting this myself. Would anyone give me advice or recommendations of how to start this off. I seriously want to get this done. If someone can just help me on how to start and what too look at to create a system like this. I would appericate if someone can help. Thank you, Shades.
  15. Is there still a market for this? Is there potential of making money?
×
×
  • Create New...