[PHP] control browser with a href tag

2007-12-18 Thread Hiep Nguyen
hi friends,

i have two pages: list.php and update.php

list.php will have a hyper link that when click on, it will open a new window 
for user to update info.  once user clicks update button on update.php page, i 
want to close update.php and return to list.php.  however if user doesn't click 
update button, i don't want user to go back to list.php.  in other word, freeze 
up list.php until user closes or clicks update button on update.php.

is this possible to do with php?

thanks

Re: [PHP] control browser with a href tag

2007-12-27 Thread Hiep Nguyen
Warren Vail [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 i have two pages: list.php and update.php

 list.php will have a hyper link that when click on, it will open a new
 window for user to update info.  once user clicks update button on
 update.php page, i want to close update.php and return to list.php.
 however if user doesn't click update button, i don't want user to go back
 to list.php.  in other word, freeze up list.php until user closes or
 clicks update button on update.php.

 is this possible to do with php?

 Yes and no, don't think you intend to, but you may be mixing technologies.
 You refer to hyperlinks, etc, which is web technologies and windows, which
 is not unless you use javascript or ajax.  With PHP you can cause your
 browser to open a new browser by adding target=_blank to the hyperlink,
 but you cannot easily disable functionality of the old browser (It's still
 open, just usually covered up by the new browser), and if the user clicks
 your hyperlink again a 3rd browser will be opened.  You could name your
 target (target=mypage) which means if the user clicks it a new browser 
 will
 be opened, and if the user clicks the same link again, a 3rd window will 
 not
 be opened, but the page in the mypage target will be refreshed.

 HTH,

 Warren Vail

after read all your replies, i understand and want to redefine the problem.

if user clicks on the hyperlink on list.php page, i want to open a new 
windows for user to update info.  once user clicks update on update.php 
page, i want to close the update.php page automatically and refresh list.php 
page.  i think this is possible.  can someone give me suggestions how to do 
this?

thanks 

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



[PHP] string vs number

2008-02-05 Thread Hiep Nguyen

hi all,

i have this php statement:

? if($rowB[$rowA[0]]=='Y') {echo checked;} ?


debugging, i got $rowA[0] = 54, but i want $rowB[$rowA[0]] = $rowB['54'].

is this possible?  how do i force $rowA[0] to be a string ('54')?

thanks
t. hiep

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



Re: [PHP] generate xls file on fly

2008-02-08 Thread Hiep Nguyen


On Fri, 8 Feb 2008, Per Jessen wrote:


Hiep Nguyen wrote:


is there anyway to generate this into xls file w/o using fopen 
fwrite to the server?  my goal is to have a link after the table and
user can click on that link and a save window pop up to allow user to
save to local disk.


Yes - have a link like this:

a href=yourscript.php?parametersGet XLS file/a

in yourscript.php, you evaluate the parameters given and build the XSL
file as output:

header(Content-Type: application/excel);
header(Content-Disposition: attachment; filename=\filename\);

print
.
.
.
.
.


done.


i already got this method, but the problem that i have is the parameters 
is mysql statement and it's very long. i don't think a good idea to pass 
this in the url. also, the page that i'm working on is a search page, 
therefore the mysql statement is very complicate and long.  that's why i 
don't want to pass via url.


is there way to do within this page???

t. hiep

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



Re: [PHP] generate xls file on fly

2008-02-08 Thread Hiep Nguyen

On Fri, 8 Feb 2008, Jason Pruim wrote:



On Feb 8, 2008, at 10:14 AM, Hiep Nguyen wrote:



On Fri, 8 Feb 2008, Per Jessen wrote:


Hiep Nguyen wrote:


is there anyway to generate this into xls file w/o using fopen 
fwrite to the server?  my goal is to have a link after the table and
user can click on that link and a save window pop up to allow user to
save to local disk.


Yes - have a link like this:

a href=yourscript.php?parametersGet XLS file/a

in yourscript.php, you evaluate the parameters given and build the XSL
file as output:

header(Content-Type: application/excel);
header(Content-Disposition: attachment; filename=\filename\);

print
.
.
.
.
.


done.


i already got this method, but the problem that i have is the parameters is 
mysql statement and it's very long. i don't think a good idea to pass this 
in the url. also, the page that i'm working on is a search page, therefore 
the mysql statement is very complicate and long.  that's why i don't want 
to pass via url.


is there way to do within this page???



I have actually done what you are looking for... Here is how I do it:

On the search page, write the search phrase into a session variable so you 
can access it from another page and then run this code:


?PHP

$sortOrder = $_SESSION['order'];
$search = $_SESSION['search'];
$select = SELECT * FROM .$table. WHERE blah blah blah blah blah;

$export = mysql_query($select);
$fields = mysql_num_fields($export);

for ($i = 0; $i  $fields; $i++) {
$header .= mysql_field_name($export, $i) . \t;
}

while($row = mysql_fetch_row($export)) {
$line = '';
foreach($row as $value) {
if ((!isset($value)) or ($value == )) {
$value = \t;
}
else
{
$value = str_replace('', '', $value);
$value = '' . $value . '' . \t;
}   $line .= $value;
}
$data .= trim($line). \n;
}
$data = str_replace(\r, , $data);

if ($data ==) {
$data =\n(0) Records Found!\n;
}
header(Content-type: application/x-msdownload);
header(Content-Disposition: attachment; filename=Export.xls);
header(Pragma: no-cache);
header(Expires: 0);


print $header\n$data;


?

What that does is it writes the current search pattern into an excel file 
called Export.xls and downloads it to your harddrive. I am in the process of 
re-writing it to work as a function, but have had mixed results so far. I'm 
learning functions right now :)


If you know functions, and want to take a stab at re-writing it, I can 
provide you with the code I have so far :)



thank you for the suggestion, but here is another problem that i try to 
avoid saving mysql statement to query from the table again.


let say that user searched and found 10 records,
in the meantime, other users may change any of these 10 records,
so if we saved mysql statement and re-run mysql statement again, the 
result might be different.  to prevent this problem, i only want to 
download records that returned on this page only.


thanks,
t. hiep

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



[PHP] generate xls file on fly

2008-02-08 Thread Hiep Nguyen

hi friends,

i have a php page with the following logic:

html
head
titleDownload/title
/head
table
  trtdTitle/tdtdAuthor/td/tr
  ? $sql = select title,author from book where title != null and author != 
null; ?
  ? $rs = mysql_query($sql) or die(mysql_error()); ?
  ? while($row = mysql_fetch_array($rs)) { ?
  trtd?=$row[0];?/tdtd?=$row[1];?/td/tr
  ? } ?
  trtda href=Download Into Excel File/a/td/tr
/table
/html


is there anyway to generate this into xls file w/o using fopen  fwrite to 
the server?  my goal is to have a link after the table and user can click 
on that link and a save window pop up to allow user to save to local disk.


appreciate very much for any input.

t. hiep

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



Re: [PHP] generate xls file on fly

2008-02-11 Thread Hiep Nguyen

On Fri, 8 Feb 2008, Jason Pruim wrote:



On Feb 8, 2008, at 10:14 AM, Hiep Nguyen wrote:



On Fri, 8 Feb 2008, Per Jessen wrote:


Hiep Nguyen wrote:


is there anyway to generate this into xls file w/o using fopen 
fwrite to the server?  my goal is to have a link after the table and
user can click on that link and a save window pop up to allow user to
save to local disk.


Yes - have a link like this:

a href=yourscript.php?parametersGet XLS file/a

in yourscript.php, you evaluate the parameters given and build the XSL
file as output:

header(Content-Type: application/excel);
header(Content-Disposition: attachment; filename=\filename\);

print
.
.
.
.
.


done.


i already got this method, but the problem that i have is the parameters is 
mysql statement and it's very long. i don't think a good idea to pass this 
in the url. also, the page that i'm working on is a search page, therefore 
the mysql statement is very complicate and long.  that's why i don't want 
to pass via url.


is there way to do within this page???



I have actually done what you are looking for... Here is how I do it:

On the search page, write the search phrase into a session variable so you 
can access it from another page and then run this code:


?PHP

$sortOrder = $_SESSION['order'];
$search = $_SESSION['search'];
$select = SELECT * FROM .$table. WHERE blah blah blah blah blah;


why not store the whole SQL statement in a session variable, so it can 
work with any table???  i never use session before, but i'll look into it 
to see if it works for me.


any suggestion for a tutorial on session in php??? thanks.



$export = mysql_query($select);
$fields = mysql_num_fields($export);

for ($i = 0; $i  $fields; $i++) {
$header .= mysql_field_name($export, $i) . \t;
}

while($row = mysql_fetch_row($export)) {
$line = '';
foreach($row as $value) {
if ((!isset($value)) or ($value == )) {
$value = \t;
}
else
{
$value = str_replace('', '', $value);
$value = '' . $value . '' . \t;
}   $line .= $value;
}
$data .= trim($line). \n;
}
$data = str_replace(\r, , $data);

if ($data ==) {
$data =\n(0) Records Found!\n;
}
header(Content-type: application/x-msdownload);
header(Content-Disposition: attachment; filename=Export.xls);
header(Pragma: no-cache);
header(Expires: 0);


print $header\n$data;


?

What that does is it writes the current search pattern into an excel file 
called Export.xls and downloads it to your harddrive. I am in the process of 
re-writing it to work as a function, but have had mixed results so far. I'm 
learning functions right now :)


If you know functions, and want to take a stab at re-writing it, I can 
provide you with the code I have so far :)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]




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



Re: [PHP] generate xls file on fly

2008-02-14 Thread Hiep Nguyen

On Fri, 8 Feb 2008, Per Jessen wrote:


Hiep Nguyen wrote:


let say that user searched and found 10 records,
in the meantime, other users may change any of these 10 records,
so if we saved mysql statement and re-run mysql statement again, the
result might be different.  to prevent this problem, i only want to
download records that returned on this page only.


This is more of a caching issue - then you determine how long you want
to keep the results for, and only re-run the mysql query when the
results have gone stale.


/Per Jessen, Zürich

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




in the last couple days, i've looked into php $_SESSION and kinda get the 
concept.  my question is can i use $_SESSION to store mysql statement? 
what is the pro/con to store mysql statement in $_SESSION?
with $_COOKIE, i can use setrawcookie to avoid urlencoding.  is ther 
anything similar in $_SESSION?


thanks,
t. hiep
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Converting tab delimited file to CSV

2008-02-18 Thread Hiep Nguyen

On Mon, 18 Feb 2008, Graham Cossey wrote:


I was wondering if someone could offer some advice please.

I'm being sent data in tab delimited files which I'm trying to split
into smaller files and convert to comma delimited using PHP.

Now, I can replace the tabs with commas and opening the resulting
files in a basic text editor all looks fine. However when I open the
files in M$ Excel they're still being treated as tab delimited and all
values are being shoved into a single column.

What can I do in the PHP code to specifically make the file CSV and be
treated as such by M$ Excel?

I'm currently just using fopen for old and new files and fwrite.

--
Graham

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




don't double-click on file_name.csv, instead open MS Excel, then click on 
file open and locate your file, then you'll know what to do from there.


t. hiep

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



Re: [PHP] Help on running external command

2008-02-20 Thread Hiep Nguyen

On Wed, 20 Feb 2008, Mário Gamito wrote:


Hi,

I need to run an eternal command from a PHP page.

My code is:

$username= 'lixo';

$username = 'lixo';

exec('su - vpopmail -c 
/var/qmail/bin/maildirmake/home/vpopmail/domains/wwlib.lan/ . $username');



try:
exec('su - vpopmail -c 
/var/qmail/bin/maildirmake/home/vpopmail/domains/wwlib.lan/'.$username);



But I get the error:
/var/qmail/bin/maildirmake/home/vpopmail/domains/wwlib.lan/: Not a 
directory


Which means that the $username variable isn't being appended to the string.

Any help would be appreciated.

Warm Regards,
Mário Gamito

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


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

Re: [PHP] setcookie

2008-03-12 Thread Hiep Nguyen

On Wed, 12 Mar 2008, Tim Daff wrote:


Hi,

I am learning PHP, I am trying to set a simple cookie:

html
head
titleCookies/title
/head
body
?php setcookie('test', 45, 
time()+(60*60*24*7)); ?

/body
/html

Firefox is returning this error:

Warning: Cannot modify header information - headers already sent by (output 
started at /Users/Daff/Sites/php_sandbox/cookies.php:7) in 
/Users/Daff/Sites/php_sandbox/cookies.php on line 7


I have googled this and can't find out what I am doing wrong.  Any help you 
could give me would be much appreciated.


Tim


setcookie from php.net states the following:

setcookie() defines a cookie to be sent along with the rest of the HTTP 
headers. Like other headers, cookies must be sent before any output from 
your script (this is a protocol restriction). This requires that you place 
calls to this function prior to any output, including html and head 
tags as well as any whitespace


call setcookie before you output ANY THING, even error

hope that helps.
t. hiep

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



Re: [PHP] validating textarea using php

2008-05-13 Thread Hiep Nguyen

On Tue, 13 May 2008, Sudhakar wrote:


hi

i need to validate textarea of a html form using php

textarea name=comments cols=26 rows=3 id=comments?php
echo($comments);?/textarea

presently my php code to validate the text area is

if($comments ==  )
{
$error.=brPlease enter your comments;
}

with this code if a user hits the space bar once or couple of times as a
matter of fact there are no characters entered by the user i do not want
this to happen, if a user simply hits the spacebar and does not type
anything i should be able to display an alert message.

please advice how i can change the above php code.

thanks.



if(chop($comments) == ) { ... }   //hope that helps.

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