Click to See Complete Forum and Search --> : printing problem(urgent)


zuzupus
06-27-2003, 04:52 AM
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

pyro
06-27-2003, 07:15 AM
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.

zuzupus
06-27-2003, 07:19 AM
its not clear could u plz tell me use if and else block as its bit confusing for me,as how to avoid if(!=)

pyro
06-27-2003, 07:25 AM
I would do something like this:

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

zuzupus
06-27-2003, 07:46 AM
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

zuzupus
06-27-2003, 09:18 AM
i m helpless i tried i dont no how to get this clock value as its pure JScript :(

zuzupus
06-30-2003, 03:14 AM
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>