リンクをクリックしたら、パラメータが変わって、出力される画像も切り変わる処理を
おこないたいです。
今、リンクをクリックすると、パラメータが上手く取れていなく、
phpの記述の仕方、$_GET,$_SERVER,変数の使用方法などを見直しているのですが、
ご教授いただける方おりましたら、アドバイスやご指摘をお願いいたします。
雑な記述と質問になってしまい申し訳ありません。
php
1<?php 2$array_category = array('1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg', '6.jpg', '7.jpg', '8.jpg', '9.jpg', '10.jpg'); 3shuffle($array_category); 4?> 5<!doctype html> 6<html> 7<head> 8<meta charset="UTF-8"> 9<title>sample</title> 10</head> 11<body> 12<?php 13$category = 'A'; 14echo '<table border="1" width="800px">' . "\n"; 15echo '<tr>' . "\n"; 16echo '<td width="200" align="center"><img src="' . $category . '/' . $array_category['0'] . '" width="190"></a></td>' . "\n"; 17echo '<td width="200" align="center"><img src="' . $category . '/' . $array_category['1'] . '" width="190"></td>' . "\n"; 18echo '<td width="200" align="center"><img src="' . $category . '/' . $array_category['2'] . '" width="190"></td>' . "\n"; 19echo '<td width="200" align="center"><img src="' . $category . '/' . $array_category['3'] . '" width="190"></td></tr>' . "\n"; 20echo '<tr>' . "\n"; 21echo '<td width="200"><img src="' . $category . '/' . $array_category['4'] . '" width="190"></td>' . "\n"; 22echo '<td colspan="2" align="center">' . "\n"; 23echo '★<a href=" . $_SERVER['PHP_SELF'] . '?A=1">A</a>  ' . "\n"; 24echo '★<a href="' . $_SERVER['PHP_SELF'] . '?B=2">B</a>  ' . "\n"; 25echo '★<a href="' . $_SERVER['PHP_SELF'] . '?C=3">C</a>  ' . "\n"; 26echo '</td>' . "\n"; 27echo '<td width="200" align="center"><img src="' . $category . '/' . $array_category['5'] . '" width="190"></td></tr>' . "\n"; 28echo '<tr>' . "\n"; 29echo '<td width="200" align="center"><img src="' . $category . '/' . $array_category['6'] . '" width="190"></td>' . "\n"; 30echo '<td width="200" align="center"><img src="' . $category . '/' . $array_category['7'] . '" width="190"></td>' . "\n"; 31echo '<td width="200" align="center"><img src="' . $category . '/' . $array_category['8'] . '" width="190"></td>' . "\n"; 32echo '<td width="200" align="center"><img src="' . $category . '/' . $array_category['9'] . '" width="190"></td>' . "\n"; 33echo '</tr>'; 34echo '</table>'; 35if ($_GET['A'] == 1) { 36 $category = 'A'; 37} 38else if ($_GET['B'] == 2){ 39 $category = 'B'; 40} 41else if ($_GET['C'] == 3){ 42 $category = 'C'; 43} 44?> 45</body> 46</html>
回答1件
あなたの回答
tips
プレビュー