これを試してください:
<?php
$games_sql = "SELECT id,col1,col2,now FROM tblname ORDER BY now ASC LIMIT 9";
$sth = $conn->query($games_sql);
$sth->setFetchMode(PDO::FETCH_ASSOC);
$gn=0;
while ($game_get = $sth->fetch()) {
$id = $game_get['id'];
$col1 = $game_get['col1'];
$col2 = $game_get['col2'];
$now = $game_get['now'];
$gametimeanddate = jdate("l d M y time G:i",$now);
$gamedate = jdate("l d M y",$now);
$gametime = jdate("G:i",$now);
//SAVE VALUES IN ARRAY
$items[] = array('id' => $id, 'col1' => $col1, 'col2' => $col2, 'now' => $now, 'gametimeanddate' => $gametimeanddate, 'gamedate' => $gamedate, 'gametime' => $gametime);
$gn++;
if(($gn%2)==0){
$class='background-color:#EEE';
}
}
?>
配列値の使用例:
<?php
echo '<table>';
foreach($items as $value)
{
echo '<tr>';
echo '<td>'. $value['id'] .'</td>';
echo '<td>'. $value['col1'] .'</td>';
echo '<td>'. $value['col2'] .'</td>';
echo '<td>'. $value['gametimeanddate'] .'</td>';
echo '<td>'. $value['gamedate'] .'</td>';
echo '<td>'. $value['gametime'] .'</td>';
echo '</tr>';
}
echo '</table>';
?>
あなたの例で:
<?php
foreach($items as $value)
{
echo $value['id']?>&title=<?php echo func1($value['col1']).'-'.func1($value['col2']);
}
?>
PDO:
PDOに関するいくつかの基本を学ぶためのいくつかの素晴らしいチュートリアル
編集:
配列値を変数に抽出できます。例:
<?php
$items = array("color" => "blue", "size" => "medium", "shape" => "sphere");
extract($items);
echo $color;
?>
あなたの例では、必要なのは
extract($game_get);