niroshan;10949772 wrote:Hi etymole,
take a look at here.
refer to the yankee at gmeil dot com comment.
Regards,
niroshan
Thanks Niroshan
That little snippet of code is great. However, I'm having trouble getting it to work with my form as I have single quoted it (following a book).
As it's quoted I cant get the foreach loop to work, although everything else works.
The $row and $row2 mentioned are declared before the form is started.
// Create the form.
echo '<h2>Edit a User</h2>
<form action="edit_user.php" method="post">
<table><tr><td><p>First Name: </td>
<td><input type="text" name="first_name" size="15" maxlength="15" value="' . $row[0] . '"/></p></td></tr>
<tr><td><p>Last Name: </td>
<td><input type="text" name="last_name" size="15" maxlength="30" value="' . $row[1] . '"/></p></td></tr>
<tr><td><p>Email Address: </td>
<td><input type="text" name="email" size="20" maxlength="40" value="' . $row[2] . '"/> </p></tr>
<tr><td><p>Sex: </td>
<td>
while ($row2=mysql_fetch_row($result2))
{
<select name=sex>
foreach(explode("','",substr($row2[1],6,-2)) as $v)
{
print("<option>$v</option>");
}
</select>
}
<tr><td><p>About me: </td>
<td><input type="text" name="about_me" size="20" maxlength="40" value="' . $row[3] . '"/> </p></tr></table>
<p><input type="submit" name="submit" value="Submit" class = "submit" /></p>
<input type="hidden" name="submitted" value="TRUE" />
<input type="hidden" name="id" value="' . $id . '" />
</form>';
I know this is a very scrappy excuse, I do apologise, I am new to PHP and haven't quite grasped quotes properly yet.
The snippet works perfectly outside of the form, however, I need it to be within the form to be submitted when everything else is.
Can you help me?
I wonder if I'm just missing a few quotations marks myself and thats all there is to get the while and foreach loops to work within the quotes...:-s
P.S. I'm half Sri Lankan. My family are from Negombo. :-)