如何用php代码自动填充mysql数据库查询?
数据库如下:
CREATE TABLE IF NOT EXISTS `scrore_table` (
`scores_id` int(11) NOT NULL auto_increment,
`scores_title` varchar(32) collate utf8_bin NOT NULL default '',
`scores` varchar(15) collate utf8_bin NOT NULL default '',
`decimal_place` char(1) collate utf8_bin NOT NULL,
`value` float(15,8) NOT NULL,
PRIMARY KEY (`currency_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1; ;
INSERT INTO `scrore_table` (`scrore_id`, `scrore_title`, `scores`, `decimal_place`, `value`) VALUES
(1, '', 'GameA0', '',),
(2, '', 'GameA1', '',),
(3, '', 'GameA2', '',),
..............................etc
(15, '', 'GameA15', '',);
成为基准(关键词)的是:分数,所以
IF found
scores = GameA0
then insert
scores_title = Game For Player A0
decimal_place = 2
value = 1.58030000
IF found
scores = GameA1
then insert
scores_title = Game For Player A1
decimal_place = 2
value = 158.030000
IF found
scores = GameA15
then insert
scores_title = Game For Player A15
decimal_place = 2
value = 0.31303000
等...
任何能帮助我的建议和指示我都很感激,非常感谢
最佳答案
一些教程可以从http://dev.mysql.com/doc/下载
这个例子:
if($scores == 'GameA0')
{
$scores_title = 'Game For Player A0';
$value = 1.58030000;
}
elseif($scores == 'Game15')
{
$scores_title = 'Gone ...';
$value = 0.31303000;
}
和表格:
mysql_query("UPDATE score_table SET score_title=".$score_title.", value=".$value." where scores=".$scores."";
关于php - 如何用php自动完成mysql数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4123660/