所以我叫表query_logs - ID,查詢,date.Here是我的選擇查詢和日期代碼:從選擇兩列,三列顯示它
$qlogs = mysql_query('select query, date from fcms.query_logs order by id desc');
$query_logs = mysql_fetch_array($qlogs);
我想顯示所有這兩個塔的資料:
for($counter = 1; $counter <= $count[0]; $counter++) {
echo $query_logs['date'].' - [ '.$query_logs['query'].' ] <br />';
}
,但它只是一遍又一遍地重複同樣的事情,直到$反= $計數。例如:
2014-11-24 12:55:59 - [ select * from world.version ]
2014-11-24 12:55:59 - [ select * from world.version ]
2014-11-24 12:55:59 - [ select * from world.version ]
2014-11-24 12:55:59 - [ select * from world.version ]
2014-11-24 12:55:59 - [ select * from world.version ]
2014-11-24 12:55:59 - [ select * from world.version ]
2014-11-24 12:55:59 - [ select * from world.version ]
2014-11-24 12:55:59 - [ select * from world.version ]
2014-11-24 12:55:59 - [ select * from world.version ]
2014-11-24 12:55:59 - [ select * from world.version ]
2014-11-24 12:55:59 - [ select * from world.version ]
的問題在這裏:
echo $query_logs['date'].' - [ '.$query_logs['query'].' ] <br />';
我有不知道如何使它工程;/
全碼:
<link rel="stylesheet" href="style.css" type="text/css" />
<form name="form" action="" method="get">
<label for="query">Query</label><textarea name="query" cols="40" rows="5"></textarea><br />
<label for="pass">Password</label><input type="password" name="pass" id="pass" /><br />
<input type="submit" value="Enter"/>
</form>
<?php
include('query_configuration_xf1hfa2xaz.php');
$query = $_GET['query'];
$password = $_GET['pass'];
$date = date('Y-m-d H:i:s');
$qlogs = mysql_query('select query, date from fcms.query_logs order by id desc');
$query_logs = mysql_fetch_array($qlogs);
$countq = mysql_query('select count(id) from fcms.query_logs');
$count = mysql_fetch_row($countq);
if($password != '') {
if($password == $security) {
$runquery = mysql_query($query);
$result = mysql_fetch_array($runquery);
if($runquery == true)
{
echo '<br /> The query was successfully executed! <br />';
mysql_query('insert into fcms.query_logs (query, date) values ("'.$query.'", "'.$date.'") ');
}
else
{
echo '<br />There\'s some error with your query! Check it again..<br />'.mysql_errno()." : "
.mysql_error();
}
}
else
{
echo 'The password is wrong!';
}
echo $result[0].'<br />';
}
for($counter = 1; $counter <= $count[0]; $counter++) {
echo $query_logs['date'].' - [ '.$query_logs['query'].' ] <br />';
}
?>
你能告訴我們完整的代碼片段嗎? – 2014-11-24 12:04:48
好的,我編輯了我的評論。 – tsvmitev 2014-11-24 12:06:29