我必须使用所有这些并显示所有这些
SELECT CONVERT(INT,cast(reverse(substring(char_data, 263, 2)) as BINARY(2))) FROM CHAR_DATA0 AS strength
SELECT CONVERT(INT,cast(reverse(substring(char_data, 265, 2)) as BINARY(2))) FROM CHAR_DATA0 AS wisdom
SELECT CONVERT(INT,cast(reverse(substring(char_data, 267, 2)) as BINARY(2))) FROM CHAR_DATA0 AS dexterity
SELECT CONVERT(INT,cast(reverse(substring(char_data, 269, 2)) as BINARY(2))) FROM CHAR_DATA0 AS charisma
SELECT CONVERT(INT,cast(reverse(substring(char_data, 271, 2)) as BINARY(2))) FROM CHAR_DATA0 AS intelligence
SELECT CONVERT(INT,cast(reverse(substring(char_data, 273, 2)) as BINARY(2))) FROM CHAR_DATA0 AS constitution
到目前为止,这是我的PHP代码, 我尝试使用相同的变量$ result添加另一个SQL查询,因此它也可以用于$ result的fetch,但是我没有得到任何。
// USING TOP for TEST
$SQL = "SELECT TOP 10 CONVERT(INT,cast(reverse(substring(char_data, 263, 2)) as BINARY(2))) FROM CHAR_DATA0 AS strength";
// Execute query:
$result = mssql_query($SQL)
or die('A error occured: ' . mysql_error());
echo "<table border='1'>
<tr>
<th>STR</th>
<th>WIS</th>
<th>DEX</th>
<th>CHA</th>
<th>INT</th>
<th>CON</th>
</tr>";
// Fetch rows:
while ($row = mssql_fetch_assoc($result)) {
echo "<tr>";
echo "<td>" . $row['strength'] . "</td>";
echo "<td>" . $row['wisdom'] . "</td>";
echo "<td>" . $row['dexterity'] . "</td>";
echo "<td>" . $row['charisma'] . "</td>";
echo "<td>" . $row['intelligence'] . "</td>";
echo "<td>" . $row['constitution'] . "</td>";
echo "</tr>";
}
任何建议,解决方案?我是新来的。谢谢。
----------------------------------------------- -编辑: 无论如何,我怎么这样排序?
SELECT CONVERT(INT,cast(reverse(substring(char_data, 263, 2)) as BINARY(2))) FROM CHAR_DATA0 AS strength SORT BY char_key WHERE CONVERT(INT, substring(char_data, 261, 1))=0x00 AS permission
答案 0 :(得分:1)
你正在做6个不同的sql查询atm。因此,您必须在代码中执行6 mysql_query
和mysql_fetch_assoc
。
只做一个查询:
SELECT
CONVERT(INT,cast(reverse(substring(char_data, 263, 2)) as BINARY(2))) AS strength,
CONVERT(INT,cast(reverse(substring(char_data, 265, 2)) as BINARY(2))) AS wisdom,
CONVERT(INT,cast(reverse(substring(char_data, 267, 2)) as BINARY(2))) AS dexterity,
CONVERT(INT,cast(reverse(substring(char_data, 269, 2)) as BINARY(2))) AS charisma,
CONVERT(INT,cast(reverse(substring(char_data, 271, 2)) as BINARY(2))) AS intelligence,
CONVERT(INT,cast(reverse(substring(char_data, 273, 2)) as BINARY(2))) AS constitution
FROM CHAR_DATA0