Moshambi
09-17-2008, 07:01 AM
Just curious how I would go about making the text match an image...this is what I have so far but it doesn't add it to the last image...and also the text is the same for all the images, which I want to be different (or whatever the user supplies):
<?php
if($_SESSION['loggedIn'] == "true")
{
if($action == "edit")
{
require("conn.php");
$img_sql = "select imagefolder from users where username = '$user'";
$img_result = mysql_query($img_sql) or die ( mysql_error() );
$imgfolder = mysql_result($img_result, 0);
$images = glob('./images/' . $imgfolder . '/*.PNG');
$pictext = "select pictext from users where username='$user'";
$pictext_result = mysql_query($pictext) or die (mysql_error());
$pictext = mysql_result($pictext_result, 0);
$i = true;
?>
<table style="position: relative; left: 35px;">
<?php
foreach($images as $img)
{
if($i == true)
{
//echo "<img src='" . $img . "' style='margin: 0px 5px 0px 5px; border: 1px solid black;' /><br /><input type='text' />";
echo "<tr><td><img src='" . $img . "' style='margin: 0px 5px 0px 5px; border: 1px solid black;' /></td>";
echo "<td style='display: block; width: 150px;'> </td>";
}
else
{
echo "<td><img src='" . $img . "' style='margin: 0px 5px 0px 5px; border: 1px solid black;' /></td></tr>";
echo "<tr>
<td>
<p>
". $pictext . "
</p>
</td>
<td style='display: block; width: 150px;'>
</td>
<td>
<p>" . $pictext ."
</p>
</td>
</tr>";
}
$i = !$i;
}
}
}
?>
</table>
Also I was wondering if there is a way to add an array-like field in MySQL, cuz I think that would help solve my problem. Thanks in advance!
<?php
if($_SESSION['loggedIn'] == "true")
{
if($action == "edit")
{
require("conn.php");
$img_sql = "select imagefolder from users where username = '$user'";
$img_result = mysql_query($img_sql) or die ( mysql_error() );
$imgfolder = mysql_result($img_result, 0);
$images = glob('./images/' . $imgfolder . '/*.PNG');
$pictext = "select pictext from users where username='$user'";
$pictext_result = mysql_query($pictext) or die (mysql_error());
$pictext = mysql_result($pictext_result, 0);
$i = true;
?>
<table style="position: relative; left: 35px;">
<?php
foreach($images as $img)
{
if($i == true)
{
//echo "<img src='" . $img . "' style='margin: 0px 5px 0px 5px; border: 1px solid black;' /><br /><input type='text' />";
echo "<tr><td><img src='" . $img . "' style='margin: 0px 5px 0px 5px; border: 1px solid black;' /></td>";
echo "<td style='display: block; width: 150px;'> </td>";
}
else
{
echo "<td><img src='" . $img . "' style='margin: 0px 5px 0px 5px; border: 1px solid black;' /></td></tr>";
echo "<tr>
<td>
<p>
". $pictext . "
</p>
</td>
<td style='display: block; width: 150px;'>
</td>
<td>
<p>" . $pictext ."
</p>
</td>
</tr>";
}
$i = !$i;
}
}
}
?>
</table>
Also I was wondering if there is a way to add an array-like field in MySQL, cuz I think that would help solve my problem. Thanks in advance!