私はPHPページを作成しており、そのページは私が持っている食肉包装のデータベース全体を印刷します。データベースの結果を形状(長方形、楕円形、正方形、挿入)の順に印刷しています。データベースに結果を出力させることはできますが、列の1つに対して実行したいのは、HTMLリンクに出力される結果を変更することです。
この列は「Imagename」で、サーバーに保存されているJPEGの名前を出力します。'Imagename'の結果がJPEGで印刷されたときに、テキストではなく、実際にはユーザーが表示できる画像を表示する新しいタブへのリンクになるようにしたいと思います。
これが私の現在のPHPで、データベースをループしてテーブルに出力します。
<?php
$con = mysql_connect("localhost", "horizon1", "");
mysql_select_db("horizon1_delyn", $con);
if ( ! $con)
{
die("Could not connect: " . mysql_error());
}
$rectangular = mysql_query("SELECT toolcode, description, traysize, imagename FROM range WHERE trayshape ='rectangular' ORDER BY traysize");
$oval = mysql_query("SELECT toolcode, description, traysize, imagename FROM range WHERE trayshape ='oval' ORDER BY traysize");
$square = mysql_query("SELECT toolcode, description, traysize, imagename FROM range WHERE trayshape ='square' ORDER BY traysize");
$insert = mysql_query("SELECT toolcode, description, traysize, imagename FROM range WHERE trayshape ='insert' ORDER BY traysize");
$fields_num = mysql_num_fields($rectangular);
echo "<table width='97%' border='0' cellspacing='0' cellpadding='0'><tr>";
//*RECTANGULAR*//
for ($i = 0; $i < $fields_num; $i++)
{
$field = mysql_fetch_field($rectangular);
echo "<td bgcolor='#E8CF24' style='font-family: arial;font-size: 12px;'>{$field->name}</td>";
}
echo "</tr>\n";
while ($row = mysql_fetch_row($rectangular))
{
echo "<tr>";
foreach ($row as $cell)
echo "<td style='font-family: arial;font-size:12px'>$cell</td>";
echo "</tr>\n";
}
mysql_free_result($rectangular);
//* OVAL *//
for ($i = 0; $i < $fields_num; $i++)
{
$field = mysql_fetch_field($oval);
echo "<td bgcolor='#E8CF24' style='font-family: arial;font-size: 12px'>{$field->name}</td>";
}
echo "</tr>\n";
while ($row = mysql_fetch_row($oval))
{
echo "<tr>";
foreach ($row as $cell)
echo "<td style='font-family: arial;font-size:12px'>$cell</td>";
echo "</tr>\n";
}
mysql_free_result($oval);
//* SQUARE *//
for ($i = 0; $i < $fields_num; $i++)
{
$field = mysql_fetch_field($square);
echo "<td bgcolor='#E8CF24' style='font-family: arial;font-size: 12px'>{$field->name}</td>";
}
echo "</tr>\n";
while ($row = mysql_fetch_row($square))
{
echo "<tr>";
foreach ($row as $cell)
echo "<td style='font-family: arial;font-size:12px'>$cell</td>";
echo "</tr>\n";
}
mysql_free_result($square);
//* INSERT *//
for ($i = 0; $i < $fields_num; $i++)
{
$field = mysql_fetch_field($insert);
echo "<td bgcolor='#E8CF24' style='font-family: arial;font-size: 12px'>{$field->name}</td>";
}
echo "</tr>\n";
while ($row = mysql_fetch_row($insert))
{
echo "<tr>";
foreach ($row as $cell)
echo "<td style='font-family: arial;font-size:12px'>$cell</td>";
echo "</tr>\n";
}
mysql_free_result($insert);
?>
ある意味で「Imagename」列を分離して画像をクリック可能にする方法を誰かが知っていますか?ご協力いただきありがとうございます?