/    Sign up×
Community /Pin to ProfileBookmark

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

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@pyroJun 27.2003 — 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.
Copy linkTweet thisAlerts:
@zuzupusauthorJun 27.2003 — its not clear could u plz tell me use if and else block as its bit confusing for me,as how to avoid if(!=)
Copy linkTweet thisAlerts:
@pyroJun 27.2003 — I would do something like this:

[code=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="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($result, MYSQL_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>[/code]
Copy linkTweet thisAlerts:
@zuzupusauthorJun 27.2003 — 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
Copy linkTweet thisAlerts:
@zuzupusauthorJun 27.2003 — i m helpless i tried i dont no how to get this clock value as its pure JScript ?
Copy linkTweet thisAlerts:
@zuzupusauthorJun 30.2003 — 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>
×

Success!

Help @zuzupus spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...