浏览代码

joining table action

development
mauirixxx 8 年前
父节点
当前提交
72e4a91f20
共有 3 个文件被更改,包括 38 次插入32 次删除
  1. +34
    -29
      db/gw-treasure-history.sql
  2. +2
    -1
      gw-pull.php
  3. +2
    -2
      gw-toon.php

+ 34
- 29
db/gw-treasure-history.sql 查看文件

@@ -1,29 +1,34 @@
/*!40101 SET NAMES utf8 */;

/*!40101 SET SQL_MODE=''*/;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
/*Table structure for table `history` */

DROP TABLE IF EXISTS `history`;

CREATE TABLE `history` (
`historydate` date DEFAULT NULL,
`charname` varchar(19) DEFAULT NULL,
`location` varchar(20) DEFAULT NULL,
`goldrec` int(4) DEFAULT NULL,
`material` varchar(30) DEFAULT NULL,
`itemreq` int(2) DEFAULT NULL,
`itemtype` varchar(13) DEFAULT NULL,
`itemattribute` varchar(15) DEFAULT NULL,
`itemrarity` varchar(6) DEFAULT NULL,
`itemname` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*
SQLyog Ultimate v12.09 (64 bit)
MySQL - 5.5.52-MariaDB : Database - mauirixxx
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;
/*!40101 SET SQL_MODE=''*/;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
/*Table structure for table `history` */
CREATE TABLE `history` (
`historydate` date DEFAULT NULL,
`charnameid` int(11) DEFAULT NULL,
`locationid` int(2) DEFAULT NULL,
`goldrec` int(4) DEFAULT NULL,
`material` varchar(30) DEFAULT NULL,
`itemreq` int(2) DEFAULT NULL,
`itemtype` varchar(13) DEFAULT NULL,
`itemattribute` varchar(15) DEFAULT NULL,
`itemrarity` varchar(6) DEFAULT NULL,
`itemname` varchar(100) DEFAULT NULL,
`runetype` varchar(25) DEFAULT NULL COMMENT 'what type of rune is it (clarity, smiting prayers, axe mastery, etc'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

+ 2
- 1
gw-pull.php 查看文件

@@ -7,7 +7,8 @@ if ($con->connect_errno > 0){
die ('Unable to connect to database [' . $db->connect_errno . ']');
}
#$sql = "SELECT * FROM `history` WHERE `charname` = '$cnameid' ORDER BY `historydate` ASC"; //old sql statement that works currently
$sql = "SELECT history.*, treasurelocation.* FROM history LEFT OUTER JOIN treasurelocation ON history.`locationid` = treasurelocation.`treasureid` WHERE history.`charname` = '$cnameid' ORDER BY `historydate` ASC";
#$sql = "SELECT history.*, treasurelocation.* FROM history LEFT OUTER JOIN treasurelocation ON history.`locationid` = treasurelocation.`treasureid` WHERE history.`charname` = '$cnameid' ORDER BY `historydate` ASC"; //round 2 of SQL queries, saving this since it still works
$sql = "SELECT history.*, treasurelocation.*, playername.`playerid`, playername.`charname` FROM ((history INNER JOIN treasurelocation ON history.`locationid` = treasurelocation.`treasureid`) INNER JOIN playername ON history.`charnameid` = playername.`playerid`) WHERE history.`charnameid` = '$cnameid' ORDER BY `historydate` ASC";
if (!$result = $con->query($sql)){
die ('There was an error running the query [' . $con->error . ']');
}


+ 2
- 2
gw-toon.php 查看文件

@@ -13,11 +13,11 @@ if (!$result = $con->query($sql)){
} */
//will be changing weblink with GET data to SELECT box with POST data
echo '<FORM METHOD="POST" NAME="cselect" ACTION="gw-pull.php">';
echo '<SELECT name="cname">';
echo '<SELECT NAME="cname">';
while ($row = $result->fetch_array()){
$charid = $row['playerid'];
$charname = $row['charname'];
echo '<OPTION VALUE="' . $charname . '">' . $charname . '</OPTION>'; //need to change first charname variable to charid once I work out the SQL query
echo '<OPTION VALUE="' . $charid . '">' . $charname . '</OPTION>'; //need to change first charname variable to charid once I work out the SQL query
}
echo '<INPUT TYPE="SUBMIT" VALUE="Choose Toon"></FORM>'; //gw-pull doesn't accept post data yet. or does it?
?>

正在加载...
取消
保存