高尔夫障碍网站

时间:2015-11-19 06:49:20

标签: php html

你能帮助我吗?我正在开发一个高尔夫障碍网站。但是我对PHP语言的了解并不是很多,我只是PHP的初学者。 我需要记录每个高尔夫球员的所有得分并计算20场比赛中最好的10个得分以获得差点得分。不是10分最低分,而是10分最高分。我已经研究了一个月,但我无法获得高尔夫差点的确切代码和逻辑。请帮帮我。



var popupElement = '<div class="btn-group" role="group"><button class="btn btn-sm btn-default" id="regbtn"><span class="glyphicon glyphicon-registration-mark"></button><button class="btn btn-sm btn-default" id="copyrightbtn"><span class="glyphicon glyphicon-copyright-mark"><span></button><button class="btn btn-sm btn-default" id="trademarkbtn"><sup>TM</sup></button></div><div class="btn-group" role="group"><button class="btn btn-sm btn-default" id="deposee"><sup>MD</sup></button><button class="btn btn-sm btn-default" id="decommerce"><sup>MC</sup><span></button><button class="btn btn-sm btn-default" id="degreebtn">&#176;</button></div>';
var lastPoint=0;
$('#popbutton').popover({
    animation: true,
    content: popupElement,
    html: true
});

function textbox()
{
    var ctl = document.getElementById('symboltext');
    var startPos = ctl.selectionStart;
    var endPos = ctl.selectionEnd;
    lastPoint = startPos;
    return {s:startPos,e:endPos};
}

function getVal(insert){
   var val=$("#symboltext").val();
    var index = textbox();
    val = val.slice(0,index.s) + insert + val.slice(index.s)
    lastPoint+=2;
    return val;
}

$(document).on('click', "#trademarkbtn", function () {
   var val=getVal("\u2122 ");
    var input=$("#symboltext");
    input.val(val).focus();
    input[0].selectionStart = input[0].selectionEnd = lastPoint;
});


$(document).on('click', "#regbtn", function () {
     var val=getVal("\u00AE ");
   var input=$("#symboltext");
    input.val(val).focus();
    input[0].selectionStart = input[0].selectionEnd = lastPoint;
});

$(document).on('click', "#copyrightbtn", function () {
      var val=getVal("\u00A9 ");
    var input=$("#symboltext");
    input.val(val).focus();
    input[0].selectionStart = input[0].selectionEnd = lastPoint; 
});
$(document).on('click', "#deposee", function () {
      var val=getVal("\u1F16B");
    var input=$("#symboltext");
    input.val(val).focus();
    input[0].selectionStart = input[0].selectionEnd = lastPoint; 
});
$(document).on('click', "#decommerce", function () {
      var val=getVal("\u1F16A");
    var input=$("#symboltext");
        input.val(val).focus();
    input[0].selectionStart = input[0].selectionEnd = lastPoint; 
});
$(document).on('click', "#degreebtn", function () {
      var val=getVal("\u00B0");
    var input=$("#symboltext");
    input.val(val).focus();
    input[0].selectionStart = input[0].selectionEnd = lastPoint; 
});
&#13;
<?php
include "class.agolfhandicap.php";
include "conn.php";
$gh=new agolfhandicap();


// Get the user name if submitted.
if(isset($_POST['user'])){
 $user=$_POST['user'];
 $gh->setuser($user);
}
if(isset($_POST['delete'])){          //delete the record
  $id=$_POST['id'];
  $gh->deleteGame($id);
}
if(isset($_POST['edit'])){           //edit the record
  $id=$_POST['id'];
}
// If no user yet, ask for it.
if(!isset($_POST['user'])){
print "<form name='user' action='$_SERVER[PHP_SELF]' method='POST'>";
 print "Enter your user name:<input type='text' name='user' size='20'>";
 print "<input type='hidden' name='hid' value='true'>";
 print "<input type='submit' value='Submit' name='submits'>";
 print "</form>";
}else{
// We have a username, so get new game data and display handicap and all games.
print "<h2>Golf Game Database and Handicap Calculator for $user</h2>\n";
@$newgame=$gh->getnewgame($id);
@$id=($_POST['edit']=="")? "":$id;
$gh->showform($id);
$hc=$gh->gethcap();
print ($hc==0)?"<h3>You need at least 5 games for a handicap index.</h3>":"<h3>Handicap for $user is $hc</h3><br>";
// If you just want the data without displaying it, use next line.
//$al=$gh->getAll();
$gh->showall();
}
?>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

假设您将游戏分数存储在数据库中,您只需查询分数并按分数降序排序查询,并将结果限制为10。