Dear all,
I have problem in extracting the list of image name such as 1-2, 2-2, 2-3
into 3 different image name to be displayed in a browser.
my ffirst index.php file is like this
<?php
include("include.php");
?>
<html>
<head>
<title><?php echo $titleheader;?></title>
<link rel="stylesheet" type="text/css" href="index.css">
</head>
<body>
<h1 align="center">.: Dermis:.</h1>
<h6 align="center">.:Picture Selection:.</h6>
<FORM NAME="fa" ACTION="viewimg.php" METHOD="POST">
<table width="92%" border="0" align="center">
<tr>
<td height="39"> </td>
<td width="89%"><font color="#000000"> </font></td>
</tr>
<tr>
<td width="11%"><strong><font color="#000099" size="2">Groups</font></strong></td>
<td><strong><font color="#000099" size="2">Picture Id
Insertion</font></strong></td>
</tr>
<tr>
<td><font color="#000000">Group 1 :</font></td>
<td><font color="#000000">
<input name="g1" type="text" value="" size="100">
</font></td>
</tr>
<tr>
<td><font color="#000000">Group 2 :</font></td>
<td><font color="#000000">
<input name="g2" type="text" id="g2" size="100">
</font></td>
</tr>
<tr>
<td><font color="#000000">Group 3 :</font></td>
<td><font color="#000000">
<input name="g3" type="text" id="g3" size="100">
</font></td>
</tr>
<tr>
<td><font color="#000000">Group 4 :</font></td>
<td><font color="#000000">
<input name="g4" type="text" id="g4" size="100">
</font></td>
</tr>
<tr>
<td><font color="#000000">Group 5:</font></td>
<td><font color="#000000">
<input name="g5" type="text" id="g5" size="100">
</font></td>
</tr>
<tr>
<td><font color="#000000">Group 6:</font></td>
<td><font color="#000000">
<input name="g6" type="text" id="g6" size="100">
</font></td>
</tr>
<tr>
<td> </td>
<td><div align="center">
<input type="submit" name="Submit" value="Submit">
</div></td>
</tr>
<tr>
<td><font color="#000000"> </font></td>
<td><font color="#000000"> </font> </td>
</tr>
</table>
</form>
<h3> </h3>
</body>
</html>
In this browser, user key in the name of the image list according to its group. the file will be directed to viewimg.php as to display the image(s) which has been input from the text box. all the data inserted to the mysql database then retrieve here as to seperated the image name (eg 1-1) from the commas(eg 1-1, 1-2, 1-3). here is the file for viewimg.php:
<?php
include("include.php");
?>
<?
$usr = "fauza";
$pwd = "fauza123";
$db = "dermis";
$host = "localhost";
# connect to database
$cid = mysql_connect($host,$usr,$pwd);
if (!$cid) { echo("ERROR: " . mysql_error() . "\n"); }
?>
<html>
<head>
<title><?php echo $titleheader;?></title>
<link rel="stylesheet" type="text/css" href="index.css">
</head>
<body>
<h1 align="center">.: Dermis:.</h1>
<h6 align="center">.:Picture Selection:.</h6>
<?
# this is processed when the form is submitted
# back on to this page (POST METHOD)
if ($REQUEST_METHOD=="POST") {
# double-up apostrophes
$description = str_replace("'","''",$description);
$sitename = str_replace("'","''",$sitename);
# setup SQL statement
$SQL = " INSERT INTO imggroup ";
$SQL = $SQL . " (userid, g1, g2, g3, g4, g5, g6) VALUES ";
$SQL = $SQL . " ('$userid', '$g1','$g2','$g3','$g4','$g5','$g6') ";
//$previous_name = session_name("$userid");
#execute SQL statement
$result = mysql_db_query($db,"$SQL",$cid);
# check for error
if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); }
echo ("<center><P><B>New Data has been added</B></P></center>\n");
}
?>
<?php
$result = mysql_query("select userid , g1 from imggroup where userid=".mysql_insert_id());
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo ' <table width="61%" border="0" align="center"><tr> <td colspan="2" bgcolor="#E6D9FF"><strong>';
printf("<font color=#000000 size=2>Group %s </font></strong></td></tr>", $row[0]);
echo ' <form name="form1" method="post" action=""><tr><td height="30" colspan="2"> ';
// printf("<p> User ID: %s Group 1: %s Group 2: %s Group 3: %s Group 4: %s Group 5: %s Group 6: %s </p>", $row[0], $row[1], $row[2], $row[3], $row[4], $row[5], $row[6]);
printf("<p> User ID: %s Group 1: %s </p>", $row[0], $row[1]);
// $img = printf("%s", $row[1]);
echo '</td></tr> <tr> <td height="23" colspan="2"><strong>Picture List</strong></td></tr><tr> <td height="216" colspan="2">';
printf ("<p><img src=dermisimg/%s.JPG width=150 height=210></p>\n\n Image ID = %s",$row[1],$row[1]);
// Delimiters may be slash, dot, or hyphen
$date = $row[1];
list($date) = split('[,.]', $date);
$count = count($date);
echo "img: $date; <br />\n";
echo "count: $count ; <br />\n";
/* string delimitedInfo = "100,200,400,3,67";
string[] discreteInfo = delimitedInfo.Split(new char[1] {','});
foreach (string Data in discreteInfo)
Console.WriteLine(Data);
*/
// $arr = array($img);
// foreach ($arr as $val) {
//printf ("<p><img src=dermisimg/%s.JPG width=150 height=210></p>\n\n Image ID = %s", $val,$row[1]);
// echo "<p><img src=dermisimg/$val.JPG width=150 height=210></p>\n";
//}
// echo '';
//printf("'", $row[1]);
//echo '</p>';
}
mysql_free_result($result);
?>
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td width="32%"><font color="#000000" size="2">Name of the group:</font></td>
<td width="68%"><font color="#000000">
<input name="g5" type="text" id="g5" size="55">
</font></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><font color="#000000" size="2">I put them into one group,
because... </font><font color="#000000"> </font></td>
</tr>
<tr>
<td colspan="2"><font color="#000000">
<textarea name="g6" cols="80" id="g6"></textarea>
</font></td>
</tr>
<tr>
<td><font color="#000000"> </font></td>
<td><div align="left"><font color="#000000">
<input type="submit" name="Submit" value="Submit">
</font> </div>
</form></td></tr>
</table>
<? mysql_close($cid);
?>
<h3> </h3>
</body>
</html>
the commented codes are the few method i used which didnt succed 🙁 sadd.. Anyone has any idea?? and suppose the viewimg will view 1st group images than will link to the other using array... how's da code.. anyone??