我已经为ID
和PHP文件创建了HTML表单。
输入ID
后,我想从PHP文件中获取ID
。
虽然我包括了<form action ="./index.php" method="get">
我无法获取数据。
我在PHP文件中使用了JSON脚本。
这是PHP形式index.php
<!--search-box-->
<div class="search-box">
<form action="./index.php" method="get">
<input class="sb-search-input input__field--madoka" name="teamid" placeholder="Enter Your Team ID" type="search" id="input-31" />
</form>
</div><!--//end-search-box-->
这是名为index.html
的php脚本
id == $PLAYERCODE) { return($playbas->web_name); } } } function GETPLAYERPOSITION($id) { $PLAYERCODE=$id; $playbasic=file_get_contents("https://fantasy.premierleague.com/drf/elements/"); $playerbasic=json_decode($playbasic); foreach ($playerbasic as $playbas) { IF ($playbas->id == $PLAYERCODE) { return($playbas->element_type); } } } function GETPLAYERFIXPOINTS($id,$fix) { $PLAYERCODE=$id; $ROUND=$fix; $play=file_get_contents("https://fantasy.premierleague.com/drf/element-summary/".$PLAYERCODE); $playerdata=json_decode($play); foreach ($playerdata->history as $plays) { IF ($plays->round == $ROUND) { return($plays->total_points); } } } $TEAMCODE=81882; $string = file_get_contents("https://fantasy.premierleague.com/drf/entry/".$TEAMCODE); $x=json_decode($string); $currentGW= $x->entry->current_event; echo '***************************************
'; echo '********* Header Information *********
'; echo '***************************************
'; echo 'Team Name: '.$x->entry->name.'
'; echo 'Overall Rank: '.$x->entry->summary_overall_rank.'
'; echo 'Overall Points: '.$x->entry->summary_overall_points.'
'; echo 'Team Value: '.(intval($x->entry->value+$x->entry->bank)/10).'
'; echo 'Total Transfers: '.$x->entry->total_transfers.'
'; echo '***************************************
'; echo '********* Player Game Week Data *********
'; echo '***************************************
'; $TOTAL_TRANSFER_COST=0; $TOTAL_CAPTAIN_POINTS=0; $TOTAL_BENCH_POINTS=0; $GW_BEST_CAPTAIN=0; $TOTAL_BEST_CAPTAIN_POINTS=0; $TOTAL_BEST_POSSIBLE_POINTS=0; $ORH=array(); $GRH=array(); $TVH=array(); $RSH=array(); $PSH=array(); $i=1; while ($i <= $currentGW) { $PICKS=file_get_contents("https://fantasy.premierleague.com/drf/entry/".$TEAMCODE."/event/".$i."/picks"); $weekdata=json_decode($PICKS); echo '
+++++++++++++++++++++++++++
'; echo 'GW: '.$i.'
'; echo 'GW Average Score: '.$weekdata->event->average_entry_score.'
'; echo 'GW Score: '.$weekdata->entry_history->points.'
'; echo 'GW Total Score: '.$weekdata->entry_history->total_points.'
'; echo 'GW Rank: '.$weekdata->entry_history->rank.'
'; echo 'GW Overall Rank: '.$weekdata->entry_history->overall_rank.'
'; echo 'GW Transfers: '.$weekdata->entry_history->event_transfers.'
'; echo 'GW Transfers Cost: '.$weekdata->entry_history->event_transfers_cost.'
'; echo 'GW Team Value: '.(($weekdata->entry_history->value+$weekdata->entry_history->bank)/10).'
'; echo 'GW Bench Points: '.$weekdata->entry_history->points_on_bench.'
'; $TOTAL_TRANSFER_COST=$TOTAL_TRANSFER_COST+$weekdata->entry_history->event_transfers_cost; $TOTAL_BENCH_POINTS=$TOTAL_BENCH_POINTS+$weekdata->entry_history->points_on_bench; $GW_BEST_CAPTAIN=0; $GW_CAPTAIN_POINTS=0; $BESTMULTI=1; $GK=array(); $CB=array(); $CM=array(); $FW=array(); $F=array(); foreach ($weekdata->picks as $pick) { $PLAYERPOINTS=GETPLAYERFIXPOINTS($pick->element,$i); $PLAYERPOSITION=GETPLAYERPOSITION($pick->element); $BESTMULTI=$BESTMULTI*$pick->multiplier; if ($GW_BEST_CAPTAIN<$PLAYERPOINTS) { $GW_BEST_CAPTAIN=$PLAYERPOINTS; } if ($pick->is_captain==1) { $GW_CAPTAIN_POINTS=$pick->multiplier*GETPLAYERFIXPOINTS($pick->element,$i); $TOTAL_CAPTAIN_POINTS=$TOTAL_CAPTAIN_POINTS+$GW_CAPTAIN_POINTS; } if ($PLAYERPOSITION==1) { $GK[count($GK)]=$PLAYERPOINTS; } if ($PLAYERPOSITION==2) { $CB[count($CB)]=$PLAYERPOINTS; } if ($PLAYERPOSITION==3) { $CM[count($CM)]=$PLAYERPOINTS; } if ($PLAYERPOSITION==4) { $FW[count($FW)]=$PLAYERPOINTS; } } $TOTAL_BEST_CAPTAIN_POINTS=$TOTAL_BEST_CAPTAIN_POINTS+$GW_BEST_CAPTAIN*$BESTMULTI; $i=$i+1; rsort($GK); rsort($CB); rsort($CM); rsort($FW); /* $F352 */ $F[0]=$GK[0]+$CB[0]+$CB[1]+$CB[2]+$CM[0]+$CM[1]+$CM[2]+$CM[3]+$CM[4]+$FW[0]+$FW[1]; /* $F343= */ $F[1]=$GK[0]+$CB[0]+$CB[1]+$CB[2]+$CM[0]+$CM[1]+$CM[2]+$CM[3]+$FW[0]+$FW[1]+$FW[2]; /* $F451= */ $F[2]=$GK[0]+$CB[0]+$CB[1]+$CB[2]+$CB[3]+$CM[0]+$CM[1]+$CM[2]+$CM[3]+$CM[4]+$FW[0]; /* $F442= */ $F[3]=$GK[0]+$CB[0]+$CB[1]+$CB[2]+$CB[3]+$CM[0]+$CM[1]+$CM[2]+$CM[3]+$FW[0]; /* $F433= */ $F[4]=$GK[0]+$CB[0]+$CB[1]+$CB[2]+$CB[3]+$CM[0]+$CM[1]+$CM[2]+$FW[0]+$FW[1]+$FW[2]; /* $F541= */ $F[5]=$GK[0]+$CB[0]+$CB[1]+$CB[2]+$CB[3]+$CB[4]+$CM[0]+$CM[1]+$CM[2]+$CM[3]+$FW[0]; /* $F532= */ $F[6]=$GK[0]+$CB[0]+$CB[1]+$CB[2]+$CB[3]+$CB[4]+$CM[0]+$CM[1]+$CM[2]+$FW[0]+$FW[1]; /* $F523= */ $F[7]=$GK[0]+$CB[0]+$CB[1]+$CB[2]+$CB[3]+$CB[4]+$CM[0]+$CM[1]+$FW[0]+$FW[1]+$FW[2]; rsort($F); echo 'GW CAPTAIN POINT: '.$GW_CAPTAIN_POINTS; echo '
GW BEST POSSIBLE CAPTAIN POINT: '.$GW_BEST_CAPTAIN*$BESTMULTI; echo '
GW BEST POSSIBLE POINTS: '.($F[0]+($GW_BEST_CAPTAIN*($BESTMULTI-1))); $TOTAL_BEST_POSSIBLE_POINTS=$TOTAL_BEST_POSSIBLE_POINTS+$F[0]+($GW_BEST_CAPTAIN*($BESTMULTI-1)); $ORH[count($ORH)]=$weekdata->entry_history->overall_rank; $GRH[count($GRH)]=$weekdata->entry_history->rank; $TVH[count($TVH)]=(($weekdata->entry_history->value+$weekdata->entry_history->bank)/10); $RSH[count($RSH)]=$weekdata->entry_history->points; $PSH[count($PSH)]=$F[0]+($GW_BEST_CAPTAIN*($BESTMULTI-1)); } echo '
total transfer cost: '.$TOTAL_TRANSFER_COST.'
'; echo 'total Captain Points: '.$TOTAL_CAPTAIN_POINTS.'
'; echo 'total Bench Points: '.$TOTAL_BENCH_POINTS.'
'; echo 'total Possible Captain Points: '.$TOTAL_BEST_CAPTAIN_POINTS.'
'; echo 'total Team Best Possible Points: '.$TOTAL_BEST_POSSIBLE_POINTS.'
'; echo 'ORH
'; echo $ORH[0].'
'; echo $ORH[1].'
'; echo $ORH[2].'
'; echo $ORH[3].'
'; echo 'GRH
'; echo $GRH[0].'
'; echo $GRH[1].'
'; echo $GRH[2].'
'; echo $GRH[3].'
'; echo 'TVH
'; echo $TVH[0].'
'; echo $TVH[1].'
'; echo $TVH[2].'
'; echo $TVH[3].'
'; echo 'RSH
'; echo $RSH[0].'
'; echo $RSH[1].'
'; echo $RSH[2].'
'; echo $RSH[3].'
'; echo 'PSH
'; echo $PSH[0].'
'; echo $PSH[1].'
'; echo $PSH[2].'
'; echo $PSH[3].'
'; ?>
答案 0 :(得分:0)
首先检查服务器上的php是否配置正确。制作一些小的php脚本,即仅打印phpinfo():
<?php
phpinfo();
命名为info.php
或其他名称,然后调用脚本。如果这不起作用,那么问题不在您的脚本中,而在服务器配置中。可能未正确配置,甚至根本没有安装。