PHP/MYSQL随机足球赛程表
我的足球经理锦标赛需要帮助。 我试图将在游戏中注册的所有团队随机插入到名为“时间表”的表中。 数据库将包含列 id、team1、team2、日期、时间。 我知道如何手动执行此操作,但如果有 50 个团队并找出他们希望没有挑战的团队,则需要花费很多时间。以及如何让所有球队每天都打一场比赛。
<?php
mysql_query("INSERT INTO timetable (id, team1, team2, date, time) VALUES ('','Blue','Red','2011-02-06','18.00')")
?>
我知道我的英语不是最好的,但我希望你能懂。 无论如何谢谢,
I need help with my football manager tournament.
I am trying to insert all teams that are registered in the game into a table called "timetable" randomly.
The database will have the columns id, team1, team2, date, time.
I know how to do this manually but it will take to much time if it's like 50 teams and to figure out wish team they haven't challenge. And how to make that all teams play one match everyday.
<?php
mysql_query("INSERT INTO timetable (id, team1, team2, date, time) VALUES ('','Blue','Red','2011-02-06','18.00')")
?>
I know my English is not the best but I hope you get it.
Thanks any way,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我了解你的问题,你希望每支球队都与其他球队比赛吗?这很简单。只需循环遍历团队即可。
您可能还想编写一个匹配日期计算算法。
如果您的 $teams 数组是用户提供的,出于安全原因,您可能希望使用 mysql_real_escape_string() 转义您的输入。
有关安全性的详细信息,请阅读 关于 mysql_real_escape_string( ) 和/或 google 有关 SQL 注入的信息
As far as I have understood your question, you want every team to play against every other team? This is simple. Just loop over the teams.
You might also want to write a match date calculation algorithm.
If your
$teams
array is user supplied you probably want to escape your inputs withmysql_real_escape_string()
for security reasons.For details about security, please read the PHP manual about mysql_real_escape_string() and/or google about SQL injection