php-windows Digest 4 Apr 2007 18:42:11 -0000 Issue 3182

Topics (messages 27619 through 27625):

Re: insert data in to columns base on the selection of the list box.
        27619 by: sam rumaizan
        27620 by: Mikael Grön
        27621 by: Mikael Grön

Sessions?
        27622 by: Gustav Wiberg
        27623 by: Mikael Grön
        27624 by: trystano.aol.com

Re: confirm unsubscribe from [email protected]
        27625 by: Bill Bolte

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
 
  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.

--- End Message ---
--- Begin Message ---
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.

--- End Message ---
--- Begin Message ---
Well, simply put (not really following your structure):

--- code ---
<?php
   if (isset($_POST['R'])):
      $address = addslashes($_POST['address']);
      $phone = addslashes($_POST['phone']);
      $lastname = addslashes($_POST['R']);
$sql = "update $tablename set address = '$address', phone = '$phone' where LastName = '$lastname';";
      if (mysql_query($sql)):
         echo "Updated " . $_POST['R'] . "<br />\n";
      else:
         echo "Error: " . mysql_error();
      endif;
   endif;
?>
<html>
<head>
</head>
<body>
<form action="thisfile.php" method="post">
<select name="R">
<option value='Johansson'>Johansson</option>
<option value='Andersson'>Andersson</option>
</select><br />
Address: <input type="text" name="address"><br />
Phone: <input type="text" name="phone"><br />
<input type="submit" value="Update values">
</form>
</body>
</html>
--- code ---

Choosing a lastname in the select, entering some address and phone info and hitting submit will update Address and Phone on the row where Lastname matches what ever you've chosen in the select. The addslashes stuff is for security only, so no hacker does SQL insertions on you.


sam rumaizan skrev:
"I don't get the purpose of your code. It's not looking right anywhere!"
*(The purpose of my code is to update the fields PhoneNumber, Address, Job, FavoriteFood that belong to the selected last name from the menu).* "I'm guessing the select-box isn't working too well, right?" *(Sorry; but the select-box works fine) (Your code will print each field twice (repetition. Try my code then you will see the difference))* "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? *NO* *I need to pull the last name* *only from my database. *
*<SELECT name="R">*
*<OPTION value='Johnsson'>Johnsson</OPTION> *
*<OPTION value='Gustavsson'>Gustavsson</OPTION>*
*<OPTION value='Andersson'>Andersson</OPTION>*
*<OPTION value=' Dood'>Dood</OPTION>*
*</SELECT>*
*Then:* *Let's say I want to change the information in my database for Johnsson(How can I do this)*
* *
*Sam*

------------------------------------------------------------------------
Finding fabulous fares is fun.
Let Yahoo! FareChase search your favorite travel sites <http://farechase.yahoo.com/promo-generic-14795097;_ylc=X3oDMTFtNW45amVpBF9TAzk3NDA3NTg5BF9zAzI3MTk0ODEEcG9zAzEEc2VjA21haWx0YWdsaW5lBHNsawNxMS0wNw--> to find flight and hotel bargains.


--- End Message ---
--- Begin Message ---
Hi there!

How much impact on the server have sessions based on the length of minutes 
(seconds) that I change to? I just wonder if someone out there has 
Any experience of this or know a place on the web that describes this...?

Best regards
/Gustav Wiberg

--- End Message ---
--- Begin Message ---
Hey Gustav

It depends so much on how much data you store in the session variables, what kind of storage you run (database or files and so on) and how many users you have, so it's really hard to say. In my experience, sessions have very little impact on the server how ever long you set them to live.

Mike


Gustav Wiberg wrote:
Hi there!

How much impact on the server have sessions based on the length of minutes (seconds) that I change to? I just wonder if someone out there has Any experience of this or know a place on the web that describes this...?

Best regards
/Gustav Wiberg


--- End Message ---
--- Begin Message ---
 Funny you should ask this.
 
 We just had a bad experience of this on our live server where previous 
developers had coded each logged in user to store a DataTable (using .NET) 
object into a session. The DataTable object was a couple of hundred KiloBytes 
and the session life was set to 1 hour. The live website could of had 50 
simulateous users, and most of them close the browser when finishing with the 
site - so you can image that if in an hour period over 500 peopel access the 
site, and one hell of large chunk of data sitting in memory. This was causing 
chaos with the website, and was causing the IIS service to restart itself on a 
very frequently basis during one day (this killed all current user sessions).
 
 Be wary of what you store in sessions and of the duration for which they stay 
on the server. I know I probs had the worse case scenario, but still it can 
happen
    
 -----Original Message-----
 From: [EMAIL PROTECTED]
 To: [email protected]
 Sent: Wed, 4 Apr 2007 3.34PM
 Subject: Re: [PHP-WIN] Sessions?
 
  Hey Gustav 
 
 It depends so much on how much data you store in the session variables, what 
kind of storage you run (database or files and so on) and how many users you 
have, so it's really hard to say. 
 In my experience, sessions have very little impact on the server how ever long 
you set them to live. 
 
 Mike 
 
 Gustav Wiberg wrote: 
 > Hi there! 
 > 
 > How much impact on the server have sessions based on the length of minutes 
 > (seconds) that I change to? I just wonder if someone out there has > Any 
 > experience of this or know a place on the web that describes this...? 
 > 
 > Best regards 
 > /Gustav Wiberg 
 > 
 > 
 -- PHP Windows Mailing List (http://www.php.net/) 
 To unsubscribe, visit: http://www.php.net/unsub.php 
 
   

--- End Message ---
--- Begin Message ---
This is the second one of these that I've received. I didn't initiate
it.

Bill

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 04, 2007 1:41 PM
To: Bill Bolte
Subject: confirm unsubscribe from [email protected]

Hi! This is the ezmlm program. I'm managing the
[email protected] mailing list.

I'm working for my owner, who can be reached
at [EMAIL PROTECTED]

To confirm that you would like

   [EMAIL PROTECTED]

removed from the php-windows mailing list, please send an empty reply 
to this address:

 
[EMAIL PROTECTED]
sts.php.net

Usually, this happens when you just hit the "reply" button.
If this does not work, simply copy the address and paste it into
the "To:" field of a new message.

or click here:
        
mailto:php-windows-uc.1175712059.jolmnhlipkbnbmnkphhl-billb=hightouchinc
[EMAIL PROTECTED]

I haven't checked whether your address is currently on the mailing list.
To see what address you used to subscribe, look at the messages you are
receiving from the mailing list. Each message has your address hidden
inside its return path; for example, [EMAIL PROTECTED] receives messages
with return path:
<php-windows-return-<number>[EMAIL PROTECTED]

Some mail programs are broken and cannot handle long addresses. If you
cannot reply to this request, instead send a message to
<[EMAIL PROTECTED]> and put the entire address listed
above
into the "Subject:" line.


--- Administrative commands for the php-windows list ---

I can handle administrative requests automatically. Please
do not send them to the list address! Instead, send
your message to the correct command address:

To subscribe to the list, send a message to:
   <[EMAIL PROTECTED]>

To remove your address from the list, send a message to:
   <[EMAIL PROTECTED]>

Send mail to the following for info and FAQ for this list:
   <[EMAIL PROTECTED]>
   <[EMAIL PROTECTED]>

Similar addresses exist for the digest list:
   <[EMAIL PROTECTED]>
   <[EMAIL PROTECTED]>

To get messages 123 through 145 (a maximum of 100 per request), mail:
   <[EMAIL PROTECTED]>

To get an index with subject and author for messages 123-456 , mail:
   <[EMAIL PROTECTED]>

They are always returned as sets of 100, max 2000 per request,
so you'll actually get 100-499.

To receive all messages with the same subject as message 12345,
send an empty message to:
   <[EMAIL PROTECTED]>

The messages do not really need to be empty, but I will ignore
their content. Only the ADDRESS you send to is important.

You can start a subscription for an alternate address,
for example "[EMAIL PROTECTED]", just add a hyphen and your
address (with '=' instead of '@') after the command word:
<[EMAIL PROTECTED]>

To stop subscription for this address, mail:
<[EMAIL PROTECTED]>

In both cases, I'll send a confirmation message to that address. When
you receive it, simply reply to it to complete your subscription.

If despite following these instructions, you do not get the
desired results, please contact my owner at
[EMAIL PROTECTED] Please be patient, my owner is a
lot slower than I am ;-)

--- Enclosed is a copy of the request I received.

Return-Path: <[EMAIL PROTECTED]>
Received: (qmail 98730 invoked by uid 1010); 4 Apr 2007 18:40:58 -0000
Delivered-To: [EMAIL PROTECTED]
Delivered-To: [EMAIL PROTECTED]
Received: (qmail 98715 invoked from network); 4 Apr 2007 18:40:58 -0000
Received: from unknown (HELO lists.php.net) (127.0.0.1)
  by localhost with SMTP; 4 Apr 2007 18:40:58 -0000
Return-Path: <[EMAIL PROTECTED]>
Authentication-Results: pb1.pair.com [EMAIL PROTECTED];
sender-id=unknown
Authentication-Results: pb1.pair.com [EMAIL PROTECTED];
spf=permerror; sender-id=unknown
Received-SPF: error (pb1.pair.com: domain hightouchinc.com from
207.206.148.78 cause and error)
X-PHP-List-Original-Sender: [EMAIL PROTECTED]
X-Host-Fingerprint: 207.206.148.78 new-baden-as5200-1.accessus.net Linux
2.4 w/o timestamps
Received: from [207.206.148.78] ([207.206.148.78:63700]
helo=[207.206.148.78])
        by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP
        id A7/44-00736-931F3164 for
<[EMAIL PROTECTED]>; Wed, 04 Apr 2007 14:40:58 -0400
Received: from no.name.available by [207.206.148.78]
          via smtpd (for [216.92.131.4] [216.92.131.4]) with ESMTP; Wed,
4 Apr 2007 13:42:23 -0500
Received: from drpepper.local[127.0.0.1] by drpepper.local[127.0.0.1]
  (SMTPD32); Wed, 4 Apr 2007 13:41:16 -0600
Message-ID: <[EMAIL PROTECTED]>
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Subject: UNSUBSCRIBE
Date: Wed, 4 Apr 2007 13:41:16 -0600
MIME-Version: 1.0
Content-Type: text/plain;
        charset="windows-1252"
Content-Transfer-Encoding: quoted-printable

UNSUBSCRIBE

--- End Message ---

Reply via email to