php-windows Digest 13 May 2007 12:36:04 -0000 Issue 3227

Topics (messages 27884 through 27886):

Re: formating a string
        27884 by: Kevin Smith

Re: [EMAIL PROTECTED]
        27885 by: sam rumaizan
        27886 by: Niel Archer

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 --- The this instead. BTW, you misunderstood the useage of substr, see http://uk.php.net/manual/en/function.substr.php.

$code = 'abcdwxyz8765';
$string = array();
array_push($string,substr($code,0,4));
array_push($string, substr($code,4,4));
array_push($string, substr($code,8,4));
echo $string[0].'-'.$string[1].'-'.$string[2];


James Savage wrote:
i have a 12 digit code that i want to format as follows xxxx-xxxx-xxxx it is all numbers i tried using substr() to format it in this fassion
$code = abcdwxyz8765;
$string = array();
$string[] = substr($code,1,4);
$string[] = substr($code,5,8);
$string[] = substr($code9,12);
echo $string[0],'-',$string[1],'-',$string[2];
OUTPUT SHOULD BE : abcd-wxyz-5678
I GET : -wxyz678-5678
Any help?

--- End Message ---
--- Begin Message ---
I understand, but how about the attached code? Every thing works fine except 
the slide menu.
   
  Sam
Niel Archer <[EMAIL PROTECTED]> wrote:
  > Yes I do have dynamic content in my page. 
> I’m attaching the whole code for this page.

You missed the point. The fragment you supplied had no dynamic content
so does not need to be echoed at all. It can simply exist outside the
tag structure.

Niel

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





 

       
---------------------------------
Give spam the boot. Take control with tough spam protection
in the all-new Yahoo! Mail Beta.

--- End Message ---
--- Begin Message ---
> I understand, but how about the attached code? Every thing works fine except 
> the slide menu.

  It had errors in it that needed correcting.  Beyond that I can't much
say. It *looks* OK, but without the missing include files it can't be
tested.

  I've restructured it below.  I had to make some guesses about your
intent, mostly about the include files.  Hopefully I've guessed
correctly and not introduced too many errors of my own.
  Note that I've moved most of the HTML outside of the PHP code, as it
does not need to be parsed.  I've also standardised it as much as
possible in an attempt to make it clearer.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd";>
<HTML>
  <HEAD>
    <SCRIPT TYPE="TEXT/JAVASCRIPT" LANGUAGE="JAVASCRIPT">
      <!-- Hide script from older browsers
        function toggleMenu(currMenu) {
          if (document.all) {
            thisMenu = eval('document.all.' + currMenu + '.style')
            if (thisMenu.display == 'lock') {
              thisMenu.display = 'none'
            } else {
              thisMenu.display = 'block'
            }
          return false
          } else {
            return true
          }
        }
      // End hiding script -->
    </SCRIPT>
    <STYLE TYPE="TEXT/CSS">#menu1 {display:none; margin-left:20px}</STYLE>
<?php

$page_title = 'View Existing Data';
//include ('./includes/header.html');
//include( '../mysql_connect.php' );

?>
    <HEAD>
    <BODY>
    <TABLE ALIGN="center" BORDER="0" CELLSPACING="0" CELLPADDING="0">
      <TR ALIGN="center" VALIGN="middle">
        <TH ALIGN="center"><FONT SIZE="6" COLOR ="#310032">View Existing 
Data</FONT></TH>
      </TR>
    </TABLE>

    <FORM METHOD="post" ACTION="ved.php>">
<?php
$query = "SELECT DISTINCT Assign_Engineer FROM lo_data";
//$result = mysql_query($query);

?>

    <BR /><BR />
    <CENTER>
      <SELECT NAME="R"><OPTION VALUE="NULL">Choose a Category:</OPTION>

<?php

while ($line = mysql_fetch_array($result))
{
    foreach ($line as $value)
    {
        echo"      <OPTION VALUE='$value'</OPTION>";
    }
}

?>
      </SELECT>
      <INPUT  TYPE="submit" NAME="Submit" VALUE="Submit Data"><BR /><BR />
<?php

if (isset($_POST["R"])) {
    $result = mysql_query("SELECT Ref_No, 
Job_Title,Category,Assign_Engineer,Date_Received,Date_Required,Date_Assigned,ProjectedCompletionDate,Date_Completed,ManhourSpent,Status
 FROM  lo_data WHERE Assign_Engineer ='".$_POST["R"]."'");
}

?>
      <DIV STYLE="overflow:auto;">
        <TABLE  WIDTH="80" BORDER="1" CELLSPACING="1" CELLPADDING="3" 
BORDERCOLOR="CDCB98">
          <THEAD>
            <TR STYLE="position: relative; top: 
expression(this.offsetParent.scrollTop); background-color: #CDCB98;">
              <TH>Reference No</TH>
              <TH>Job Descriptions</TH>
              <TH>Category</TH>
              <TH>Assign Engineer</TH>
              <TH>Date Received</TH>
              <TH>Date Required</TH>
              <TH>Date Assigned</TH>
              <TH>Projected Completion Date</TH>
              <TH>Date Completed</TH>
              <TH>Manhour Spent</TH>
              <TH>Status</TH>
            </TR>
          </THEAD>
<?php

while($row = mysql_fetch_array($result))
{
    echo "<TBODY>";
    echo "<TR VALIGN=\"TOP\" ALIGN=\"CENTER\">";
    echo "<TD>{$row['Ref_No']}<BR />\n<H3><A HREF=\"page1.html\" 
onClick=\"return toggleMenu('menu1')\">Update The Record</A></H3>\n<SPAN 
ID=\"menu1\">";
    echo "<FORM>\n<P><TEXTAREA NAME=\"text\" ROWS=\"10\" COLS=\"40\">Update the 
record</TEXTAREA><INPUT TYPE=\"submit\" VALUE=\"Update\"><INPUT 
type=\"reset\"></P></FORM>";
    echo "</SPAN>\n</TD>";
    echo "<TD>{$row['Job_Title']}</TD>";
    echo "<TD{$row['Category']}</TD>";
    echo "<TD{$row['Assign_Engineer']}</TD>";
    echo "<TD{$row['Date_Received']}</TD>";
    echo "<TD{$row['Date_Required']}</TD>";
    echo "<TD{$row['Date_Assigned']}</TD>";
    echo "<TD{$row['ProjectedCompletionDate']}</TD>";
    echo "<TD{$row['Date_Completed']}</TD>";
    echo "<TD{$row['ManhourSpent']}</TD>";
    echo "<TD{$row['Status']}</TD>";
    echo "</TR>";
    echo"</TBODY>";
}

?>
        </TABLE>
      </DIV>
    </FORM>
    <BR /><BR />
    <CENTER>
<?php

//mysql_close();
//include ('./includes/footer.html');

?>
    </CENTER>
  </BODY>
</HTML>


Niel

--- End Message ---

Reply via email to