I don't get the purpose of your code. It's not looking right anywhere!
I'm guessing the select-box isn't working too well, right?
Let's say there's 4 $lines:
foreach ($line as $value)
{
echo"<OPTION value='$value'";
}
echo ">$value</OPTION>";
will produce:
<OPTION value='value1'<OPTION value='value2'<OPTION
value='value3'<OPTION value='value4'>value4</OPTION>
... You need to use this code for the selectbox instead:
while ($line = mysql_fetch_array($result))
{
foreach ($line as $value)
{
echo"<OPTION value='$value'>$value</OPTION>";
}
}
But, I must say, printing all columns as separate values in the select
box doesn't make any sense.
In a situation with this data in the database:
LastName PhoneNumber Address Job FavoriteFood
_________________________________________________________________________
Johnsson 12345 Superstreet Programmer Pizza
Gustavsson 54321 Miniway 42 Cleaner Chicken
Andersson 23456 Richstreet 2 Boss Noodles
Dood 45678 Projects Security Fajitas
you will get:
<SELECT name="R">
<OPTION value='Johnsson'>Johnsson</OPTION>
<OPTION value='12345'>12345</OPTION>
<OPTION value='Superstreet'>Superstreet</OPTION>
<OPTION value='Programmer'>Programmer</OPTION>
<OPTION value='Pizza'>Pizza</OPTION>
<OPTION value='Gustavsson'>Gustavsson</OPTION>
<OPTION value='54321'>54321</OPTION>
<OPTION value='Miniway 42'>Miniway 42</OPTION>
<OPTION value='Cleaner'>Cleaner</OPTION>
<OPTION value='Chicken'>Chicken</OPTION>
<OPTION value='Andersson'>Andersson</OPTION>
<OPTION value='23456'>23456</OPTION>
<OPTION value='Richstreet 2'>Richstreet 2</OPTION>
<OPTION value='Boss'>Boss</OPTION>
<OPTION value='Noodles'>Noodles</OPTION>
<OPTION value='Andersson'>Andersson</OPTION>
<OPTION value='45678'>45678</OPTION>
<OPTION value='Projects'>Projects</OPTION>
<OPTION value='Security'>Security</OPTION>
<OPTION value='Fajitas'>Fajitas</OPTION>
</SELECT>
Is that really what you're after?
Mike
sam rumaizan skrev:
bedul,
This is what I need (don't worry about the variable names since they are different from my previous email.)
<?php
$page_title = 'Update Current Data';
include ('./includes/header.html');
include( '../mysql_connect.php' );
$tbl_name="lodata"; // Table name
echo'<form>';
$query = "SELECT Assign_Engineer FROM lodata";
$result = mysql_query($query);
echo"<br>";
echo"<br>";
echo"<center>";
echo"<select NAME='R'>";
echo"<option value='NULL'>Choose Name :</option>
";
while ($line = mysql_fetch_array($result))
{
foreach ($line as $value)
{
echo"<OPTION value='$value'";
}
echo ">$value</OPTION>";
}
echo "</SELECT>";
echo "</form>";
echo'<form name="data" method="post" action="ucd.php">';
if (isset($_POST['Submit'])) { .
if (eregi ('^[[:alpha:]\.\' \-]{2,15}$', stripslashes(trim($_POST['Job_Title'])))) {
$jt = escape_data($_POST['Job_Title']);
} else {
$jt = FALSE;
echo '<p><font color="red" size="+1">Please enter Job Descriptions!</font></p>';
}
if (eregi ('^[[:digit:]\.\' \-]{2,15}$', stripslashes(trim($_POST['ManhourSpent'])))) {
$mhs = escape_data($_POST['ManhourSpent']);
} else {
$mhs = FALSE;
echo '<p><font color="red" size="+1">Please enter Man hour Spent!</font></p>';
}
if (eregi ('^[[:alpha:]\.\' \-]{2,15}$', stripslashes(trim($_POST['Status'])))) {
$stat = escape_data($_POST['Status']);
} else {
$stat = FALSE;
echo '<p><font color="red" size="+1">Please enter Status!</font></p>';
}
if ($jt && $mhs && $stat) {
$sql="UPDATE $tbl_name SET Job_Title = CONCAT(Job_Title, '$_POST[Job_Title]'),CONCAT(ManhourSpent, '$_POST[ManhourSpent]'),CONCAT(Status, '$_POST[Status]') WHERE Assign_Engineer ='SAR'";
$result=mysql_query($sql);
if($result){
echo "Your data have been submitted";
echo "<BR>";
}
else {
echo "ERROR.Please Try Again.";echo "<BR>" . mysql_error();
}
}
}
echo "<br>";
echo "<br>";
echo "<br>";
echo"<table width='500' border='0' align='center' cellpadding='0' cellspacing='1' bordercolor= 'CDCB98'>";
echo"<tr>";
echo"<td>";
echo"<table width='90%' border='1' cellspacing='1' cellpadding='3' bordercolor= 'CDCB98'>";
echo"<tr>";
echo"<td>Job Title/Description</td>";
echo"<td>";
echo'<textarea name="Job_Title" type="text" id="Job_Title" cols="30" rows="6"></textarea>';
echo"</td>";
echo"</tr>";
echo"<tr>";
echo"<tr>";
echo"<td>Manhour Spent</td>";
echo"<td>";
echo'<input name="ManhourSpent" type="text" id="ManhourSpent">';
echo"</td>";
echo"</tr>";
echo"<tr>";
echo"<td>Status/Comments</td>";
echo"<td>";
echo'<textarea name="Status" type="text" id="Status" cols="30" rows="6"></textarea>';
echo"</td>";
echo"</tr>";
echo"<tr>";
echo"<td colspan='3' align='center'>";
echo'<input class="sub" type="submit" name="Submit" value="Submit Data">';
echo"</td>";
echo"</tr>";
echo"</table>";
echo"</form>";
echo"</td>";
echo"</tr>";
echo"</table>";
mysql_close();
echo'<CENTER>';
include ('./includes/footer.html');
echo'</CENTER>';
?>
---------------------------------
Now that's room service! Choose from over 150,000 hotels
in 45,000 destinations on Yahoo! Travel to find your fit.
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php