Jump to content

php_joe

Members
  • Posts

    175
  • Joined

  • Last visited

    Never

Posts posted by php_joe

  1. I want a script so that it will count up from a date from onload, like a stopwatch. Not by comparing it to the client-side clock.

    so instead of saying "It's been 8 years and 45 days since this date" it would just start at the setcount date and count up like a clock.

    Oh, and I'd like to be able to set the starting hour, minute, and second instead of having it just start from the day.

    Thanks!

    Here is a script that runs off of the clock. I've been working on it all day but all I get is "NaN"  :'(

    [code]<script language="JavaScript1.2">

    function setcountup(theyear,themonth,theday){
    yr=theyear;mo=themonth;da=theday
    }

    //////////CONFIGURE THE countup SCRIPT HERE//////////////////

    //STEP 1: Configure the date to count up from, in the format year, month, day:
    //This date should be less than today
    setcountup(1999,3,2)

    //STEP 2: Configure text to be attached to count up
    var displaymessage="have passed since the debut of our site!"

    //STEP 3: Configure the below 5 variables to set the width, height, background color, and text style of the countup area
    var countupwidth='95%'
    var countupheight='20px' //applicable only in NS4
    var countupbgcolor='lightyellow'
    var opentags='<font face="Verdana"><small>'
    var closetags='</small></font>'

    //////////DO NOT EDIT PASS THIS LINE//////////////////

    var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
    var crosscount=''

    function start_countup(){
    if (document.layers)
    document.countupnsmain.visibility="show"
    else if (document.all||document.getElementById)
    crosscount=document.getElementById&&!document.all?document.getElementById("countupie") : countupie
    countup()
    }

    if (document.all||document.getElementById)
    document.write('<span id="countupie" style="width:'+countupwidth+'; background-color:'+countupbgcolor+'"></span>')

    window.onload=start_countup


    function countup(){
    var today=new Date()
    var todayy=today.getYear()
    if (todayy < 1000)
    todayy+=1900
    var todaym=today.getMonth()
    var todayd=today.getDate()
    var todayh=today.getHours()
    var todaymin=today.getMinutes()
    var todaysec=today.getSeconds()
    var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
    paststring=montharray[mo-1]+" "+da+", "+yr
    dd=Date.parse(todaystring)-Date.parse(paststring)
    dday=Math.floor(dd/(60*60*1000*24)*1)
    dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
    dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
    dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)

    if (document.layers){
    document.countupnsmain.document.countupnssub.document.write(opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds "+displaymessage+closetags)
    document.countupnsmain.document.countupnssub.document.close()
    }
    else if (document.all||document.getElementById)
    crosscount.innerHTML=opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds "+displaymessage+closetags

    setTimeout("countup()",1000)
    }
    </script>

    <ilayer id="countupnsmain" width=&{countupwidth}; height=&{countupheight}; bgColor=&{countupbgcolor}; visibility=hide><layer id="countupnssub" width=&{countupwidth}; height=&{countupheight}; left=0 top=0></layer></ilayer>[/code]
  2. [quote author=Nicklas link=topic=114288.msg465084#msg465084 date=1163018882]
    If you want to sort on the second column, then you need to make sure that all lines have atleast 2 columns, that´s all you need to know. Number of lines doesnt matter.
    [/quote]

    Oh yes, I see.

    Thank you very much! :)

    Joe
  3. If you embed a file you're taking that file from another location. It's like hot-linking to a jpg. To my knowlage you have no control over what's inside of that file unless it's your file.

    Joe
  4. If you gave each member a profile you could include their status as a buyer or a seller and show them different pages that way:

    On the profile page write a line like this:
    [code]$status = "customer";[/code]

    Then put this code in your index:
    [code]<?
    require "./profiles/{$user}.php";
    require "./{$status}_index.php";
    ?>[/code]

    Now you need to creat customer_index.php and supplier_index.php

    Put everything that you want [b]both[/b] to see in the main index.php.

    Joe
  5. At the very [b]top[/b] of your page put this:
    [code]<?php
    if($site){
    header("Location: $site");
    }
    ?>[/code]

    Then this code should send you to Google:
    http://www.mysite.com/link.php?site=http://www.google.com

    If you don't want the address to be visible in the link then you can store it on the page (or external file) and call it by a number:

    [code]<?php
    if($site){
    $key = $site;
    $address = array("http://www.yahoo.com", "http://www.google.com", "http://www.excite.com");
    header("Location: $address[$key]");
    }
    ?>[/code]

    And use the number in this link:
    http://www.mysite.com/link.php?site=2

    Joe
  6. I was having a simular problem with one of my codes. It would dislpay fine when the chinese word was called in the script, but if it was passed to the script inside of a url then it just showed up as ???.

    It was suggested on this forum that I put the php script into a text file, save it under a Chinese encoding, and then try it. I have not had time to try yet so I can't endorse or refute this advise.

    Joe
  7. I'm just trying to make a table that I can sort by any column. I don't want to change the information in the lines.

    I've been playing around with it a bit and I [i]could[/i] reorder the lines
    [code]<?
    foreach($data as $key => $value){
    list($one, $two, $three, $four) = explode("|", $value);
    $array = array($four, $three, $two, $one);
    $data[$key] = implode("|", $array);
    }
    $table = implode("\n", $data);
    sort($data);
    ?>[/code]
    But it seemed a bit cumbersom and I was hoping that there was a better way.

    Joe
  8. Hi,

    If I have a database stored on a text file that looks like this:

    animal|dog|cat|mouse
    eats|cats|mice|grass
    poops in|my yard|my house|my cereal

    I can sort the table by the first column like this:
    [code]<?
    $data = file($database);
    sort($data);
    ?>[/code]

    Is there an easy way to sort the database by the second or third column?

    Thanks!

    Joe
  9. the character is "funny looking"? like alien letters?

    If you have IE try this:
    1. Click on "View" in the toolbar at the top of the window.
    2. Click on "Encoding"
    3. Select "Big 5", "Chinese Simplified (GB2312)", or some other Chinese encoding

    Joe
  10. Hi,

    I'm trying to use PHP to create a link with a chinese word in it that will open an iframe.

    The code that I'm using is this:
    [code]echo "<a href=\"./rightcard.php?word=$chinese_word\" target=\"iframe\">Link</a>";[/code]

    In the source code it looks like this:
    [code]<a href="./rightcard.php?word=&#21160;&#29289;" target=\"iframe\">Link</a>[/code]

    If it weren't for an iframe it would look like this in the URL bar:
    [code]http://test.org/index.php?word=加法[/code]

    But when I click on it the word comes up as "??"

    Joe
  11. It's not so hard. :)

    When you're faced by a difficult project just break it into parts

    When they're setting up their account have a code like this in the register page:
    -------------------------------------------------------------------------
    $profile = './accounts/{$username}_profile.php";
    $address_list = './accounts/addresses.php";
    if(!file_exists($path) { [b]// does the profile already exist?[/b]
    $new_profile_content = "<?\n\$status = \"unmoderated\";\n\$email = \"$register_email\";\n?>"; [b]// what to put in the profile[/b]
    $add_register_email = "$register_email\n"; [b]// the user's email address with a line break added[/b]
    $new_profile = fopen($path, "w"); [b]// create the profile[/b]
    fwrite($new_profile, $new_profile_content); [b]// write the info[/b]
    fclose($new_profile); [b]// close the profile[/b]
    $add_address = fopen($addresses, "a+"); [b]// open the addresses.php[/b]
    fwrite($add_address, $add_register_email); [b]// add the address[/b]
    fclose($add_address); [b]// close addresses.php[/b]
    }
    -------------------------------------------------------------------------
    (The register page will have to provide the $username and $register_email)

    Then, when they submit a message at your webpage use this code:
    -------------------------------------------------------------------------
    $profile = './accounts/{$username}_profile.php";
    $address_list = './accounts/addresses.php";
    require "$profile"; [b]// get their profile info[/b]
    if($status == "unmoderated"){
    $subject = 'the subject'; [b]// your subject[/b]
    $message = 'hello'; [b]// your message[/b]
    $headers = 'From: $email' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
    $addresses = file($address_list); [b]// turn addresses.php into an array[/b]
    foreach($addresses as $key => $value){ [b]// for each one...[/b]
    $to = "$value";
    mail($to, $subject, $message, $headers); [b]// send them the message[/b]
    }
    } [b]// all done![/b]
    -------------------------------------------------------------------------

    Of course, this is just off the top of my head and may need some tweaking to work right.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.