www.webdeveloper.com
Results 1 to 7 of 7

Thread: printing problem(urgent)

  1. #1
    Join Date
    Jun 2003
    Posts
    181

    Unhappy printing problem(urgent)

    hi,

    i got printing problem in new line between PHP and javascript
    php stuff i can print but how i can use javascript in between if and else as clock is javascript code and time field is php

    <td nowrap>
    //http://www.javascriptkit.com/script/cut2.shtml to get clock using pure JS
    <input type="text" class="button" size="1" name="clock">
    <select name="time" size="1" >
    <option selected value="<?=date('H:i')?>"><? echo (date('H:i')); ?></option>
    <option value="08:00"></option>
    <option value="09:00"></option
    <option value="10:00"></option
    </select>
    </td>
    //get the time from table
    $query = "SELECT time FROM t_emp ;
    $result = mysql_query($query) or die("Query failed: Fetch all rows");
    <? while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { ?>
    //printing
    <td>
    <? if ($_POST["time"] != "clock") {?>
    <?= $line["time"] ?>//workign fine when user selcts time field
    <? } else {?>
    //this is problem area how i can print this live clock value if user dont select time as this clock is javascript(to get live clock)
    what should i write code for clock
    <? }?>
    <? } ?>//end of while loop
    </td>

    if anybody help me out will be appreciable
    thanks

  2. #2
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Unless there is more relavant code, this: <? if ($_POST["time"] != "clock") {?> will always return true. ie. $_POST["time"] will never equal clock, and thus the script will never get to your else.

  3. #3
    Join Date
    Jun 2003
    Posts
    181
    its not clear could u plz tell me use if and else block as its bit confusing for me,as how to avoid if(!=)

  4. #4
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    I would do something like this:

    PHP Code:
    <td nowrap> 
    //http://www.javascriptkit.com/script/cut2.shtml to get clock using pure JS 
    <input type="text" class="button" size="1" name="clock"> 
    <select name="time" size="1" > 
    <option selected="selected" value="none">Select a time</option>
    <option value="<?=date('H:i')?>"><? echo (date('H:i')); ?></option> 
    <option value="08:00"></option> 
    <option value="09:00"></option 
    <option value="10:00"></option 
    </select> 
    </td> 
    //get the time from table 
    $query = "SELECT time FROM t_emp ; 
    $result = mysql_query($query) or die("Query failed: Fetch all rows"); 
    <? while ($line mysql_fetch_array($resultMYSQL_ASSOC)) { ?> 
        //printing 
        <td> 
        <? if ($_POST["time"] != "none") { #if $_POST["time"] does not equal "none" we know that they selected a time.
            
    echo $line["time"];//workign fine when user selcts time field 
        

        else {
    ?> 
            //this is problem area how i can print this live clock value if user dont select time as this clock is javascript(to get live clock) 
            //what should i write code for clock 
        <? }
     }
    //end of while loop ?>
    </td>

  5. #5
    Join Date
    Jun 2003
    Posts
    181
    sorry...still not getting clock value when user not select any time
    <? if ($_POST["time"] != "none")
    echo $line["time"]
    ?>
    when user selects time it prints time its fine as previously it do but when user dont select anything he will get [B]none[B] as printed value thats absolutely wrong he will get value of clock how to get this clock value

    sorry for ur inconvenience

  6. #6
    Join Date
    Jun 2003
    Posts
    181

    Unhappy

    i m helpless i tried i dont no how to get this clock value as its pure JScript

  7. #7
    Join Date
    Jun 2003
    Posts
    181
    Hi,

    im sorry that i really not able to clear my point,actually i created time field in database but i didnt added clock as i m not interseted to insert clock value in database only time field thats when i clcik on submit button time is inserted in database and in same time it show the value of time as there is no clock field so unable to display the time
    so now my question is how i can make 2 dif.columns in database as in application its in same table,anybody have an idea how to avoid this complexity
    thanks
    <td>
    <input type="text" class="button" size="1" name="clock">
    <select name="time" size="1" >
    <option selected="selected" value="none">Select a time</option>
    <option value="<?=date('H:i')?>"><? echo (date('H:i')); ?></option>
    <option value="08:00"></option>
    <option value="09:00"></option
    <option value="10:00"></option
    </select>
    </td>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles