insert data in to columns base on the selection of the list box.

insert data in to columns base on the selection of the list box.

am 03.04.2007 15:00:11 von sam rumaizan

--0-1317441266-1175605211=:93645
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit



Can you help me please?


1- I have created a while loop to populate the list box with the information of column1.
2-I need to update (add data) in to column2, column3, column4 base on the selection of the list box.


echo'

';



$query = "SELECT column1 FROM table";

$result = mysql_query($query);

echo"
";



echo"
";

echo"
";





echo"";

echo "";

$sql="UPDATE $tbl_name SET column2 = CONCAT(column2, '$_POST[column2]', column3 = CONCAT(column3, '$_POST[column3]',column4 = CONCAT(column4, '$_POST[column4]' WHERE Assign_Engineer ='".$_POST["R"]."'";


$result=mysql_query($sql);







---------------------------------
No need to miss a message. Get email on-the-go
with Yahoo! Mail for Mobile. Get started.
--0-1317441266-1175605211=:93645--

RE: insert data in to columns base on the selection of the list box.

am 03.04.2007 15:03:59 von Bill Bolte

When you say "update in to column2, column3..." are you referring to the
list boxes or database tables?

If it's the list boxes, are you wanting this to happen on the client
side? Or are you putting the data all out at once?



-----Original Message-----
From: sam rumaizan [mailto:samcalc@yahoo.com]=20
Sent: Tuesday, April 03, 2007 8:00 AM
To: php-windows@lists.php.net
Cc: php-windows-info@lists.php.net
Subject: [PHP-WIN] insert data in to columns base on the selection of
the list box.



Can you help me please?


1- I have created a while loop to populate the list box with the
information of column1.
2-I need to update (add data) in to column2, column3, column4
base on the selection of the list box.
=20

echo'

';

=20

$query =3D "SELECT column1 FROM table";

$result =3D mysql_query($query);

echo"
";

=20

echo"
";

echo"
";

=20

=20

echo"";

echo "";

$sql=3D"UPDATE $tbl_name SET column2 =3D CONCAT(column2, =
'$_POST[column2]',
column3 =3D CONCAT(column3, '$_POST[column3]',column4 =3D =
CONCAT(column4,
'$_POST[column4]' WHERE Assign_Engineer =3D'".$_POST["R"]."'";


$result=3Dmysql_query($sql);




=20

=20
---------------------------------
No need to miss a message. Get email on-the-go=20
with Yahoo! Mail for Mobile. Get started.

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: insert data in to columns base on the selection of the list box.

am 04.04.2007 07:20:21 von sam rumaizan

--0-2048406786-1175664021=:41567
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Thank you for your corroboration.
Maybe my question wasn’t clear. What I need to do is:
1- I have a table in mysql with column1(Last Name), column2(address), column3(phone Number), column4(job), column5(favorite food)
2- I have created a while loop to populate the list box in my webpage.
3- I have created text fields for address and phone Number in my webpage.
4- The list box will be populated with column1 (Last Name) of all the users registered in my database.
5- Let’s say one of the users want to change (update) his/her address, phone Number. He/she will choose the Last Name from the dropdown menu (list box)
6- he/she will fill the field in the page for address, phone Number with the new information.
7- The user will hit submit to update (change) the information in the database (mysql)

If this is not clear enough, I will try to post my code.


Bill Bolte wrote: When you say "update in to column2, column3..." are you referring to the
list boxes or database tables?

If it's the list boxes, are you wanting this to happen on the client
side? Or are you putting the data all out at once?



-----Original Message-----
From: sam rumaizan [mailto:samcalc@yahoo.com]
Sent: Tuesday, April 03, 2007 8:00 AM
To: php-windows@lists.php.net
Cc: php-windows-info@lists.php.net
Subject: [PHP-WIN] insert data in to columns base on the selection of
the list box.



Can you help me please?


1- I have created a while loop to populate the list box with the
information of column1.
2-I need to update (add data) in to column2, column3, column4
base on the selection of the list box.


echo' ';



$query = "SELECT column1 FROM table";

$result = mysql_query($query);

echo"
";



echo"
";

echo" ";





echo"";echo"Choose a Category:"; while ($line = mysql_fetch_array($result)) { foreach ($line as $value) { echo"}echo ">$value"; }echo "";

echo "";

$sql="UPDATE $tbl_name SET column2 = CONCAT(column2, '$_POST[column2]',
column3 = CONCAT(column3, '$_POST[column3]',column4 = CONCAT(column4,
'$_POST[column4]' WHERE Assign_Engineer ='".$_POST["R"]."'";


$result=mysql_query($sql);







---------------------------------
No need to miss a message. Get email on-the-go
with Yahoo! Mail for Mobile. Get started.

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php








---------------------------------
It's here! Your new message!
Get new email alerts with the free Yahoo! Toolbar.
--0-2048406786-1175664021=:41567--

Re: insert data in to columns base on the selection of the list box.

am 04.04.2007 08:43:47 von sam rumaizan

--0-1382494081-1175669027=:97132
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit


bedul,

This is what I need (don't worry about the variable names since they are different from my previous email.)



$page_title = 'Update Current Data';
include ('./includes/header.html');
include( '../mysql_connect.php' );
$tbl_name="lodata"; // Table name
echo'

';

$query = "SELECT Assign_Engineer FROM lodata";
$result = mysql_query($query);
echo"
";
echo"
";
echo"
";

echo"";
echo "";

echo'
';
if (isset($_POST['Submit'])) { .


if (eregi ('^[[:alpha:]\.\' \-]{2,15}$', stripslashes(trim($_POST['Job_Title'])))) {
$jt = escape_data($_POST['Job_Title']);
} else {
$jt = FALSE;
echo '

Please enter Job Descriptions!

';
}
if (eregi ('^[[:digit:]\.\' \-]{2,15}$', stripslashes(trim($_POST['ManhourSpent'])))) {
$mhs = escape_data($_POST['ManhourSpent']);
} else {
$mhs = FALSE;
echo '

Please enter Man hour Spent!

';
}

if (eregi ('^[[:alpha:]\.\' \-]{2,15}$', stripslashes(trim($_POST['Status'])))) {
$stat = escape_data($_POST['Status']);
} else {
$stat = FALSE;
echo '

Please enter Status!

';
}
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 "
";
}
else {
echo "ERROR.Please Try Again.";echo "
" . mysql_error();
}


}
}
echo "
";
echo "
";
echo "
";
echo"";
echo"";
echo"";
echo"";
echo"
";

echo"";

echo"";
echo"";
echo"";
echo"";
echo"";

echo"";
echo"";
echo"";
echo"";
echo"";
echo"";
echo"";
echo"";
echo"";
echo"";
echo"";
echo"
Job Title/Description";
echo'';
echo"
Manhour Spent";
echo'';
echo"
Status/Comments";
echo'';
echo"
";
echo'';
echo"
";
echo"";
echo"
";
mysql_close();



echo'
';
include ('./includes/footer.html');
echo'
';
?>







---------------------------------
Now that's room service! Choose from over 150,000 hotels
in 45,000 destinations on Yahoo! Travel to find your fit.
--0-1382494081-1175669027=:97132--

Re: insert data in to columns base on the selection ofthe list box.

am 04.04.2007 09:07:21 von php

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"";

will produce:



.... You need to use this code for the selectbox instead:

while ($line = mysql_fetch_array($result))
{
foreach ($line as $value)
{
echo"";
}
}


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:



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.)
>
> >
>
> $page_title = 'Update Current Data';
> include ('./includes/header.html');
> include( '../mysql_connect.php' );
> $tbl_name="lodata"; // Table name
> echo'

';
>
> $query = "SELECT Assign_Engineer FROM lodata";
> $result = mysql_query($query);
> echo"
";
> echo"
";
> echo"
";
>
> echo"";
> echo "";
>
> echo'
';
> if (isset($_POST['Submit'])) { .
>
>
> if (eregi ('^[[:alpha:]\.\' \-]{2,15}$', stripslashes(trim($_POST['Job_Title'])))) {
> $jt = escape_data($_POST['Job_Title']);
> } else {
> $jt = FALSE;
> echo '

Please enter Job Descriptions!

';
> }
> if (eregi ('^[[:digit:]\.\' \-]{2,15}$', stripslashes(trim($_POST['ManhourSpent'])))) {
> $mhs = escape_data($_POST['ManhourSpent']);
> } else {
> $mhs = FALSE;
> echo '

Please enter Man hour Spent!

';
> }
>
> if (eregi ('^[[:alpha:]\.\' \-]{2,15}$', stripslashes(trim($_POST['Status'])))) {
> $stat = escape_data($_POST['Status']);
> } else {
> $stat = FALSE;
> echo '

Please enter Status!

';
> }
> 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 "
";
> }
> else {
> echo "ERROR.Please Try Again.";echo "
" . mysql_error();
> }
>
>
> }
> }
> echo "
";
> echo "
";
> echo "
";
> echo"";
> echo"";
> echo"";
> echo"";
> echo"
";
>
> echo"";
>
> echo"";
> echo"";
> echo"";
> echo"";
> echo"";
>
> echo"";
> echo"";
> echo"";
> echo"";
> echo"";
> echo"";
> echo"";
> echo"";
> echo"";
> echo"";
> echo"";
> echo"
Job Title/Description";
> echo'';
> echo"
Manhour Spent";
> echo'';
> echo"
Status/Comments";
> echo'';
> echo"
";
> echo'';
> echo"
";
> echo"";
> echo"
";
> mysql_close();
>
>
>
> echo'
';
> include ('./includes/footer.html');
> echo'
';
> ?>
>
>
>
>
>
>
>
> ---------------------------------
> 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