php-windows Digest 22 May 2007 01:33:30 -0000 Issue 3233

Topics (messages 27917 through 27919):

Re: Textarea and mysql
        27917 by: Luis Moreira (ESI-GSQP)

Dynamically update mysql field
        27918 by: sam rumaizan
        27919 by: bedul

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 ---
Hi

        First, let me just say that "it does not work" is too vague.
        You should always describe the problem a little more.

        Anyway, there are a couple of things I don't understand on your
script :

        $textareaSubmit = str_replace("\r",
"",$textareaSubmit,$textarea2Submit);
        $inserts = explode("\n", $textareaSubmit, $textarea2Submit);  

        Possibly you want to use the functions in both strings
$textareaSubmit and $textarea2Submit, but I believe (I don't know your
version of PHP) that the syntax is wrong.
        The function "str_replace" replaces all occurrences of a string
within a string, not within a set of strings.
        The same with "explode".
        Check the syntax of both.

Luis


-----Original Message-----
From: Moore, Joshua [mailto:[EMAIL PROTECTED] 
Sent: sexta-feira, 18 de Maio de 2007 17:52
To: [EMAIL PROTECTED]; bedul
Cc: Bill Bolte; [EMAIL PROTECTED]
Subject: RE: [PHP-WIN] Textarea and mysql

I have two textareas that I need to insert into 2 different fields, so with
the following code im having trouble getting it to work:

Original:
$textareaSubmit = $_POST['textAreaValue'];
//First of all strip all the returns \r
$textareaSubmit = str_replace("\r", "",$textareaSubmit);
//Explode by new line
$inserts = explode("\n", $textareaSubmit);
//check if its array
if(is_array($inserts)){
    //run foreach on array
    foreach($inserts AS $insertSQL){
        $check = false;
        $check = mysql_query('INSERT INTO somewhere (`somecolumn`) 
VALUES (\''.$insertSQL.'\')');
        if($check === true){
            //success
        }else{
            //failure
            //do something?
        }
    }
}

Mine:

$textareaSubmit = $_POST['cpu_asset'];
$textarea2Submit = $_POST['cpu_serial'];
$textareaSubmit = str_replace("\r", "",$textareaSubmit,$textarea2Submit);
//First of all strip all the returns \r
$inserts = explode("\n", $textareaSubmit, $textarea2Submit);  //Explode by
new line
if(is_array($inserts)){ //check if its array
 //run foreach on array
foreach($inserts AS $insertSQL){
        $check = false;
        $check = mysql_query('INSERT INTO labels (`asset, serial`) VALUES
(\''.$insertSQL.'\')');
        if($check === true){
        echo "Done";
        }else{
        echo "An error occured during printing. \n Reason:\n Failed to
insert
data into mysql";
                                        }
                                    }
                                }

Mine doesn't work and im not sure why....

Thanks for your help!

-----Original Message-----
From: Aleksandar Vojnovic [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 18, 2007 3:02 AM
To: bedul
Cc: Bill Bolte; [EMAIL PROTECTED]
Subject: Re: [PHP-WIN] Textarea and mysql


$textareaSubmit = $_POST['textAreaValue'];
//First of all strip all the returns \r
$textareaSubmit = str_replace("\r", "",$textareaSubmit);
//Explode by new line
$inserts = explode("\n", $textareaSubmit);
//check if its array
if(is_array($inserts)){
    //run foreach on array
    foreach($inserts AS $insertSQL){
        $check = false;
        $check = mysql_query('INSERT INTO somewhere (`somecolumn`) 
VALUES (\''.$insertSQL.'\')');
        if($check === true){
            //success
        }else{
            //failure
            //do something?
        }
    }
}

bedul wrote:
> $temp = str_replace("\n","[break]",$inpText); //inpText is from textArea
>
> and then u enter your temp to the sql..
>
> when you want to split it up.. just use
>
> $temp=explode("[break]",$inp4Sql); //hope i don't give wrong function
>
> ==spam?? sory===
> ----- Original Message ----- 
> From: "Bill Bolte" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, May 18, 2007 4:22 AM
> Subject: RE: [PHP-WIN] Textarea and mysql
>
>
> Split the data on a line break maybe? First thing that comes into my
> head... 
>
> -----Original Message-----
> From: Moore, Joshua [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, May 17, 2007 4:17 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-WIN] Textarea and mysql
>
> Hello,
>
>  
>
> Im currently having a bit of an issue with putting user info from a
> textarea
> into mysql db with php. With the textarea I need each new line to be a
> separate entry into the db fields. So I guess the end result is making
> the
> textarea act like a regular text html form. The reason I am using
> textarea is
> because I want a user to paste in a long string of numbers
>
> Ex:
>
> 11111111
>
> 22222222
>
> 33333333
>
> ...and so on
>
>  
>
> And each will end up in the same field just different entries. 
>
>  
>
> Does anyone have any idea how I can accomplish this?
>
>  
>
> Thanks
>
>   

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

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

--- End Message ---
--- Begin Message ---
I have Textarea generated by while loop. How can I name it to be able to use it 
with my mysql update statement? Scroll down to see it
   
   
  while($i<$num)
  {
// collect all Information
$id=mysql_result($result,$i,"ID");
$RefNo=mysql_result($result,$i,"Ref_No");
$JobTitle=mysql_result($result,$i,"Job_Title");
$Category=mysql_result($result,$i,"Category");
$AssignEngineer=mysql_result($result,$i,"Assign_Engineer");
$DateReceived=mysql_result($result,$i,"Date_Received");
$DateRequired=mysql_result($result,$i,"Date_Required");
$DateAssigned=mysql_result($result,$i,"Date_Assigned");
$ProjectedCompletionDate=mysql_result($result,$i,"ProjectedCompletionDate");
$DateCompleted=mysql_result($result,$i,"Date_Completed");
$ManhourSpent=mysql_result($result,$i,"ManhourSpent");
$Status=mysql_result($result,$i,"Status");
   
  ?>

          <TBODY>
        <TR VALIGN="TOP" ALIGN="CENTER">
       <TD><? echo "$id" ?></TD>
        <TD><? echo "$RefNo" ?></TD>
  
      <TD> <P><TEXTAREA NAME=text  ROWS="10"
        COLS="40"><? echo "$JobTitle"?></TEXTAREA>
   
  <BR><INPUT TYPE="submit"
    VALUE="Update">
  <INPUT type="reset"></P></TD>
        <TD><? echo "$Category" ?></TD>
    <TD><? echo "$AssignEngineer" ?></TD>
        <TD><? echo "$DateReceived" ?></TD>
       <TD><? echo "$DateRequired" ?></TD>
        <TD><? echo "$DateAssigned" ?></TD>
        <TD><? echo "$ProjectedCompletionDate" ?></TD>
        <TD><? echo "$DateCompleted" ?></TD>
        <TD><? echo "$ManhourSpent" ?></TD>
        <TD><? echo "$Status" ?></TD>
        </TR>
        </TBODY>
   
  
    <?
 ++$i;
   }
   }




 

       
---------------------------------
Need a vacation? Get great deals to amazing places on Yahoo! Travel. 

--- End Message ---
--- Begin Message ---
u mean like this??
<?

//> $id=mysql_result($result,$i,"ID");

while($temp = mysql_fetch_array($result)){
  foreach($temp as $varNm =>$varVal){
        $$varNm =$varVal;

    }
/*
put your table code here
*/

}


?>

SOry just gues!

----- Original Message -----
From: "sam rumaizan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 21, 2007 3:24 PM
Subject: [PHP-WIN] Dynamically update mysql field


> I have Textarea generated by while loop. How can I name it to be able to
use it with my mysql update statement? Scroll down to see it
>
>
>   while($i<$num)
>   {
> // collect all Information
> $id=mysql_result($result,$i,"ID");
> $RefNo=mysql_result($result,$i,"Ref_No");
> $JobTitle=mysql_result($result,$i,"Job_Title");
> $Category=mysql_result($result,$i,"Category");
> $AssignEngineer=mysql_result($result,$i,"Assign_Engineer");
> $DateReceived=mysql_result($result,$i,"Date_Received");
> $DateRequired=mysql_result($result,$i,"Date_Required");
> $DateAssigned=mysql_result($result,$i,"Date_Assigned");
>
$ProjectedCompletionDate=mysql_result($result,$i,"ProjectedCompletionDate");
> $DateCompleted=mysql_result($result,$i,"Date_Completed");
> $ManhourSpent=mysql_result($result,$i,"ManhourSpent");
> $Status=mysql_result($result,$i,"Status");
>
>   ?>
>
>           <TBODY>
>         <TR VALIGN="TOP" ALIGN="CENTER">
>        <TD><? echo "$id" ?></TD>
>         <TD><? echo "$RefNo" ?></TD>
>
>       <TD> <P><TEXTAREA NAME=text  ROWS="10"
>         COLS="40"><? echo "$JobTitle"?></TEXTAREA>
>
>   <BR><INPUT TYPE="submit"
>     VALUE="Update">
>   <INPUT type="reset"></P></TD>
>         <TD><? echo "$Category" ?></TD>
>     <TD><? echo "$AssignEngineer" ?></TD>
>         <TD><? echo "$DateReceived" ?></TD>
>        <TD><? echo "$DateRequired" ?></TD>
>         <TD><? echo "$DateAssigned" ?></TD>
>         <TD><? echo "$ProjectedCompletionDate" ?></TD>
>         <TD><? echo "$DateCompleted" ?></TD>
>         <TD><? echo "$ManhourSpent" ?></TD>
>         <TD><? echo "$Status" ?></TD>
>         </TR>
>         </TBODY>
>
>
>     <?
>  ++$i;
>    }
>    }
>
>
>
>
>
>
>
> ---------------------------------
> Need a vacation? Get great deals to amazing places on Yahoo! Travel.

--- End Message ---

Reply via email to