0

7 列を含む html テーブルがあります。データは XML フィードから取得され、フィード内のアイテムに対してループする必要があります。次の方法で PHP 変数を割り当てます。

foreach ($xml->Game as $Game) { 
  $Date = $Game->Date; $AwayTeam = $Game->AwayTeam;

// 次に、counted for ループの下で変数に配列を割り当てます。

for($i=0; $i<$count; $i++){
    $arrayDate = $Date;
}

PHP を使用して、次のようなテーブルの配列をエコーし​​ました。echo "<td>arrayDate[$i]</td>";

ただし、3 つの列では、配列と共にチェックボックスを表示する必要があります。

チェックボックスとarrayValueを同じセルに表示する方法はありますか? PHP、JQuery、および HTML オプションに柔軟に対応できます。

<?php  
require_once('db-config.php');
// rss page for Testing -  
$feed_url = "http://www.sportsbooks.com/lines/cgi/lines.cgi?tem=parse&sport=203&ct=text/xml&type=";
$xml = simplexml_load_file($feed_url);
//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
$arrayDate = array('');
$arrayLine = array('');
$arrayLineStrip = array('');
$arrayOverPrice = array('');
$arrayUnderPrice = array('');
$arrayARotation = array('');
$arrayHRotation = array('');
$arrayAwayTeam = array('');
$arrayHomeTeam = array('');
$arrayAwayTeamPrice = array('');
$arrayHomeTeamPrice = array('');
$arrayAwayTeamMoneyLine = array('');
$arrayHomeTeamMoneyLine = array('');
$Date = (string)$xml->Date;
$AwayTeam = (string)$xml->AwayTeam;
$HomeTeam = (string)$xml->HomeTeam;
$AwayRotation = (string)$xml->AwayRotation;
$HomeRotation = (string)$xml->HomeRotation;
$Total = (string)$xml->Total;
$OverPrice = (string)$xml->OverPrice;
$UnderPrice = (string)$xml->UnderPrice;
$Line = (string)$xml->Line;
$AwayTeamPrice = (string)$xml->AwayTeamPrice;
$HomeTeamPrice = (string)$xml->HomeTeamPrice;
$AwayTeamMoneyLine = (double)$xml->AwayTeamMoneyLine;
$HomeTeamMoneyLine = (double)$xml->HomeTeamMoneyLine;
$Title = (string)$xml->Title;
?>
<html>
<div style="font-family:arial; font-size:.8em;"> 
<table id="nfl-main-1" cellpadding="0" cellspacing="0" border="1" bordercolor="#585858" width=100%>
<td>
<table id="nfl-main-2 border=1 cellpadding="0" cellspacing="0" width="100%">
<tr><td colspan="7"><table border=0 width=100% cellspacing=0 cellpadding=0><tr>
<td bgcolor="#585858" align="center" width=100%><h2 style="color:white; font-size: 16px"><?php echo $Title; ?></td>
</tr></table></td></tr>
<tr>
<div style="font-family:arial; font-size:.8em; color:white;"> 
<th>Date</th>
<th>    </th>
<th>#</th>
<th>Team</th>
<th>Money</th>
<th>Spread</th>
<th>Total</th>
</tr>       
</div>
</table>
</div>
</table>
</html>
<?php>
// # items to display 
$count = 20; 
// Characters from each item 
$char = 200; 
echo '<table cellpadding="0" align="left" cellspacing="0" border="1" bordercolor="#585858" width=100%>';
foreach ($xml->Game as $Game) { 
$Date = $Game->Date; $AwayTeam = $Game->AwayTeam; $HomeTeam = $Game->HomeTeam; $AwayRotation = $Game->AwayRotation;
$HomeRotation = $Game->HomeRotation; $Total = $Game->Total; $OverPrice = $Game->OverPrice;
$UnderPrice = $Game->UnderPrice; $Line = $Game->Line; $AwayTeamPrice = $Game->AwayTeamPrice;
$HomeTeamPrice = $Game->HomeTeamPrice; $AwayTeamMoneyLine = $Game->AwayTeamMoneyLine; $HomeTeamMoneyLine = $Game->HomeTeamMoneyLine;
for($i=0; $i<$count; $i++){
$AwayTeamSpread = " ";
$HomeTeamSpread = " ";
$arrayDate = $Date;
$arrayARotation = $AwayRotation;
$arrayHRotation = $HomeRotation;
$arrayAwayTeam = $AwayTeam;
$arrayHomeTeam = $HomeTeam;
$arrayTotal = $Total;
$arrayLine = $Line;
$arrayOverPrice = $OverPrice;
$arrayUnderPrice = $UnderPrice;
$arrayAwayTeamMoneyLine = $AwayTeamMoneyLine;
$arrayHomeTeamMoneyLine = $HomeTeamMoneyLine;
$arrayAwayTeamPrice = $AwayTeamPrice;
$arrayHomeTeamPrice = $HomeTeamPrice;
$arrayLine = $Line;
$LineStrip = str_replace("-", " ",$arrayLine);

if($arrayHomeTeamMoneyLine>0);
{
$AwayTeamSpread = "-";
$HomeTeamSpread = "+";
}
if($arrayAwayTeamMoneyLine>0);
{
$AwayTeamSpread = "+";
$HomeTeamSpread = "-";
}
echo '<tr>';
echo "<td>$arrayDate[$i]</td><td><table><tr><td>$arrayARotation[$i]</td></tr><tr><td>$arrayHRotation[$i]</td></tr></table></td><td><table><tr><td>$arrayAwayTeam[$i]</td></tr><tr><td>$arrayHomeTeam[$i]</td></tr></table></td><td><table><tr><td>$arrayAwayTeamMoneyLine[$i]</td></tr><tr><td>$arrayHomeTeamMoneyLine[$i]</td></tr></table></td><td><table><tr><td>$AwayTeamSpread $LineStrip ($arrayAwayTeamPrice)</td></tr><tr><td>$HomeTeamSpread $LineStrip ($arrayHomeTeamPrice)</td></tr></table></td><td><table><tr><td>Over $arrayTotal</td></tr><tr><td>Under $arrayTotal</td></tr></table></td>";
echo '</tr>';
echo '</table>';
echo '<table cellpadding="0" align="left" cellspacing="0" border="1" bordercolor="#585858" width=100%>';
echo '<tr>';
echo "<td>$arrayDate[$i]</td><td><table><tr><td>$arrayARotation[$i]</td></tr><tr><td>$arrayHRotation[$i]</td></tr></table></td><td><table><tr><td>$arrayAwayTeam[$i]</td></tr><tr><td>$arrayHomeTeam[$i]</td></tr></table></td>";
echo '<tr>';
}
}
?>
<form>
<td><input type="checkbox" name="AwaySpread[]" value="<?php echo '$arrayDate' ?>"><?php echo $count ?><br></td>
<input type="checkbox" name="HomeSpread[]" value="HomeSpread"><br>  
<input type="checkbox" name="Over[]" value="Over"><br> 
<input type="checkbox" name="Under[]" value="Under"><br> 
<input type="checkbox" name="AwayMoneyLine[]" value="AwayMoneyLine"><br> 
<input type="checkbox" name="HomeMoneyLine[]" value="HomeMoneyLine"><br>
<input type="submit" name="Continue" value="Continue"><br>
</form>
</html>
4

1 に答える 1

0

このようなものを使用してみませんか。

echo "<td><input type='checkbox'/> arrayDate[$i] </td>";
于 2012-10-26T02:39:31.740 に答える