[PHP] Re: Embedding an image in an email

2003-07-07 Thread Hugh Bothwell
Todd Cary [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 I would like to encode and embed an image in a file that can be
 emailed.  Is there some documentation on how to do this?


First, it's a bad idea... if you *must* show images, it's
far better to stick them on a web server and refer to them
from your email.

Second, if you really have to know how - look at the
source of the posting you just made, and/or look at
the relevant RFCs.

--
Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada
v3.1 GCS/E/AT d- s+: a- C+++ L+$ P+ E- W+++$ N++ K? w++ M PS+
PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+




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



[PHP] Re: limit on displaying a LONGTEXT filed from MySQL database

2003-06-23 Thread Hugh Bothwell
Artoo [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 How can I start searching for the first space in a string while starting
at
 say the 150th character?  I'm trying to display the first 150 characters
of
 an article that is stored in a LONGTEXT filed of a MYSQL database, and
 should the 150th character be inside a word, I would want to finish
 displaying that word.

 For example supose the 150th character is the v in the word privileges
I
 would want to finish displaying the word and end with privileges rather
 then ending  withpriv


If you want to go to the next space, try

SELECT
@a:= LOCATE(' ', mytext, 150),
IF( @a  0,
LEFT(mytext, @a ),
mytext
) AS returntext
FROM dbase


If you have some other small set of terminal
characters, you can extend it like

SELECT
@a:= LOCATE(' ', mytext, 150), @a:= IF(@a=0, 1000, @a),
@b:= LOCATE('.', mytext, 150), @b:= IF(@b=0, 1000, @b),
@c:= LOCATE(',', mytext, 150), @c:= IF(@c=0, 1000, @c),
@first:= MIN(@a, @b, @c),
IF( LENGTH(mytext)  150),
LEFT(mytext,
IF(@first  1000,
@first,
150
)
),
mytext
) AS returntext
FROM dbase


If you want more flexibility - which I would - I suggest
returning the first 170 characters or so, and truncate
more accurately in PHP.


SELECT
LEFT(mytext, 170) AS returntext
FROM dbase


?php

function TruncateAfterWord($str, $len) {
if (strlen($str) = $len)
return $str;
else {
preg_match( /\A([A-Za-z]*)/, substr($str, $len), $match );
return substr($str, 0, $len) . $match[1];
}
}

?


--
Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada
v3.1 GCS/E/AT d- s+: a- C+++ L+$ P+ E- W+++$ N++ K? w++ M PS+
PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+




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



[PHP] Re: Returning TWO variables from function

2003-06-21 Thread Hugh Bothwell
Roy W [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Can someone let me know how to return TWO variables from a function

 I tried:

 return $var1, $var2;

 But I get parse errors and other errors.


function ReturnMultiValues($a, $b, $c, $d) {
return array($a, $b, $c, $d);
}


list($first, $second, $third, $fourth) = ReturnMultiValues(1, 2, 3, 4);


--
Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada
v3.1 GCS/E/AT d- s+: a- C+++ L+$ P+ E- W+++$ N++ K? w++ M PS+
PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+




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



Re: [PHP] securing a graphic

2003-06-19 Thread Hugh Bothwell
 From: Ryan Holowaychuk [EMAIL PROTECTED]
 To: '[EMAIL PROTECTED]' [EMAIL PROTECTED]
 Sent: Friday, June 20, 2003 2:26 AM
 Subject: [PHP] securing a graphic
 Is there a way in PHP that I can secure a graphic, so that when the page
is
 loaded it will show the graphic, but is not able to be right clicked on
or
 downloaded to there desktop.

 Thanks
 Ryan


Haseeb Iqbal [EMAIL PROTECTED] wrote in message
news:LAW15-[EMAIL PROTECTED]
 yeah there is a way you have to use some third party tools for that.
 http://www.antssoft.com/htmlprotector/index.htm
 .php can't do this AFAIK


This security tool will stop 95% of the general public,
mostly by looking scary.  Anyone who knows what they're
doing will go through it in about 20 seconds.


They work in three steps:

  first, they have a decryption function which is url-encrypted:


function hp_d01(s) {
  var
o=,
ar = new Array(),
os = ,
ic = 0;

  for ( i = 0; i  s.length; i++ ) {// for each char in the
encrypted string
c = s.charCodeAt(i);// get the ascii value

if ( c  128 )// if 7bit ie all alphanumberics
and punctuation
  c = c^2;// XOR with 0010ie flip
second-lowest bit

os += String.fromCharCode(c);// cast back to char and append
to working string

// this stuff is for working around Javascript's slow string
concatenation:
// work with a temporary string until it gets up to 80
characters long,
// then store it and start a new working string.
if ( os.length  80 ) {
  ar[ic++] = os;
  os=
}
  }

// concatenate all the temporary strings to get the final
decrypted string
  o = ar.join() + os;
  document.write(o)
}



  second, they use their decryptor to expand a block of code
  which tries to lock down the browser to as great an extent
  as possible, encrypted in their custom code.


  third, in the body of the page, they use their decryptor to
  expand the actual body of the page.


Here is the page code with all the decryption/lockdown junk
stripped out:


html
headmeta http-equiv=Content-Type content=text/html;
charset=iso-8859-1
titleSample page protected by HTMLProtector/title
STYLE type=text/css
!--

  body, p, td, dd, dt, ul, ol, li, blockquote {font-family: verdana,
arial, sans-serif; font-size: 9pt; color: 11;}
  div.sidebar {font-size: 8pt; margin: 0}
  h1, div.title {color: 79; font-size: medium; font-weight: bold;
margin-bottom: 0}
  h2 {color: 79; font-size: small; font-weight: bold; margin-bottom: 0}
  dt {color: 79; font-weight: bold; margin-bottom: 0.5em; margin-top:
2em}

  A:aalink {font-weight:bold; text-decoration: none}
--
/STYLE
/head
body bgcolor=#FF text=#00
h1 align=centerSample page protected by HTMLProtectorbr
  br
/h1
table width=100% border=0
  tr
td width=120
  div align=centerimg src=/image/sample.gif width=80
height=80/div
/td
td width=874
  p align=centerIt's a sample text paragraph.br
a href=/htmlprotector/index.htmIt's a sample link/a.br
a href=mailto:[EMAIL PROTECTED]It's a sample email
link/a./p
/td
  /tr
/table
pThis page has been protected by HTMLProtector with follow features:/p
ul
  liProtect BODY section/li
  liMake page expire immediately/li
  liDisable Internet Explorer 6 image toolbarbr
  /li
  liDisable right mouse button/li
  liDisable text select/li
  liDisable off-line viewing/li
  liDon't display links in status bar/li
  liDisable page printing/li
  liDisable clipboard and printscreen/li
  liDisable drag and drop/li
  liDisable adobe acrobat web capturebr
  /li
  liKill frame/li
  liDomain lock/li
  liURL lock/li
/ul
pPlease take a look on what HTMLProtector can do for you!/p
pnbsp; /p
/body
/html



As you are looking specifically for image
protection, notice the line
img src=/image/sample.gif width=80 height=80

Try visiting
http://www.antssoft.com/image/sample.gif

Real secure, eh?


The bottom line is, the web page and graphic must
be publically available and decryptable in order for
people to view it in a browser.  If the browser can
decode it, so can just about anyone that knows what
they're doing.

Also note, this scheme adds about 4 1/2 kb to
the size of your page and makes it unusable by
non-Javascript-enabled browsers.  Why bother?

--
Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada
v3.1 GCS/E/AT d- s+: a- C+++ L+$ P+ E- W+++$ N++ K? w++ M PS+
PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+




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



Re: [PHP] functions, opinion...

2003-06-17 Thread Hugh Bothwell
Dvdmandt [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 Now, where did those two paragraphs come from? A bit of experience with
all
 those langs and the BASIC school... I'm at the age of 14 and don't even
know
 math yet so (I mean, I know +, -, / and *, but not advanced stuff)...


functional programming is based around the idea
that subroutines should have no side effects - all
the information a subroutine needs should be passed
as parameters, and its results should be returned.
Further, a function called with the same set of parameters
should always return the same result.

The original basis for this was that it made
program analysis much simpler; however, it
was found to be useful in practice as well for
a number of reasons:

- it was a means of enforcing variable scope
  (essentially, all variables are local),

- it promotes much simpler functions and
  more reuse.

- it can allow much more extreme compiler
  optimizations


While the functional programming philosophy
can be applied in most programming languages,
some of the languages I mentioned do a better
job of making its usefulness obvious.

For more info, see some of the links at
http://directory.google.com/Top/Computers/Programming/Languages/Functional/


--
Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada
v3.1 GCS/E/AT d- s+: a- C+++ L+$ P+ E- W+++$ N++ K? w++ M PS+
PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+




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



[PHP] Re: rows by day

2003-06-16 Thread Hugh Bothwell
Sebastian [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
[snip]
 $result = $db-sql(SELECT * FROM $news GROUP BY time DESC LIMIT
 $_GET[page], $pagelimit);
  while($row = mysql_fetch_row($result)) {

 echo $row[title] br/ Written by $row[author] br/ $row[text];
 }

 I'd like to sort the results by day, example:

 Monday's Articles:
 all rows that are posted on Monday.

 Tuesday's Articles:
 all rows that are posted on Tuesday ...


If you're sorting in descending order (as your
query seems to intend), shouldn't it be
Wednesday ... Tuesday ... Monday?


$query =
SELECT title, author, text, tstamp, DAYNAME(tstamp) AS day 
.FROM news 
.SORT BY tstamp DESC 
.LIMIT {$_GET['page']}, $pagelimit;

$result = $db-sql($query);


$first = true;
$lastday = ;

while($row = mysql_fetch_array($result)) {
if ($row['day'] != $lastday) {
$lastday = $row['day'];

if ($first)
$first = false;
else
echo /ul;

echo date(l M j, $row['tstamp']) . br/ul;
}

echo
lib{$row['title']}/bbr/
.Written by {$row['author']}br/
.{$row['text']}/li;
}

if ($first)
echo No results returned!br/;
else
echo /ul;



In production, I would rewrite this to
separate the logic from the presentation...
but if you trace through it, this should
give you a good idea of how to proceed.


--
Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada
v3.1 GCS/E/AT d- s+: a- C+++ L+$ P+ E- W+++$ N++ K? w++ M PS+
PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+




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



[PHP] Re: Including text with PHP and keeping blanks

2003-06-16 Thread Hugh Bothwell
Fredrik Fornwall [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hello!

 I am just wondering if there exist some built-in function in PHP to
 include text files in HTML while retaining blank spaces and tabs. While
 I have found some text to HTML converting scripts I would prefer to let
 PHP format the text while including it into a web page, instead of
 creating a separate file first. Any suggestions?


echo pre$mytext/pre;//  ;-)


Unless you are going to render to a fixed-width font,
your spacing will suffer anyway... or do you only
care about left-hand spaces, ie for indenting?

--
Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada
v3.1 GCS/E/AT d- s+: a- C+++ L+$ P+ E- W+++$ N++ K? w++ M PS+
PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+




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



Re: [PHP] Formatting issue.

2003-06-16 Thread Hugh Bothwell
Lowell Allen [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 From: Tom Ray [Lists] [EMAIL PROTECTED]

 I want to be
 able to display thumbnail versions of the pictures, 3 per row and as
 many rows as needed. Unfortunetly, all I can do right now is 1 per row,
 this is where I need the help. Here's the code that displays images:
 [snip]
 So how do I make this work so I can have three cells per table row and
 it actaully show the proper picture?


 You need to set up a counter so you can start a new table row at the
 appropriate time. Beginning from the line where you use explode(), and for
 brevity not writing out the HTML for linking the image:


... alternatively, you could use CSS relative positioning to
'flow' the images, so they wrap to whatever the page width
is.

This has the side benefits of simplifying your output
logic and making the output more flexible.




--
Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada
v3.1 GCS/E/AT d- s+: a- C+++ L+$ P+ E- W+++$ N++ K? w++ M PS+
PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+




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



Re: [PHP] functions, opinion...

2003-06-16 Thread Hugh Bothwell
Dvdmandt [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Or you could just temporarily enable ob... That's what I do when I have a
 function that needs to return lots of HTML containing many ' and ... I
know
 it's possible to use \ as well, but ob is somewhat easier then...


You're missing the point.  Output buffering can be useful,
but it is an entirely separate issue from the functional
programming style these two are endorsing
(and with which I wholeheartedly agree).

Too many people learned programming in the
BASIC school, writing 'do this, then add this, then
append that and the other' programs and ending
up with five-page subroutines.

A bit of experience with LISP or ML or FORTH
can be a wonderful thing; you start to see how
to simplify your problems, breaking them into
smaller and smaller pieces until all the answers
are obvious and there are no places left for bugs
to hide, passing the results back to build your
final solution and keeping the pieces generic
and reuseable.

--
Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada
v3.1 GCS/E/AT d- s+: a- C+++ L+$ P+ E- W+++$ N++ K? w++ M PS+
PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+




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



[PHP] Re: need help on coding

2003-06-15 Thread Hugh Bothwell
Shien Hang Low [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 problem :
 
 code :
 ?
 $data= message;
 echo $data;
 ?
 
 output :
 message
 ---
 if i want the output to be :
 message
 
 i try to used the below code but fail:
 ?
 $data = message;
 echo $data;
 ?
 
 so i wonder if i want to get the output that with the
 'quatation' mark  how can i do it, your help means alot to me
 thank you for your time and patient .


There are two ways of doing this:

First, you could use a literal string (using single-
quote marks ie ' )

$data = ' message ';


Secondly, you could escape the quotation marks
inside the string, ie

$data =  \message\ ;


I find the first method is a little easier to
read; however, single-quoted strings are
not evaluated for variable substitution, ie

$insert = 'test';

// $data = ' $insert ';// will not work!
$data = ' ' . $insert . ' ';
$data =  \$insert\ ;


Hope this helps.


--
Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada
v3.1 GCS/E/AT d- s+: a- C+++ L+$ P+ E- W+++$ N++ K? w++ M PS+
PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+




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



[PHP] Re: Random Image Store

2003-06-11 Thread Hugh Bothwell
Monil Chheda [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I want to create an php system that prevents automated
 registrations.

 I have come up with the script in which users come
 over and need to enter a random key displayed on the
 images while submitting their info. If the number
 entered is correct, the post is submitted, else, the
 same form is displayed with another random key.

 Now, any one doing a View Source gets to know the
 image source as myscript.php. What I want to do is
 to save the .jpeg image on my disc with the name as
 randomnumber.jpeg , where randomnumber is generated
 randomly for that page.

 Then, I would put an IMG SRC=randomnumber.jpeg tag
 and no one will be able to get the name of my php file
 creating the image.


Why should it matter whether they know the generating
script's name?

The only important thing is that they can't easily read
off (or generate) the password-value passed to the
image-creation script.  You could store the passcode
as a session variable, or send it as an encrypted get-
variable, or hash into a stored dictionary.

--
Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada
v3.1 GCS/E/AT d- s+: a- C+++ L+$ P+ E- W+++$ N++ K? w++ M PS+
PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+




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



[PHP] Re: How to format a strign with a generic mask??

2003-06-11 Thread Hugh Bothwell
Felipe Desiderati [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
I need a simple function that takes a string and formats
 with a generic mask. Like this example above:

$string1 = 12345678
$string2 = 11062003

echo format_string (#.###.###-#, $string1);  // -- Returns 1.234.567-8
echo format_string (##/##/, $string1);  // -- Returns 11/06/2003

Does anybody here have an idea to how to do this?


Here is a function that does what you want, with
a test stand.  HTH!


?php

function format_string($mask, $contents, $ch = '#') {

$c = 0;
$str = ;

for($m = 0; $m  strlen($mask); $m++)
if ($mask[$m] == $ch) {
$str .= $contents[$c];
$c++;
}
else
$str .= $mask[$m];

return($str);
}

?
html
body
form action=mask.php method=get
Mask: input type=text name=mask value=?php echo
$_GET['mask']; ?/br/
Content: input type=text name=cont value=?php echo
$_GET['cont']; ?/br/
Maskchar: input type=text name=ch value=?php echo
$_GET['ch']; ?/br/
input type=submit
/form


bResult:/b ?php echo format_string($_GET['mask'], $_GET['cont'],
$_GET['ch']); ?br/
/body
/html

--
Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada
v3.1 GCS/E/AT d- s+: a- C+++ L+$ P+ E- W+++$ N++ K? w++ M PS+
PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+




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



[PHP] Re: Scalable Vector Graphics

2003-06-06 Thread Hugh Bothwell
Bob Strasser [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I'm building a database visualization tool using SVG.  Is it possibe to
send
 information from a form on one html page to another html page with a SVG
 graphic enbedded in the page and have the php generated SVG graphic
receive
 the post information.


Not directly...

If there is only a small amount of info to be passed,
you could embed it as a url parameter to the image-
generating script.

If there is too much for that, I would have the
form submit to a page which stuffs the needed
information into session variables, then
redirects to the page with the graphics.
This page then passes the session-id
to the script that generates the graphics.

--
Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada
v3.1 GCS/E/AT d- s+: a- C+++ L+$ P+ E- W+++$ N++ K? w++ M PS+
PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+




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



[PHP] Re: PHP and base32 encryption

2003-06-05 Thread Hugh Bothwell
Cditty [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Someone has sent me a line of text that is base32 encrypted that I need to
 decrypt.  Does anyone know of a php module or snippet that can decrypt
 this?  I have searched on google and the php.net site, but was unable to
 find anything that can help.


Here is the most recent (draft) spec I could find:
http://community.roxen.com/developers/idocs/drafts/draft-josefsson-base-enco
ding-04.html

Be aware, there are several different suggested alphabets:
http://www1.ietf.org/mail-archive/ietf/Current/msg13890.html


I don't know of any php implementation offhand, but
it doesn't seem especially difficult.

--
Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada
v3.1 GCS/E/AT d- s+: a- C+++ L+$ P+ E- W+++$ N++ K? w++ M PS+
PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+



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



Re: [PHP] Move Decimal Point

2002-12-11 Thread Hugh Bothwell
Chris Wesley [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Wed, 11 Dec 2002, Stephen wrote:

  One other question. How would I find the first 0 of a repeating zero.
  Like 204,000. How would you find the 0 in the 4th column.

 For your repeating zeors question, you'll have to make use of some string
 functions or a regexp function.  Look for a pattern of more than 1 zero.


I would check out the modulus operator (%); something
like the following:

$zeros = 0;

// Ensure the number is an integer (if
// you already know this, you can skip
// this step).
// NOTE: no overflow checking!
while ($number != (int) $number) {
$zeros--;
$number *= 10;
}

// Look for trailing 0s
while(($number % 10) == 0) {
$number /= 10;
$zeros++;
}




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




[PHP] Re: Quick way to test series of integers

2002-10-25 Thread Hugh Bothwell

Paul Kaiser [EMAIL PROTECTED] wrote in message
news:58851.208.216.64.17.1035495310.squirrel;illinimedia.com...
 I have around 50 checkboxes on an HTML form. Their value is 1. So,
 when a user check the box, then no problem -- the value returned by the
 form is 1 and I can enter that into my SQL database.

 HOWEVER...

 If the user does not check the box, I'm in trouble, because the value
 does not default to 0, but rather nil I'm guessing...


You can take advantage of the way PHP parses passed values...

If you have two (or more) form inputs with the same name, the last value
over-writes the previous one(s).  ie if your script is called like
   myscript.php?n=0n=1
then you get
  $_GET[n] == 1

Sure, you say, but how can I make use of that?

Well, if the last value weren't sent, you would still have the previous
value, ie $_GET[n] == 0

Try this:

input type=hidden name=n value=0// this value is *always* sent
input type=checkbox name=n value=1// this value is only sent if
checked!

NOTE:  the order is important!  The conditional input must come *after*
the default!



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




[PHP] Re: An interesting one!!!

2002-10-25 Thread Hugh Bothwell

Tim Haynes [EMAIL PROTECTED] wrote in message
news:20021023162115.16675.qmail;pb1.pair.com...
 Here is a puzzle, infact it is a game that I need to do in PHP, here is
the
 spec

 3 prizes to be won every day over a month by clicking on 24 seperate
 windowsand thats it

 How could I go about deciding whether a user that clicked on one of the
 windows is a winner or not, obviously I wouln't want the prizes to go in
the
 first hour of the day, so would need to spread it out abit.

Obviously you don't know how many contestants you will have, so you can't
base it on that.

What about varying the probability of a win by the time since the last
page-view?
You could adjust this by hourly activity (to decrease the advantage for
people
hitting it at 2am) and by (time remaining / prizes remaining) to ensure
coming
out near your number-of-prizes target.

Does it *have* to be three prizes per day, or is that *on average*?  I
prefer
the latter; it makes things more tractable.



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




[PHP] Re: Time/date function MYSQL-UNIX

2002-05-24 Thread Hugh Bothwell


Peter [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Is there a built in PHP function which will convert a MySQL type date
 (DDMM or whatever) into a unix timestamp so it can be used with the
 other PHP time and date functions?

 I'm currently using substr() to extract bits of the date so it displays as
 DD / MM /  but it's annoying!


SELECT
id, UNIX_TIMESTAMP(mydate) AS mydatestamp
FROM mytable

then  $row['mydatestamp'] is your unix timestamp.



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




Re: [PHP] Email harvesters

2002-05-20 Thread Hugh Bothwell


Miguel Cruz [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 But then how would newsgroup users write back to people?

 miguel

 On Mon, 20 May 2002, Leif K-Brooks wrote:
  I think it would be a good idea to have whatever software sends list
  messages to the newsgroup block out the addresses.


Okay, I'm not saying any of these are
necessarily 'good'; but for argument, here
goes:


(1. )  pass-thru server:

(.a)  Replace email addresses with hyperlink
to server-based reply form, ie

   [EMAIL PROTECTED]
becomes
  www.listserv.com/replyto/9317401


(.b) Replace with email address with
processed email, ie

[EMAIL PROTECTED]
becomes
   [EMAIL PROTECTED]

This will of course still require spam-
filtering.

(.c)  request-for-contact.
Server form will forward user's
email and request an email reply.


(2. ) They can't - all contact via the
newsgroup - all email addresses censored,
no work-around provided.

(2.b)  Make this opt-in on request.




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




[PHP] Re: Non cachable php for use as an img src

2002-05-19 Thread Hugh Bothwell


Henry [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hello All,

 I want to return a gif from a php script. I want it to not be cachable
 anywhere not browsers, proxys etc. Actualy what I want to do is pass an
 existing .gif file as the output and do some database manipulation whilst
I
 do so.

Add a randomized cache-killer parameter, ie

img src='counter.php?site=1k={insert random number here}' /

Your script can ignore it, but the cache is
unable to guarantee it doesn't mean something
important, so it will force a reload.



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




[PHP] Re: job payment.

2002-05-19 Thread Hugh Bothwell


Jule [EMAIL PROTECTED] wrote in message
02051916383210.28871@localhost">news:02051916383210.28871@localhost...
 I got an offer to do some php/mysql design
 for a local company, basically what it's going
 to be is to take the current Access DB and
 make it acessible through a webpage (that's
 the basic info they gave me).
 How much should i except to get paid for this,
 and what is an acceptable amount, for the
 completion of this project, or per hour?

Depends drastically on how complex the
database is, and on what their idea of
making it 'accessible' is.

Are you porting the database to mySQL, or
mirroring it?  How many tables/records/pages?
How much 'design' do you do, and how much
is just fill-in-the-blanks?  Is this 'view-edit-
delete record' accessibility, or 'view-edit-
authorize-track changes-sign off on a form
filled from a six-table-join query', or what?
Is it in-house only, or for authorized clients
too, or for the public?



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




[PHP] Re: Shoutcast

2002-05-19 Thread Hugh Bothwell


Johan EkströM [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Anyone that has knowledge about this program, regarding it's XML output
and
 php fetching that info and placing it on a php-page for user's to view?

Take a look at some of the scripts from
http://www.casterclub.com/downloads.php

you should be able to figure out what you need.



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




[PHP] Re: finding postion of any chat occur first

2002-05-19 Thread Hugh Bothwell


Prachait Saxena [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I have a string like $str=Hello World  ;
 and i want to find the first occurance of any one of the char in   or


 $sp=strpos($str,)
 Did not work, beacuse in this I can give only one char


function strpos_multi($str, $chars) {
$firstpos = $badvalue = $strlen($str);

$numchars = strlen($chars);
for ($i = 0; $i  $numchars; $i++) {
$ch = substr($chars, $i, 1);
$pos = strpos($str, $ch);

if ($pos !== false)  // NOTE: op is bang-equals-equals
$firstpos = min($pos, $firstpos);
}

if ($firstpos == $badvalue)
return -1;
else
return $firstpos;
}


$charpos = strpos_multi($str,  );



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




[PHP] Re: Restricting image height and width in a message

2002-05-17 Thread Hugh Bothwell


Jeff Lewis [EMAIL PROTECTED] wrote in message
004e01c1fda3$78a91cd0$76a1a8c0@LEWISJCIT">news:004e01c1fda3$78a91cd0$76a1a8c0@LEWISJCIT...
 Currently, people can post links to images in an application I am using
but
 they can post something outrageous like 1000X800 pixels and it messes
thing
 up on the format.  I was sent this as a solution but it really bogs down
 especially on images from certain servers.  Is there a better way to do
 this?

... you are asking your server to load
each external image to find its size
every time the page is called. This
is (ahem) somewhat inefficient.

I would look at your link-adding page:

1. ask users not to link to super-huge
images OR ask for a thumbnail
link as well as the full-size;

2.  when links are submitted, get the
image size and store it in a local
database; then get the image size
(and thumbnail-image-size) at
the same time you retrieve the link
(and thumbnail-link)... set the preview
image to the thumbnail, and the anchor
to the full-size image.




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




[PHP] Re: PHP Tag question

2002-05-15 Thread Hugh Bothwell

Matthew Walker [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I'm writing a coding standards document for our programmers,
 and I need to know if the 'echo' shortcut PHP tags are always
 on, or if we need to assume they might not be on.

 (By echo shortcut, I mean this syntax: ?=$variable?)

Whether short-form tags are available or not is controlled
by the 'short_open_tag' setting in php.ini.

If your files will ever contain a mixture of XML and PHP,
it is best to stick to the long opening tag, as the ?
shortform cannot distinguish between ?php and ?xml



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




[PHP] Re: PHP and mySQL

2002-05-14 Thread Hugh Bothwell


City Colleges Of Chicago - Mannheim [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 if there is a booktitle and a quantity chosen, then go to that booktitle
and
 adjust the quantity in the database.


?php
$link = mysql_pconnect($local, $user, $pass)
or die(Error connecting: .mysql_error());
mysql_select_db($db, $link)
or die(Error opening database $db: .mysql_error());

if ($submit) {
if ($bookID !=  and $quantity  0) {
$query =
UPDATE Book2
. SET stock=(stock-.(int)$quantity.)
. WHERE bookID=.(int)$bookID
. AND stock =.(int)$quantity;
$result = mysql_query($query, $link);

if (mysql_affected_rows($link) == 1)
echo pYour order has been placed./p;
else
echo pThere was an error in placing the order./p;
}
}
else {
echo pYour order has not been placed./p;
}
?


NOTE:
1.  We work with a unique book-id, not a book title;
this is (a) faster for the database and (b) eliminates
problems dealing with several books of the same
name (ie multiple editions, hard-cover/soft-cover/trade,
etc).
2.  We add quantity-checking to the query - before an
order is placed, we ensure there are sufficient books
on hand.  Because this is done as a single operation,
we don't have to worry about transaction-safety.
3.  When composing the query, all values are cast to int,
foiling would-be hack attempts.



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




[PHP] Re: Referrals

2002-05-13 Thread Hugh Bothwell

 When you select an item to look at, there is a section named:

 Customers who bought this item also bought:

 blah link one - blah description
 blah link two - blah description

 How is this done? Is there a reference to a new db which has the links and
 references them from there or do they look into sessions or cookies?

It seems pretty straight-forward;

Each customizer has an account; when you go
to buy something you have to sign in.

When you buy something, a record is kept,
'this user' bought 'this item'.

To get the referrals, we search for all users
who bought the current item, then search for
all items bought by those users (except the
current item).


Summary so far:

Table: user
userID, name, username, password, cc#, etc

Table: items
itemID, name, description, price, etc

Table: purchases
userID, itemID, date


First search:

SELECT DISTINCT userID FROM purchases
WHERE itemID=$currentItemId;

... turn all returned userIDs into a comma-delimited list...

Second search:

SELECT itemID, COUNT(itemID) AS num FROM purchases
WHERE userID IN ( $userList ) AND itemID != $currentItemId
GROUP BY itemID ORDER BY num DESC LIMIT 5

... returns the 5 most popular also-bought items.

A database supporting sub-searches would make
this very simple, but I think a good coder could
turn this into a single query even in MySQL through
clever use of joins.



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




[PHP] Question: overlaying PNG-8 w/ transparency

2002-05-13 Thread Hugh Bothwell

I've been reading through the documentation, and
before going further I'll ask if someone's done this before:

I'm putting a simple 2d tile-based game together;
I have a series of tiles saved as 8-bit PNG images with
transparency (the lowest tile has no transparent
pixels).  I have a bit-vector telling me which overlays
I need. I want to take the background and consecutively
add on each of the overlays in order.

I can load each of the tiles, and I can send a resulting image
to the browser; so far, so good.  The sticking point
is I can't figure out how to lay one partially-transparent
image over another.

It kind of looks like I have to create a TrueColor image
structure, then consecutively load each 8-bit image, turn it
into a Brush, and apply it to the canvas... then (optionally)
reduce back to a palettized image before sending it to the
browser.

Is there an easier way to do this ?



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




[PHP] Re: Self Destruct code

2002-05-07 Thread Hugh Bothwell

Keep some vital part of the code separate, ie on your own host... such as
the ability to add new users, or the calendar-file for next month, or
whatever.  Their system works fine, and as soon as they pay they get the
last module and are on their own, but if they fail to pay you can pull the
plug.  And because it's something *missing* rather than an additional test
in the code they have, it's much harder to work around.


Phpcoder [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi
 I have a funny request; I wrote a system for a client and am rather
 concerned that I am not going to receive payment for the work done. They
 want me to hand over the code before they are willing to pay, so
 basically I will be left at their mercy; if they don't pay, they will
 still have a working version of the system...
 So, is there any way I can inconspicuously code in some boo-boo's that
 are time related etc. Something that will bomb the mysql tables or break
 some code if it is not unlocked within a month etc.
 I'm not sure if people out tjere might have existing safeguard tools
 etc, so I'm open for suggestions.
 PS, I know about Zend's encrypter, but since it will live on their
 server, I don't think it will help much since they will need the
 decrypter on there anyway right?

 Thanks




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




Re: [PHP] Re: I-worm/Klez and a GIF query/question

2002-05-04 Thread Hugh Bothwell


R [EMAIL PROTECTED] wrote in message
001501c1f369$060a52a0$0a6da8c0@lgwezec83s94bn">news:001501c1f369$060a52a0$0a6da8c0@lgwezec83s94bn...
 Hey,
 Thanks for replying,
 Do you by any chance have the code or functions that i can use to do this?
 even to output on jpeg should be ok.
 Cheers,
 -Ryan

If outputting a JPEG is ok, why bother?  I guess you
could up the output quality to prevent blurring...


I don't have code to hand, but I can tell you
how to go about it:

Look up the Gif89a format spec; it will tell you
how to write the header (desired bits-per-
pixel, size, etc).

Count the number of different colors you use.
Set the bits-per-pixel to the lowest value
such that 2^bpp= numcols+1, and encode
at bpp+1 actual bits per pixel, always referring
to entries in the _existing_ palette, one entry
per pixel.  This is obviously less efficient than
the LZW expanding-dictionary scheme, but
avoids patent infringement.

I recommend writing this as a PHP function
that accepts an image structure and returns
a bit-string; that will make it very easy to
integrate into your scripts.

... if this sounds too complicated, you
could always hire me to do it instead (hint, hint).



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




Re: [PHP] Re: I-worm/Klez and a GIF query/question

2002-05-04 Thread Hugh Bothwell


Jason Wong [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]...
 On Saturday 04 May 2002 04:58, Hugh Bothwell wrote:
  NOTE that for someone sufficiently persistent, they could still
  pattern-match the generated image to retrieve the number and
  auto-register that way.  (I could write a PHP file to do that, too :-)

 The pics generated by services like Yahoo are distorted and thus are
 extremely difficult to OCR.

Yahoo apparently uses a mixture of static, marble, grid,
colored background, ripple, and warp to obfuscate images.
 They don't seem to vary the typeface, size, spacing, or
alignment of their font, although they do randomize the
location. Of these, only ripple and warp seem inherently
difficult to OCR.  They also weaken it by using only short
dictionary words; this could be useful in an attack (ie if the
result is not a word in the dictionary, scrap it and
start fresh).


Yahoo links to an interesting page at Carnegie-Mellon:
http://www.captcha.net/

They use a different scheme here; they show
a set of six images and ask for a 'theme' word
that describes them.

Me being a skeptic, I wonder how many image
sets they actually have and guess not more than
200 or so; it seems that a sufficiently determined
person could catalog a decent-sized subset and
automate an attack that way (of course, they
could always obfuscate their images to some
degree...).


... and the race continues ;-)



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




[PHP] Re: Javascript function

2002-05-04 Thread Hugh Bothwell


Morten Nielsen [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi
 Is it possible to call a function in a javascriptpage from a PHP page?
 I have a function, which I use when the user press a button. I would like
to
 call this function just by typing the name. Is that possible?

Strictly speaking, no...

Indirectly, you can use PHP to write Javascript such that your
Javascript function will be called when the client loads the page.



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




[PHP] Re: PHP editing environment

2002-05-03 Thread Hugh Bothwell


Pag [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 Anyone know how i can make my work more efficient? Like install MySQL and
 PHP and get everything working normally when i preview the code in
internet
 explorer, that would be perfect, is it possible? How do you guys and girls
 work with php, what editors and/or tools you use?

1.  Install Apache from apache.org

2.  Install PHP from php.net

3.  Install MySQL from mysql.com

4.  I use HomePage 4.5.2; it has a setting that is very useful:
 under Options - Settings - Browse, check 'Enable
Server Mappings', click Add, set 'C:\program files\
Apache Group\Apache\htdocs' (or wherever you put
your web directory) to 'http:/localhost/' and Voila!
You can browse the page results directly in HomePage.
Very handy.  I assume version 5 has something
closely equivalent.



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




[PHP] Re: I-worm/Klez and a GIF query/question

2002-05-03 Thread Hugh Bothwell


R [EMAIL PROTECTED] wrote in message
007501c1f304$3c1607a0$0a6da8c0@lgwezec83s94bn">news:007501c1f304$3c1607a0$0a6da8c0@lgwezec83s94bn...

 at the end of the form he wants a key gif...(A gif with a number)
 that is automatically generated and that number has to be entered into the
 text boxthe idea is that it prevents automaited registerations.

I've seen code that puts out an image that is .gif-compatible
(ie can be viewed in any browser) but is not LZH-compressed,
ie does not fall under the patents.  I could write a PHP file
to do it...

The drawback, of course, is no compression; but for a small
image that shouldn't be a problem.

NOTE that for someone sufficiently persistent, they could still
pattern-match the generated image to retrieve the number and
auto-register that way.  (I could write a PHP file to do that, too :-)



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




Re: [PHP] Re: why is better?

2002-05-02 Thread Hugh Bothwell


Steve Bradwell [EMAIL PROTECTED] wrote in message
57A1618E7109D311A97D0008C7EBB3A1CBB2EA@KITCHENER">news:57A1618E7109D311A97D0008C7EBB3A1CBB2EA@KITCHENER...
 Hi,

 Sorry to bud in on this, but I was thinking about writing my next php app
 oop style to learn. Are you saying that It is going to be slower or
 poorer performance?

It will be slightly (in most cases, unnoticeably) slower.

On the other hand, if properly designed, it should be
easier to maintain and much more easily reuseable in
other projects.

I think that's a reasonable tradeoff.



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




Re: [PHP] bumping up hour by one

2002-05-02 Thread Hugh Bothwell


Tom Beidler [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 My mistake. The correct code that works is;

 $display_time = date(H:i);

 // round time to nearest 15 minute interval
 $display_timex = explode (:,$display_time) ;
 if (($display_timex[1] = 00)  ($display_timex[1] = 07)) {
 $insert_time = $display_timex[0] . :00;
 } elseif (($display_timex[1] = 8)  ($display_timex[1] = 22)) {
 $insert_time = $display_timex[0] . :15;
 } elseif (($display_timex[1] = 23)  ($display_timex[1] = 37)) {
 $insert_time = $display_timex[0] . :30;
 } elseif (($display_timex[1] = 38)  ($display_timex[1] = 52)) {
 $insert_time = $display_timex[0] . :45;
 } elseif (($display_timex[1] = 53)  ($display_timex[1] = 59)) {
 $display_timex[0]++;
 $insert_time = $display_timex[0] . :00;
 }

How 'bout:

// split it in a more readable way
list($hour, $min) = split( , date(H i));

// calculate nearest quarter-hour
$quarters = (int) (($min + 7) / 15);

// check for round-to-next-hour
if (4 == $quarters) {
$quarters = 0;
$hour++;
}

// turn quarter-hours back into minutes
$min = 15 * $quarters;

// format final result
$insert_time = sprintf(%2i:%02i, $hour, $min);



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




[PHP] Re: Question for you guys on best tools for a job

2002-04-29 Thread Hugh Bothwell


Michael Champagne [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I'm not even sure this is possible without doing a client side java applet
of
 some sort.

You might be able to munge something using a hidden frame
and Javascript polling, but it would be an unneccessarily heavy
load on your server.


Ideally, this sounds like a server-broadcast situation:

- write a client applet that connects to the
  server, registers, and gets the initial values;

- write a login server script that registers
  clients and returns an initial data set;

- write an update server script that updates
  the database and broadcasts updates to all
  registered clients.

I would have the client re-register hourly and
automatically expire registrations more than
an hour-and-a-bit old.




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




[PHP] Re: Translation Request--Altavista Babelfish can't do it

2002-04-26 Thread Hugh Bothwell


Vins [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 if(!ereg(^#(.)*$, $buffer[$i]))
 {
 echo ok;
 }

 what does this mean?

It takes a string ($buffers[$i]) and tries to
match it with a regular expression.  The
expression reads a string beginning with
any character except '#', followed by 0 or
more of any character to the end of the
string.  The number of matches found is
returned, and if the number is 0 ('not not-false'),
it prints ok.

Boiled down, it is 'ok' if the string
doesn't start with '#'.

At a guess, it looks like someone is
stripping comments from a shell script.



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




[PHP] Re: 3dim Array problem

2002-04-19 Thread Hugh Bothwell

  while( $res=$UDV - getDbAns()) {// fetch mains

Just checking:

On success, $UDV-getDbAns() returns array of string;
On fail, it returns false.

  if(strlen($res[0])  2) { // if result is OK
 $menarr[$h]=$res[0]; // put them in array

Here is your problem - you set $menarr[$h] to
a string, then later try to set stringval[$s][$h] to
a string.  Unsurprisingly, PHP has no idea how to
treat a string as a 2d array.


 // get submenues
 $selchi=select chi from link where pa = '$res[0]';

Try echoing this string to make sure it is what you think;
might have to be
... where pa = '{$res[0]}' ;

 $UDB -  talk2DB($selchi);
 while($chia=$UDB - getDbAns()) {
if(strlen($chia[0]) 3) { // if result is OK
   //echo b.$chia[0]./bbr;
   // Youll get a 0x20 separated string
   $subp=explode( ,$chia[0]); // explode it, to get single values

   if(is_array($subp)) { // if there are more than one in it

... the result of explode() is _always_ an array; this
test and the alternate code are unnecessary.

  $maxs=count($subp); // check out how many
  for($n=0; $n  $maxs ; $n++) {// each child in main/sub/n

why not use foreach() ?  not much difference, maybe,
just a bit easier to follow...

 // put the value in main/sub/n
 error here  -   $menarr[$h][$s][$n]=$subp[$n];

as above, $menarr[$h] is a string.


  }
   }

del else // if there´s only one value
del {
del $menarr[$h][$s][0]=$chia[0];
del }

 }// end if sub
 $s++; // submenues plus one

You never set $s to 0; your submenus are going to be
numbered funny, ie

$menarr[0][0]
$menarr[0][1]
$menarr[0][2]
$menarr[1][3]
$menarr[1][4]
etc

  }// end while subs
   }// end if main

   $h++; // mainmenues plus one
 }// end while mainmenues



Here is my reorganized code:

$h = 0;
while ( $res = $UDV-getDbAns() ) {
if ( strlen($res[0]) = 2 )
continue;// skip invalid results ('--' ?)

$menarr[$h]['menu'] = $res[0];// store menu name

$child_query = SELECT chi FROM link WHERE pa='{$res[0]}' ;
$UDB-talk2DB($child_query);

$s = 0;
while ( $child = $UDB-getDbAns() ) {
if ( strlen($child[0]) = 3 ) {
continue;

$subp = explode( , $child[0]);
foreach($subp as $key = $val)
$menarr[$h][$s][$key] = $val;

$s++;
}

$h++;
}

Hope this helps.

P.S.  ... it seems to me the query-in-query could be
replaced by a single sorted query; the result would
probably be a little faster, but (shrug) save that for later.



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




[PHP] Re: Images don't save

2002-04-18 Thread Hugh Bothwell


Manu Verhaegen [EMAIL PROTECTED] wrote in message
E10E651CDD2DD5118912E8E8C70F5513@compuver01">news:E10E651CDD2DD5118912E8E8C70F5513@compuver01...
 Hi,
 You can right click on a image on your browser and choose save.
 I want to disable this option, how can i do this


1. JavaScript - catch right-button-clicks and do something else with them.

(user can turn off JavaScript)
(many scripts of this sort are vulnerable to: press and hold
left button, click right button, release left button)


2. Put the image as a table background, then put a transparent .gif over
it - someone right-click-and-save'ing will get themselves a transparent .gif

(use can look at the source and call the image directly, or pick it
out of the browser cache)


3. Put a placeholder picture in, then use JavaScript to dynamically
swap your actual image so it doesn't show up in the HTML source

(user can trace the JavaScript or write themselves a script to
return the current image URL)
(users without JavaScript are severely peeved)


4. Use an applet or plug-in to display a non-clickable image

(User can view source then call image directly).
(People trying to print out your page will hate you).


5. Use an applet or plug-in to display a non-clickable
image stored in some non-standard format.

(Hackers will enjoy munching on your plug-in;
everyone else will use a screen-capture utility).


Basically,

(a) if a user can see it they can steal it, and

(b) trying to prevent this just ticks people off.



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




[PHP] Re: Using one submit button (long, rambling, near-total rewrite)

2002-04-17 Thread Hugh Bothwell

Jennifer Downey [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]...

 I have no takers on this one?

You would have more help if you didn't glumph
a whole whack of code in... it takes five minutes
just to sort out what's what.


  if I have on item it is fine. If I have two items it
 won't update the first items price but will the
 second. if I try to enter a price in the first items
 textbox it doesn't update and then deletes the
 second item's price.

It sounds like you are trying to return multiple
values to a single variable - ie, you need to
return an array, then iterate through the array
to process it.


$uid = $row['uid'];
$id = $row['id'];
$name = $row['name'];
$image = $row['image'];
$iquantity = $row['quantity'];
$itype = $row['type'];
$iprice = $row['price'];

Look up the documentation on extract()


 if($update)
 {
  $eprice = '$price[]';
  $query = UPDATE {$config[prefix]}_shop SET price = '$eprice'
 where uid = {$session[uid]} AND id = '$id';
  $ret = mysql_query($query) or die(mysql_error());

if(isset($update) and is_array($price))
foreach($price as $id = $newval)
if ($newval != ) {
$query =
UPDATE {$config['prefix']}_shop 
.SET price='$newval' 
.WHERE uid='{$session['uid']}' AND id='$id' ;
mysql_query($query) or die(mysql_error());
}



  echo TABLE BORDER='0' WIDTH='95%' CELLPADDING='0'
 CELLSPACING='0'TR;
  echo TD width=20%img src='$image'/TD;
  echo TD width=30%font size=2$name/font/TD;
  echo TD width=20%font
 size=2CENTER$iquantity/CENTER/font/TD;
  echo TD width=30%font size=2CENTERa
 href='$PHP_SELF?id=$idremove=yes'X/a/CENTER/font/TD;
  echo TD width=30%font size=2CENTERinput type=\text\
 value=\\ name=\price[]\ size='8'
 MAXLENGTH='8'BR/a/CENTER/font/TD;
  echo /TD/TR/TABLE;
echo input=\hidden\ name=\remove\ value=\yes\;
 }

(grin)  you realize your column widths add to 130% ?

This is not necessarily a problem; rather, I point it out as
a symptom of poorly formatted and hard-to-follow code.

I often find it useful to write simple table-making functions
just so it's easier to follow what's going on... something
like


// adjustable indentation for prettyprinting
define(BEGINTABLE, \n\t);
define(ENDTABLE, \n\t);
define(BEGINROW, \n\t\t);
define(ENDROW, \n\t\t);
define(BEGINCELL, \n\t\t\t);
define(ENDCELL, );
define(BEGINCONTENTS, );

function makeTable($content, $width=, $border=0) {
return
BEGINTABLE.table
.( $width !=  ?  width='$width' : )
. border='$border' cellspacing='0' cellpadding='0'
.$content
.ENDTABLE.\table;
}

function makeRow($content) {
return
BEGINROW.tr
.$content
.ENDROW.\tr;
}

function makeCell($content=, $width=) {
return
BEGINCELL.td.($width !=  ?  width='$width' : ).
.($content !=  ? $content : nbsp;)
.ENDCELL./td;
}


Then your code turns into

// separate out the recurrent formatting
$s = div style='font-size: larger; align=center;';
$e = /div;

$content = makeRow(
 makeCell($s.Image.$e,20%)
.makeCell($s.Name.$e,30%)
.makeCell($s.Quantity.$e,20%)
.makeCell($s.Remove Item.$e, 30%)
.makeCell($s.Price.$e, 30%)
);
// Wow, the odd total here is a lot more obvious!

$query =
SELECT uid, id, name, image, type, quantity 
.FROM {$config[prefix]}_shop 
.WHERE uid = {$session[uid]};
$res = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($res)) {
extract($row);
$content .= makeRow(
 makeCell(img src='$image')
.makeCell($s.$name.$e)
.makeCell($s.$quantity.$e)
.makeCell($s.input type='checkbox' 
.name='rem[$id]' value='true'.$e)
.makeCell($s.input type='text' value='' 
.name='price[$id]' size='8' maxlength='8'.$e)
);
}

echo
\nform
.makeTable($content, 95%)
.$s
.input type='reset' value='Clear form'
.input type='submit' name='update' 
.value='Update And Remove'
.$e
.\n/form;



... I have changed a few things; for one, instead
of removing items singly, I have refit a set of
checkboxes, returning an array of selected items
for removal.

Also, note my use of single-quotes inside the double-quoted
strings... I find this much easier to follow, instead of umpteen
dozen escaped double-slashes.

I hope this is of some use to you.
  Hugh.



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




Re: [PHP] Server-side imagemaps?

2002-04-16 Thread Hugh Bothwell


Leif K-Brooks [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 on 4/16/02 3:26 PM, Uchendu Nwachukwu at [EMAIL PROTECTED] wrote:

 Is there anyway I can use server-side imagemaps with PHP? I want to build
an
 application that lets people click on a picture, and have the coordinates
of
 the click on the picture be stored in a database. I've searched
www.php.net
 and it makes no mention of it.

 If I understand correctly, you want to know how to have to have the
 coordinates of a click sent to your script.  Use html something like this
to
 do that:
 form method=get action=yourscript.php
 input type=image src='/path/to/your/image.jpg'
 /form

 That would generate a query string something like
 yourscript.php?x=138y=327.  From there, you can do whatever you want
with
 the values.  Hope that helped!

form action='url/path/scriptname.php'
input type='image' name='myimage' src='url/path/image.jpg'
/form

will pass variables myimage.x and myimage.y BUT note
that to distinguish the variables from class members, PHP
processes that to $myimage_x and $myimage_y

Hope this helps.




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




[PHP] Notice: recent FAQ discussions

2002-04-05 Thread Hugh Bothwell

For anyone who may have missed the recent debate:

We seem to have come down to two groups:
the majority seem to be headed for a web-based
searchable FAQ, while a small minority - myself and
two or three others - want a succint text-based
FAQ to post on the newsgroup at regular intervals.

As the two are not mutually exclusive,  I am going
to wish the majority best of luck and proceed in
developing a postable FAQ, following the general
outline I posted several days ago.

I will post preliminary versions for comment as soon
as possible.



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




Re: [PHP] conditionally including classes/functions

2002-04-05 Thread Hugh Bothwell

 -Original Message-
 From: Andrew Warner [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, April 04, 2002 11:29 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] conditionaly including classes/functions

 Is it okay practice to condtionally include php files that contain
 only classes or functions (as opposed to just straight code)?   The
 result is a class or function inserted right in the middle of an if{}
 block:


I would find it much more useful to do something like
a transparent include-on-first-use; for a function this
shouldn't be too hard, but I have no idea how to make it
work for a class short of wrapping every method
independantly.

function MyLazy($a) {
if (!function_exists(contentsMyLazy))
include(contentsmylazy.php);// define the function

return contentsMyLazy($a);
}



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




[PHP] Re: PHP FAQ (again)

2002-04-03 Thread Hugh Bothwell

Justin French [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I saw this mentioned a few times recently, but I'd really like to put out
 the call again.

 This group needs an FAQ *specific to this list* which helps new members /
 posters integrate seamlessly...

Perhaps someone could quickly summarize and refer to
http://www.php.net/manual/en/faq.php
http://www.alt-php-faq.org/
http://www.kbcenter.com/category.php?parent_id=3
http://www.faqts.com/knowledge_base/index.phtml/fid/51/
http://pear.php.net/faq.php
http://www.php-faq.com/
http://www.phpworld.com/faq/faq_000.html
http://www.tek-tips.com/gfaq.cfm/lev2/4/lev3/31/spid/434
http://www.vbweb.co.uk/php/
http://www.cetus-links.org/oo_php.html
http://www.speakeasy.net/main.php?page=phpfaq
+ the list archives
+ posting etiquette

and point to php.net, zend.com, mysql.com, phpbuilder.com, etc...



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




[PHP] PHP FAQ (again) ... we have a plan!

2002-04-03 Thread Hugh Bothwell

I'm getting a bit interested in this; here's how I
suggest we proceed.

First, we have to agree on the scope of the project.
I suggest a small number of FAQs directed at specific
subjects (rather than one 5000-line monster); my
suggested breakdown follows below.

Second, I suggest storing these permanently in
an easily-referrable format so it's easy to quote the
official faq.  Would php.net be willing to host them?
Hard to find a more suitable spot...

Third, I suggest the introduction to php.net
should be posted to the php.general newsgroup
weekly, and the other faqs could maybe be
posted one per week in rota just to keep
everyone's memory fresh.

Fourth, we should have a set of guidelines for the
content (a faq faq?), ie

- each faq should start with links to the whole
list of permanently-stored faqs

- each faq should be no more than two layers deep
or 500 lines long; more than that, we should
consider splitting off a top-level subject into its
own faq.

- faqs should be text-only, or HTML equivalent
(modest background, URLs turned into links,
no graphical content) with rows no more than
72 characters long (easy to quote in a newsgroup).

- each bottom-level section should consist of a short
explanation, two to ten lines, followed by one
to three URLs for further reference.

- all URLs should be to stable, recognized sites;
OpenSource-affiliated sites should be listed first

Suggested content / breakdown:
==

+ introduction to php.net
  charter - the purpose of this newsgroup
  posting guidelines and etiquette
be specific
be terse
descriptive subject
include exact error messages
include code no more than N lines, else give URL
be polite
be thankful - no-one HAS to help you
don't cross-post
don't multi-post
don't spam
  how to subscribe / unsubscribe to the newsgroup
  how to subscribe / unsubscribe to mailing lists
  reference to archives
  reference to php.net manual

+ quick overview of the language
  what is PHP, short history
  most recent version
  where to download
refer to installation instructions
  terminology/jargon?
  refer to php.net manual
  refer to tutorials
http://www.zend.com/zend/art/intro.php
http://hotwired.lycos.com/webmonkey/programming/php/
  what else I should learn
HTML, JavaScript, CSS, SQL - links

+ installation, recompilation, configuration

+ name this function
  quick searchable function list with keywords, short
descriptions,  maybe very short examples, and links
to appropriate php.net manual page

+ advanced language questions
  what is a good development environment
  page redirection
  browser refresh / timeout
  I keep getting headers already sent
  how to print a number with leading zeros
  how to interact with JavaScript
  the difference between include() and require()
  playing with arrays
  playing with tables

+ forms, sessions, user authentication, cookies
  how to authenticate users
  playing with forms
  how to pass values from one script to another
  how to initiate a session
  how to terminate a session
  counting current users

+ php+database
  refer to mysql.com
  how to query a database
  how to get a limited number of rows

+ email
  how to validate an email address
http://www.zend.com/zend/spotlight/ev12apr.php
  sending email
refer to RFCs
plain text
HTML
multipart MIME
  processing email ie w/ procmail






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




Re: [PHP] Any ideas on combining arrays????

2002-04-03 Thread Hugh Bothwell

I'm not sure I understand what problem
you're trying to solve.

It looks something like the number of times
a given piece of data occurs per user?

Where does the data come from and what
are you trying to accomplish?


 Need some ideas on combining some arrays
 into one!  I have array for data and other array
 for counter.  How do I make an array that would show
 different data for each counter number?

 -- clip --
$FFR = array (
   TU4R  = array( data = , count =  ),
   PH01  = array( data = , count =  ),
);
 -- clip --




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




[PHP] suggestions on work-arounds to highlight_file() ?

2002-04-03 Thread Hugh Bothwell

using PHP 4.1.3-dev on WinME, I call

$a = str . highlight_file(file.php, true);

and get a warning,

Warning: Wrong parameter count for highlight_file() in myfile.php

and *don't* get the highlighted source I want.  show_source()
does precisely the same thing.

The manual says that PHP version = 4.0.0 should support
a second optional parameter... why would this fail?
Is there some other easy way to do this?  I have to get it returned
in a string to stuff it into my template.



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




[PHP] Re: Help with nested if statements, is this possible?

2002-04-01 Thread Hugh Bothwell

... an old C trick: when comparing a variable to a
constant, put the constant first, ie

if (Completed == $payment_status) {
}

that way, if you accidentally use 'assignment-equals'
instead of 'equivalence-equals', you get a syntax error.


Martinahingis [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 if ($payment_status = Completed)
 if you do this your if statement is invalid
 You should do




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




[PHP] Re: $PHP_SELF

2002-04-01 Thread Hugh Bothwell

In php.ini, there is a setting called short_open_tag
which controls whether ? is recognized as shorthand
for ?php

Try using ?php instead - if that works, then your
problem has been identified.


 I have a question that could be Apache, could be
 php, but I'm so new to this I have to ask: what is
 wrong with my code for the form action?  Apache
 does not recognize the ? as the beginning of php
 code and gives an error filename is not valid
 whenever this form is submitted [note: phpinfo()
 and several other php files work with no problem]?




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




[PHP] Re: Changing black to blue (2)

2002-03-31 Thread Hugh Bothwell

 I have a map of the world with all countries. I have
 250 maps of the same size as png where only one
 country is black, rest is transp.
 Now I neeed to set this country color to blue or red
 to indicate a special spot.
 I just don't want to save the same map double or tripple.

Good!  Makes much more sense.

Call this like
img src='country.php?cty=germanycol=255,0,0'
(functions in bold you will have to write yourself)
== country.php ===
?php
Header(Content-type: image/png);
$mapURL = '\images\countrymask\'.MAKESAFE($cty);

// load image
$img = ImageCreateFromPNG($mapURL.$mapname)
or MAKEDEFAULTIMAGE();

// parse new desired color
$newcolor = split(',', $col);

// find black
$oldcolor = ImageColorResolve($img, 0, 0, 0);

// change to new color
ImageColorSet($img, $oldcolor, $newcolor[0], $newcolor[1],
$newcolor[2]);

// ... and return result
ImagePNG($img);
?

Note that depending on how much this gets used,
it may indeed be better (faster, less computationally
intensive) in the long run to use multiple image
copies, ie country_red.png, country_blu.png etc.



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




[PHP] Re: Has anyone written such a function?

2002-03-30 Thread Hugh Bothwell

(shrug) convert to unixtime, subtract, and reformat

In fact, you could do the conversion and subtraction in your SQL query,
returning just 'elapsed seconds since date', and reformat from there.

 I need a function that will get a date in the past and return how much
 time has passed since that date till now.
 The input to the function is a MySQL DATETIME format and the output
 should be something like :

 2 Years, 36 Days, 7 hours , 25 minutes

 I would write it but I'm pretty sure it has been done.




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




[PHP] Re: changing the color from black to blue on an image. Help on imagecolorset.

2002-03-30 Thread Hugh Bothwell


Andy [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi there,

 I would like to change the color on a png file from black
 to blue. This png file is transparent and contains only a
 spot which is black. It is needed to stay transparent
 because I am gonna merge it later on with a jpeg.

... why are you trying to do this in PHP?  Why not use
Photoshop to edit the original .png graphic?



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




[PHP] Re: problems trying to use PHP to choose CSS

2002-03-30 Thread Hugh Bothwell

 I am trying this method: Register a global variable ($CSS) using a FORM.
 [snip]
 I wonder if I am not doing something stupid/overlooking something obvious,
 but I am very new  PHP so that is possible.

 // in my global PHP file

 // Now what I am trying to do here is set a default that should ONLY be
 // used if the $CSS variable is NOT already set

 if (!isset($CSS))
 {
 // if it is not set, then and only then set it and define it
 session_start();
 session_register(CSS);
 $CSS=global;
 }


1.  session_start() should called every time,
ie not inside a conditional clause.

2.  I'm not sure that giving the form-return value
and the session value the same name is a good idea.

3.  I think a lot of the double-quotes in your echoed
text were screwing things up.


Try something like:

?php// HEADER
session_start();

// new session?  set default value
if (!session_is_registered(CSS)) {
session_register(CSS);
$CSS = global;
}

// setting changed by form?  update session value
if (isset($newCSS))
$CSS = $newCSS;
?


!-- USAGE --
link type='text/css' rel='stylesheet' href='/global/css/?php echo
$CSS; ?.css' /


!-- FOOTER --
pChoose style:
form method='post'!-- default action is get-to-self --
select name='newCSS'
option value='default' selectedDefault/option
option value='smaller'Smaller/option
option value='tamecolors'Tamer Colors/option
option value='print'Print/option
/select
input alt='Set Style' type='submit' name='Set Style' value='Set
Style' /
/form
/p
pCurrent style is: strong?php echo $CSS; ?/strong/p





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




[PHP] Re: Nead Help With A Php Script

2002-03-30 Thread Hugh Bothwell

 I need a php script that checks if the there is a
 cookie set with the users username and if not it
 brings you to an other page and telling you that
 you are not loged in!


(a)  Don't cross-post all over.


(b)  Cookies 'automagically' become global variables, so
a simple version is

if(!isset($username)) {
header(Location: http://www.mysite.com/login.php;);
exit;
}


(c)  Obviously, this won't prevent someone from
faking a username via the querystring, so you have to
specify that it's a cookie:

if(!isset($_COOKIE[username])) {
header(Location: http://www.mysite.com/login.php;);
exit;
}


(d)  Doesn't work?  What do you mean, doesn't work?
OK, if you are using pre-4.1.0, it won't work
(you would have to look in $HTTP_COOKIE_VARS[]
instead)  BUT note that there are known security
flaws so you should be running 4.1.2 anyway.


(e)  It's kind of irrelevant anyway - because unless you
are really always positively certain your users are
cookiefied, you should be using sessions, in which case
what you really want is

session_start();

if(!session_is_registered(username)) ])) {
header(Location: http://www.mysite.com/login.php;);
exit;
}




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




[PHP] Re: Nead Help With A Php Script

2002-03-30 Thread Hugh Bothwell

Aaargh!   typo...

 if(!session_is_registered(username)) ])) {

should be

if(!session_is_registered(username)) {



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




[PHP] Re: Disabling the Back Button?

2002-03-30 Thread Hugh Bothwell

You're asking the wrong question.

'Disabling the back button' changes the expected behaviour
of the browser and as such is an *EVIL* thing to do, roughly
on par with driving the wrong way down one-way streets or
spray-painting your neighbor's cat.

What you want is to 'prevent the user from accessing or
resubmitting the form after it has been submitted', and
the question is the answer: when the form is submitted set
a flag; check the flag before showing a page or accepting
a submission.


David Johansen [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 OK, I basically just want to make it so that the user can't go back once
 they're done with an application form that I'm working on. I don't case if
 they go back in the middle and my page handles that just fine, but I want
 them to not be able to go back when they're all done. Is there some way
that
 I can do this? Thanks,



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




[PHP] Re: OT - representing data

2002-03-29 Thread Hugh Bothwell

How about a hierarchical tree?  Strip the common precursor stuff
([http[s]://][www.]) and proceed from there, splitting on '.', '/', '?' and
''.

I would also put a Yahoo-style split-level back-out link on the page, ie
[nandotimes].[com]/[news]/[current]/
article2001.html(1 ref  4000 views)
article2002.html(1 ref  2500 views)
   [article2003.php]   (4 refs  6600 views)
article2004.html(1 ref  800 views)
(where [text] indicates a hyperlink)

Combine this with your restrictor text box and N-items-per-page and it
should be reasonably navigable.


 I have over 26000 urls in a table. They are all urls and query strings of
 hits to the same 10 - 20 sites.

 I need to have a way to allow the user to select one of these, and then do
 some processing on it, and I'm struggling to find a way.

 I did have a select dropdown with a list of them, but that has become
 unmanageable, even when coupled with a restrictor text box. For example,
the
 user types 'david' in the restrictor, and then the dropdown only lists
those
 urls with '%david%'

 Has anyone got a genius way of allowing the user to select one easily and
 without having to download all 26000.



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




[PHP] Re: Is this code safe?

2002-03-28 Thread Hugh Bothwell


Richard Ellerbrock [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 $result=mysql_query(DELETE FROM customer
 WHERE customer=$cust,
 $ds) and
 $result=mysql_query(DELETE FROM custinfo
 WHERE customer=$cust,
 $ds) and
 $result=mysql_query(DELETE FROM revdns
 WHERE customer=$cust,
 $ds) and
 AuditLog($ds, sprintf(my_(User %s deleted customer cust %u),
  $HTTP_SERVER_VARS[PHP_AUTH_USER], $cust));

Note: you had better do a thorough job of validating $cust, lest someone
pass something charming like

$cust = '39428 or customer  0';

which might be enough to make your whole *week* interesting.



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




[PHP] Re: Advice needed

2002-03-23 Thread Hugh Bothwell

Actually, it looks pretty straight-forward:

?php

$points = array( 1, 2, 3, 5, 10, 15, 20, 25, 50, 100, 300, 500, 600,
10 );
$prices = array();


function init_prices() {
global $points, $prices;

foreach($points as $val)
$prices[$val] = none;
}

function show_prices() {
global $points, $prices;

foreach($points as $val)
echo q$val: .$prices[$val].br /;
}

function add_price_point($num, $price) {
global $points, $prices;

// this saves us from div-by-0 and automatically
// discards invalid quantities
if ($num  1)
return;

$per = $price / $num;

foreach($points as $val)
if ($val = $num)
if (($prices[$val] == none) or ($prices[$val]  $per))
$prices[$val] = $per;
}


init_prices();

add_price_point($Quantity1, $Price1);
add_price_point($Quantity2, $Price2);
add_price_point($Quantity3, $Price3);

show_prices();

?


 q1 q2 q3 q5 q10 q15 q20 q25 q50 q100 q300 q500 q600 q10
 0  0  0  0  .10 .10 .10 .10 .10 .10  .10  .10  .10  .10

Note that this is a messy and misleading way to do things:

1.  Having '0' as the price for un-valued quantities is dangerous, unless
you want to tell me that 4 or fewer items are free.  Note that in my code I
have replaced it with none, which isn't much safer (it may get cast to 0)
but is a lot more obvious when debugging.

2.  What's with all these price points?  Surely it would be cleaner to keep
just the decision points in your database instead?

- what happens if you can get a cheaper price on 120 items (or on any
arbitrary number of items not in the list)?  Will you just defer it to the
next number of items (in my example, 300)?  Your customers might be
unhappy...



 Now the tricky part is $Quantity2 can either be blank or have a value
 and if $Quantity2 has a value then $Quantity3 can either be blank or have
a
 value

This is quite simply - let the function itself check whether it has been
passed a valid quantity - if not, return without doing anything.  Voila -
valid results and code that is easy to read.



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




[PHP] Re: PHP for 3D scatterplots

2002-03-20 Thread Hugh Bothwell


Simon De Deyne [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 is there any code for this available yet?
 I am looking for a way of plotting gif images of objects
 in a 3D space...

 thank you!
 Simon

Don't know of any offhand, but it doesn't sound all THAT hard to develop...
actually, it could be kind of interesting.  In fact, if you want to include
a few more details I might whip up a demo for you.

- what kind of axis scaling do you want?  (linear / log)
- axis data range figured how? (specified / auto)
- where do you want the axis drawn (back edge / full box / at 0s)
- what kind of projection (orthogonal / perspective)
- how to draw data points (single-pixel / ball / icon)
- depth indication (none / shading / drop-line to axis / other)
- should data points be scaled (no / by size / by color)
- how to handle overlapping / coincident data (ignore / emphasize)
- how to color data points (specified / per-point / random/arbitrary)



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




[PHP] Re: [PHP-DB] I cant get the logic for this...

2002-02-19 Thread Hugh Bothwell

?php

$nWidth = 3;// desired table width
$nPos = 0;// current-column counter

// do database query
$res = mysql_query(???);

// start table
echo table;

// while there is data...
while($row = mysql_fetch_object($res)) {
// begin new row if appropriate.
// NOTE: Of necessity, I separate this from the
// end-of-row test; otherwise, a query returning
// an exact multiple of the table width would
// result in a table with an empty final row.
if (0 == $nPos)
echo tr;

// write a cell and increment location
echo td.your_stuff./td;
$nPos++;

// end row if appropriate and reset location
if ($nWidth == $nPos) {
echo /tr;
$nPos = 0;
}
}

// calculate padding needed for final row
// NOTE: if-and-only-if padding is required,
// the row must be terminated; otherwise the
// row must have already been terminated.
$nEmpty = $nWidth - ($nPos+1);
if ($nEmpty  0)
echo td colspan='$nEmpty'nbsp;/td/tr;

// end table
echo /table;

?


 So my result returns say seven results, I have a table, and I want to
 show
 3 results per row of the table... I.e.:
 
 Table
 TR
 TD = result1 /TD  TD result2 /TD TD = result3 /TD
 /TD
 /TR
 TR
 TD = result4 /TD  TD result5 /TD TD = result6 /TD
 /TD
 /TR
 TR
 TD = result7 /TD  TD resultempty /TD TD = resultempty /TD
 /TD
 /TR
 /table
 
 The last two td in row 3 are empty because result found 7 results.
 
 This cant be fixed so echo statements wont work as the result could
 Be 3 or 10 or 56 or whatever.
 
 As Always your help and or guidance in this matter is appreciated.
 
 Dave Carrera
 Php / MySql Development
 Web Design
 Site Marketing
 http://www.davecarrera.com




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




[PHP] Re: Storing Newsletter in Database

2002-02-19 Thread Hugh Bothwell


Kevin Old [EMAIL PROTECTED] wrote in message
030701c1b988$cf93df30$0701a8c0@KOLD">news:030701c1b988$cf93df30$0701a8c0@KOLD...
 Hello all,

 I have a challenge that has been put on me.  I have built a website for my
 church and we are now wanting to put our newsletter online.  It is
currently
 being done in Microsoft Publisher.

 I would like to take the MS Publisher file and extract the data and insert
 it into a database (PostgreSQL) and then display it via PHP.  Catch is,
the
 data is not that consistent.

What sort of data are we talking about?  Like, group meeting
times?  Where do you get the data that goes into the newsletter?



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




[PHP] Re: problem with working with dates

2002-02-15 Thread Hugh Bothwell

 but for some reason, no matter what the month, the first if statement
 (if current_month = 1) is seen as true and executes...  any suggestions?

Try using 'equivalence-equals' (==) instead of 'assignment-equals' (=).



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




[PHP] Re: How can I open URL using HTTP POST instead of HTTP GET?

2002-02-10 Thread Hugh Bothwell


Zlutarch G. [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi everyone,

 PHP fopen function opens URL using the HTTP GET method. But what if one
 could only open the web page using the HTTP POST method? In this case,
fopen
 won't work. Is there a PHP function that is similar to fopen, but uses
HTTP
 POST method to open URL instead? If not, then how do I work around this
 problem?

Umm... you might have to open a socket and read/write directly.
To do this, you'd have to look up the appropriate RFCs and write
the headers manually.

Anyone got a better idea?



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




[PHP] Re: Webcam on websites? Ugh!!!

2001-12-16 Thread Hugh Bothwell


Webleycity [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 A client wants a webcam on his site. Does any body know what script is
used
 and how it works.

The camera should come with a prog to take a snapshot.
Write a batch file that takes a snapshot, then uploads it
to your web server.  Write a batch file that calls the first
batch file every 55 seconds, OR make it a timed job via
cron.

Add javascript to the web page to call the new
graphic every 60 seconds and swap it in after it is finished
loading.  The five-second difference is to ensure that
small delays will not cause the same picture to be reloaded
again.

If you have loads of space, you could keep an archive;
otherwise I suggest overwriting the existing image each
time or maybe alternating between two names.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Need high bandwidth provider for my Asian community site

2001-12-16 Thread Hugh Bothwell


Webleycity [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 If one creates a file outside the web space on a server. How doe's one
 connect to this from a HTML or PHP page?

 As I understand it. It is not as simple as normal html link.

From an HTML page, it's just a simple link
(the same goes for generated HTML from a
PHP page).

Calling external files from PHP code depends
first on the security settings and second on the
realization that it will slow things down dramatically;
unless it's absolutely necessary, keep files local.




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Store locator / postcode proximity

2001-12-10 Thread Hugh Bothwell


Rich Buggy [EMAIL PROTECTED] wrote in message
018a01c18160$c463c180$[EMAIL PROTECTED]">news:018a01c18160$c463c180$[EMAIL PROTECTED]...
  I'm wondering if anyone has any information about how to get the
  proximity data for postcodes in Australia? Or is it safe to assume
  that if a postcode is, say, 3107, that 3120 or 3110 (for example)
  are nearby as well as 3108 (so, perhaps, 10 above and 10 below could
  be safely assumed to be nearby?)

   Don't even bother trying that for Sydney. There's a border around
Western
 Sydney where the Eastern suburbs are 21xx and the Western ones are 27xx.
For
 example 2148 and 2767 are next to each other.

A search at google.com for australia list postal code got me
http://www.auspost.com.au/postcodes/
from which you can download the full dbase in .csv format...
it gives you town/suburb info which could probably be sufficient.

Alternatively, take a look at
http://www.mapds.com.au/NowWhere_/nowwhere_.html
which provides exactly what you are looking for as a
monthly-fee service (no prices listed, give them a call).




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: eval on a form

2001-12-10 Thread Hugh Bothwell


Paul Roberts [EMAIL PROTECTED] wrote in message
000d01c18101$5dbb2220$01f8883e@laptop1">news:000d01c18101$5dbb2220$01f8883e@laptop1...
 Hi

 I'm trying to pre-fill a form ( the data is passed via sessions or from
 another script).

 i have some check boxes on the form that i would like checked if the
 variable is present.

 any ideas

I would write a checkbox-presenting function - pass it the name of
the variable the checkbox represents, it will see if the variable is set
(and if so, denote it CHECKED) and name the checkbox properly.
This should encapsulate stuff nicely and make your source easier to
follow; something like

function CondCheckbox($variablename) {
$str = INPUT TYPE='CHECKBOX' NAME='$variablename';

  if (isset($GLOBALS[$variablename]))
$str .=  CHECKED;

  return $str.;
}

(note: I have not actually run-tested this; it should be pretty close,
though)


Then your form will look something like

Ingredients:
FORM
?php
echo CondCheckbox(flour).Flourbr;
echo CondCheckbox(butter).Butterbr;
echo CondCheckbox(salt).Saltbr;
echo CondCheckbox(oatmeal).Oatmealbr;
?
input type='submit'
/FORM


Is this something like what you were after?  It would help
if you gave us a slightly more detailed idea of what sort of
data was involved.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Redirect function

2001-12-10 Thread Hugh Bothwell


Steve Osborne [EMAIL PROTECTED] wrote in message
000901c181db$bfca1f40$[EMAIL PROTECTED]">news:000901c181db$bfca1f40$[EMAIL PROTECTED]...
 Is there a function or command in php that will redirect a user to another
 page, similar to Response.Redirect(URL) in ASP?


header(Location: http://www.MyNewUrl.com/index.php;);



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: time stuff

2001-12-10 Thread Hugh Bothwell


[EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 suppose the date is 12-10-01
 --
 $timestamp = time();
 
 //this is the sent on date
 $yd_expl = explode(':',08-01-01);

Uh, better make that
... = explode('-', '08-01-01');

Otherwise I think you'll get { 6 } instead of { 8, 1, 1 }



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Application servers / job priorities ?

2001-10-24 Thread Hugh Bothwell


Lee [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I am developing a portal that will allow users to perform various
 calculations on their data sets. These calculations (handled by C /
 Fortran programs) will be run as external processes (and may take up to
 a few hours to complete). I am wondering if there is something that I
 can use (either in PHP or as another external process) to act as an
 application server i.e. allow multiple users to submit requests for
 calculations, but place these requests in a queue - perhaps associating
 each calculation with a priority, and handling each request as
 appropriate.

 Can anyone suggest anything that may faciliate this? Any links/hints
 would be greatly appreciated. Thanks very much in advance.

I would separate this into front end/back end systems.

The front end lets people sign in, submit a data set, request an operation,
and set the priority.  It should let them view job status and
reorder/reprioritize the jobs.  All this information gets stored in a
database (three tables - one for users, one for data sets, one for jobs).

The back end runs independantly - repeatedly queries the database to find
the next most urgent job and spawns a program to do the calculation.  Play
with the number of concurrent threads per processor to find a good balance
to keep the system busy but not bottlenecked.

This set-up would make it very easy to distribute the calculations across
multiple systems to speed things up.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: new to php

2001-09-09 Thread Hugh Bothwell


Kostis Mentzelos [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 is it possible to create a table that automatically
 updates its contents every 30 seconds?

I would use JavaScript to make the page reload itself.

Note: this could generate a LOT of traffic.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: cleaning up the uri

2001-09-09 Thread Hugh Bothwell


Jon Thompson Coon [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I don't want to ask all these silly questions constantly time, but being
 lazy overcomes the urge not to do so.

 Having a page somethin/somewhere/index.php?do=thisand=that. This page
 does some updating and database queries. Hitting the reload button makes
 these things happen again (obviously). My question is, what are the
 usual ways of dealing with this problem?

 I don't want to separate my code into separe files, i.e. linking into a
 script that does the updating and redirects to the original page without
 the do=thisand=that part.

... so make the two pieces the same file... have the script redirect to
itself minus the parameters.

ie,
= xyz.php ===
?php
if (isset(do)) {
do database stuff
header(Location: xyz.php?submitted=true);
}
else if (isset(submitted)) {
thanks for submitting
}
else {
show form
}
?
==



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Error handling and the usage of @

2001-09-07 Thread Hugh Bothwell


Seb Frost [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Could someone give me an example of the sort of error handling you put in
 your php scripts?  Cheers.  Should I be preceding every command with @?
 Anything where this would be harmful?  Just looking for some pointers
really

In general, stuff that (a) might fail in normal
use and (b) prints an unwanted error message.

This usually deals with calls to external
programs, stuff that sometimes be down.
In my case, this is pretty much restricted to
mail() and the mysql_xx functions.




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: Error handling and the usage of @

2001-09-07 Thread Hugh Bothwell


Seb Frost [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 So I should chuck it on all mysql functions?  Done.  Don't ya just love
 search and replacing a whole directory of scripts :-)  Still works fine
 too - bonus!

er...

I should have noted - if you are going to surpress the default error
messages, you need to do your own custom error checking to replace it... ;-)



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Statement Confusion

2001-09-06 Thread Hugh Bothwell


Pavel Jartsev [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Jordan Elver wrote:
 
  Hi,
  Could any one explain what this statemnt means?
 
  $i = (!$i)?0:$i;

Well, literally, if not-$i is equivalent to true then $i becomes string
0, otherwise $i 'becomes' $i.

A more obvious approach would be
if ($i == 0)
$i = 0;

I assume you got this out of some sort of integer-to-string conversion code?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: how to get all the records of a particular month....

2001-09-03 Thread Hugh Bothwell


Sagar [EMAIL PROTECTED] wrote in message
001b01c1347e$b58e2580$6dfb7ccb@ravella">news:001b01c1347e$b58e2580$6dfb7ccb@ravella...
 I hope some one will solve my problem.
 I have a table in which a field is of date type.
 i want a mysql query to get all the records of the table
 into an array of  a particular month.

Some clarification is needed: do you want all entries for
a given month of ANY year, or of a specific year?

If the first, I would use
SELECT * FROM table
WHERE MONTH(datefield) = mm
(See the MySQL documentation, section 7.4.11)

Or, for the second
SELECT * FROM table
WHERE datefield BETWEEN
'-mm-01' AND '-mm-31'

... how's that?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: EDI with PHP?

2001-09-03 Thread Hugh Bothwell


Jon Farmer [EMAIL PROTECTED] wrote in message
003f01c1345c$53e385e0$[EMAIL PROTECTED]">news:003f01c1345c$53e385e0$[EMAIL PROTECTED]...
 The company I work for is starting to lose contracts because they are not
 capable of EDI. As I seem to be the only person in the company who has
heard
 of EDI and knows what it stands for I am assumed to be an expert :-)

Ain't it always the way :-)

 Anyway, I would like to suggest that instead of EDI we use XML and use PHP
 both as a parser and a creater of the EDI like transactions. I would
propose
 they are sent over the net and probably PGP encrypted or signed. I have
done
 some minor work with PHP and XML, mainly credit card authorisation, but
 wondered how suited it would be to this kind of app?

http://www.computerworld.com/cwi/story/0,1199,NAV47-68-85-1552_STO55904,00.h
tml
http://www.xml.com/search/index.ncsp?sp-q=EDI

PHP should be quite capable of handling this,
but you will end up creating a lot of the business
logic from scratch.  If your company already uses
integrated management software like SAP, it may
have EDI capabilities built in.





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: database searching

2001-09-03 Thread Hugh Bothwell


Melih Onvural [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 i want to randomly choose a column in a database with a quote in it, by
the
 number of the column.
 i have a random seed working, but it won't pull only one column, but all
 columns. How can I choose
 just one column, and print one column at a time?

SELECT text FROM quotes ORDER BY RAND() LIMIT 1



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Pulling a random image

2001-09-03 Thread Hugh Bothwell


Brad R. C. [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 But what my goal was is to make it where it goes through all the images
 before showing a random twice.

... if you actually want to do this, you will have to keep track
of which items you have seen in the last rotation.


 Now... I thought the following function did that, but for some reason it
is
 not...

Nope.  You are just (inefficiently) choosing one item at random.

An equivalent-but-faster approach would be
SELECT * FROM user
WHERE valid=1 AND inrotation=1
ORDER BY RAND() LIMIT 1


If you really need random-order, once-per-cycle images,
you could achieve it by adding a 'views' field to the table;
initialize all entries to the same value (ie 0).  Each time an image
is displayed, increment the views; when you choose an image,
choose from the pool where the views value is minimal, ie.

SELECT id,imgname FROM user
WHERE valid=1 AND inrotation=1 AND views=MIN(views)
ORDER BY RAND() LIMIT 1

UPDATE user SET views=views+1
WHERE id=$id

How's that?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Database Function

2001-09-02 Thread Hugh Bothwell


Georgie [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I have a simple php script that searchs a MySQL database and returns
results
 that I made myself and I'm trying to implement code that splits the
results
 into x amount of pages, buts it really tricky.

... if you want X results per page, look at the LIMIT clause for your
SQL statements.

If you actually meant X _pages_ (... I don't see where this would be
useful, but hey...) I would check the number of returned results
with mysql_num_rows(), calculate the start-row offset, and then
mysql_data_seek() to the place you want.

Either way, it's actually pretty simple.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] number to word converter

2001-08-31 Thread Hugh Bothwell

Here is a slightly more readable number-to-English converter.  It will deal
with negative numbers and recognizes zero; it's table-driven, so it
shouldn't be too hard to convert to other languages.

It will convert anything in +/- 10^30.  This should be pretty comprehensive;
if not, extend the triplets table (and email me to explain what on Earth
you're doing with it!! ;-)

?php

// Hugh Bothwell  [EMAIL PROTECTED]
// August 31 2001
// Number-to-word converter

$ones = array(
 ,
  one,
  two,
  three,
  four,
  five,
  six,
  seven,
  eight,
  nine,
  ten,
  eleven,
  twelve,
  thirteen,
  fourteen,
  fifteen,
  sixteen,
  seventeen,
  eighteen,
  nineteen
);

$tens = array(
 ,
 ,
  twenty,
  thirty,
  forty,
  fifty,
  sixty,
  seventy,
  eighty,
  ninety
);

$triplets = array(
 ,
  thousand,
  million,
  billion,
  trillion,
  quadrillion,
  quintillion,
  sextillion,
  septillion,
  octillion,
  nonillion
);

 // recursive fn, converts three digits per pass
 function convertTri($num, $tri) {
  global $ones, $tens, $triplets;

  // chunk the number, ...rxyy
  $r = (int) ($num / 1000);
  $x = ($num / 100) % 10;
  $y = $num % 100;

  // init the output string
  $str = ;

  // do hundreds
  if ($x  0)
   $str = $ones[$x] .  hundred;

  // do ones and tens
  if ($y  20)
   $str .= $ones[$y];
  else
   $str .= $tens[(int) ($y / 10)] . $ones[$y % 10];

  // add triplet modifier only if there
  // is some output to be modified...
  if ($str != )
   $str .= $triplets[$tri];

  // continue recursing?
  if ($r  0)
   return convertTri($r, $tri+1).$str;
  else
   return $str;
 }

// returns the number as an anglicized string
function convertNum($num) {
 $num = (int) $num;// make sure it's an integer

 if ($num  0)
  return negative.convertTri(-$num, 0);

 if ($num == 0)
  return zero;

 return convertTri($num, 0);
}

?

and a test fn I wrote,

?php
  function randThousand() {
   return mt_rand(0,999);
  }

 // Returns an integer in -10^9 .. 10^9
 // with log distribution
 function makeLogRand() {
  $sign = mt_rand(0,1)*2 - 1;
  $val = randThousand() * 100
   + randThousand() * 1000
   + randThousand();
  $scale = mt_rand(-9,0);

  return $sign * (int) ($val * pow(10.0, $scale));
 }

// example of usage
for ($i = 0; $i  20; $i++) {
 $num = makeLogRand();
 echo br$num: .convertNum($num);
}
?

Usage is simple:
convertNum(integer) returns a string, the value in English.

Hope this helps.





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Databases, arrays and woes

2001-08-30 Thread Hugh Bothwell


Kath [EMAIL PROTECTED] wrote in message
015301c13156$2c273500$[EMAIL PROTECTED]">news:015301c13156$2c273500$[EMAIL PROTECTED]...
 I have a MySQL table which stores information like this:

 | Type | Place Name | Place Abbrv |

 and lets say I have data in the table like:

 Example #1:
 | Office | Bill's Office | bo |
 | Store | Millcreek Supply | mcs |
 | Office | Harry's Office | ho |
 | Store | Sam's Discount Taxidermy | sdt |
 | Shipping | East Coast Distribution Facility | ecdf |

 What I'd like to do is be able to have PHP grab the information out of the
 database and sort like this on a webpage:

 Type Name #1:
 - Place Name (with hyperlink using the abbrv)
 - Place Name (with hyperlink using the abbrv)

 Type Name #2:
 - Place Name (with hyperlink using the abbrv)
 - Place Name (with hyperlink using the abbrv)

 What is the best way to do this?  I've tried arrays, different MySQL
calls,
 voodoo, ouija boards and drinking, but nothing has gotten me what I need.

This is a recurrent question; I'm going to write
a quick answers page for the _next_ 20 people
who ask this.

Basically, the answer is a mix of MySQL and PHP:

In MySQL, query your records, sorted by the
header column (so that all occurrences with the
same value are together).

In PHP, keep a 'last-known header' variable.
If the next header doesn't match the previous
one, you're starting a new block - so print a
new header.  Otherwise, you're continuing an
existing block, so skip the header.


?php
$conn = @mysql_pconnect(host, user, pwd)
or die(Error connecting: .mysql_error());

$query =
SELECT type, placename, placeabbrv 
.FROM places 
.ORDER BY type,placename;
$res = @mysql_db_query(db, $query, $conn)
or die(Error querying: .mysql_error());

$lasttype = ;
echo \n\tul;
while ($row = mysql_fetch_array($res)) {
extract($row);

if ($lasttype != $type) {
echo \n\t/ul\nbr$type\n\tul;
$lasttype = $type;
}

echo \n\t\tlia
href='places_$placeabbrv.html'$placename/a/li;
}
echo \n\t/ul;
?

Hope that helps.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Random number

2001-08-30 Thread Hugh Bothwell


Rosen [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi,
 I'm using PHP code from manual:
 srand( (double) microtime() * 100);
 // Get random User ID
 $uid=rand();

 but it dowsn't work !

... I would make sure that microtime() is doing what you think it is;

something like

for ($i = 0; $i  100; $i++) {
$k = (int) microtime();
echo br$k;

for ($j = 0; $j  1; $j++)
$m = $j *3;
}

If you get a page of '0 / 0 / 0' you'll know what your problem is...



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: script preprocessor?

2001-08-29 Thread Hugh Bothwell


[EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

  Is there a macro preprocessor that can be used to substitute arbitrary
  sections of code with different code? define is documented as working
  for rvals only and my attempts to produce something more meaty lead to
  parse errors.

You could define the code as a function, then check which version of the
function to use...

?php
define(DEBUG, true);

if (defined(DEBUG) and DEBUG==true) {
function myMacroizedCode() {
echo This is debug-mode code;
}
}
else {
function myMacroizedCode() {
echo This is non-debug code;
}
}

for ($i = 0; $i  100; $i++)
myMacroizedCode();
?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Developer

2001-08-28 Thread Hugh Bothwell


Vincent - D. Ertner [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi phpers,

 I'm looking for a PHP Developer ... what is probably the
 best way to go for it?

General procedure is to give a rough sketch of what you want to accomplish,
what development tools you are using, how long it will take, and a request
for either quotes or resumes (depending on whether it's permanent or not).



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: double check query statement??

2001-08-28 Thread Hugh Bothwell


Gerard Samuel [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   $query = SELECT mpn_job.ID, job, assigned_to, status_date, category;
   $query .= FROM mpn_job, mpn_job_category WHERE CID =
 mpn_job_category.ID;
   $query .= AND category = '$category';
   $result = mysql_query($query);
   $row = mysql_fetch_row($result);
   foreach ($row as $data) {
  echo $data[0];
   }

 I tried the SELECT statement from mysql command line (less $category, I
 used an actual category name) and it works there.  I try it out in php,
 and I get nothing.  (I echoed $category before this and it works
 correctly)  Do you guys see anything in there that may need correcting?

Sure - you need to have an extra space at the
end of each line... right now, it comes out like
... status_date, categoryFROM mpn_job ...
 ... mpn_job_category.IDAND category ...

I often find it useful to echo the query statement
just before using it... it makes mistakes like this
kind of obvious.

Also, if you used
$result = @mysql_query($query)
or die(Error querying: .mysql_error());
you should get more-useful error messages.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: What is it with _vti?

2001-08-26 Thread Hugh Bothwell


Seb Frost [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I have these _vti_pvt _vti_cnf directories on my website.  Why?  I never
put
 them there... can I delete them?

 I tried searching for this but it's impossible to search for since it
seems
 a lot of website have these directories and it just comes up with them :-)

Those directories are for Frontpage extensions.  If you don't use Frontpage,
it should be safe to take an axe to them.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: global variable.

2001-08-25 Thread Hugh Bothwell


Nafiseh Saberi [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 hi.

 I want to use glabal variable.

 ?
 global $a;

 ?
 but it doesnot work??

... why do you think you need to use global here?

global is used *in a function* to let it see
external variables.  You are not in a function,
so I don't see why you think you need it.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: sizeof(int)

2001-08-25 Thread Hugh Bothwell


Saurabh Kapoor [EMAIL PROTECTED] wrote in message
001901c12d63$b1b62100$9e2823d9@killer666">news:001901c12d63$b1b62100$9e2823d9@killer666...
 I am a C programmer, looking to migrate some code to PHP (Unusual, but my
 colleagues request it).

 Can someone tell me the size (in bytes) of the type int in PHP.

 I need a 16 bit (2 byte) storage unit (I use a lot of bitwise operations)

Try this:

?php

 $val = 2; $last = 1; $pow = 1;

 echo pre\n(0) 1\n(1) 2;
 while ($val  $last) {
  $last = $val;
  $val = $val  1;
  $pow++;

  echo \n($pow) $val;
 }
 echo /pre;
?

Running PHP 4.0.6 on WinMe, I get 32 bits.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] $i % 2 ? 0:

2001-08-25 Thread Hugh Bothwell


Mike Cullerton [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 it's an if/else shortcut.

 the part before the '?' is tested. '$i % 2' in your case.

 the part after the '?' is returned if the test evals to true. '0' in your
 case.

Documentation at
http://www.php.net/manual/en/language.operators.comparison.php

Think of ( A ? B : C ) as

if (A)
return B;
else
return C;

For example,
$a = 2;
echo The value of a is . ($a == 2 ?  :  not ) .  2;



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] help

2001-08-25 Thread Hugh Bothwell


Tyler Longren [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 On Sat, 25 Aug 2001 15:03:49 +1000
 GaM3R [EMAIL PROTECTED] wrote:

  can anyone explain to me exactly what this would do differently?
 
  $data = fread($fp, filesize($file));
 
  $data = fread($fp, filesize($file));

 That will stop fread from producing errors.  So, if you don't want to see
 any error's from fread, put a  in front of it.  This can also be done
 with other functions:

 $db = mysql_select_db(dbname);

You're thinking of the @ error-control operator.
'=' is 'get a reference to the returned array'.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: How to download a picture thru http://?

2001-08-24 Thread Hugh Bothwell


Tamas Bucsu [EMAIL PROTECTED] wrote in message
012c01c12c8b$49cf6750$1100020a@domain1">news:012c01c12c8b$49cf6750$1100020a@domain1...
 Is there any special way to get some pics from
 the web? Cos' what I wrote just does not work.
 Thanks


  if (file_exists($kepnev)){

 $kepnev=http://www.stg/pics/somethinggy.jpg;];

   $fdr = fopen($kepnev,r);
   $fdw = fopen($kepnevshort,w);
   while (!feof($fdr)) {
fputs ($fdw,fgets($fdr, 4096));

   }

   fclose($fdr);
   fclose($fdw);
  }
 }

The simplest method, assuming
the file is web-accessible, is probably
echo img src='$kepnev';

If you really need to pass the raw image data
back (ie you're pulling it out of a database or
server file system or dynamically generating it),
you have to start with appropriate headers to
tell the browser how to treat what it's getting, ie
header(Content-Type: image/jpg);

Also, I bet it helps if you set $kepnev
_before_ you test whether it exists.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Timestamps operations

2001-08-24 Thread Hugh Bothwell


Alberto [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I have 2 timestamps like mktime(0,0,0,10,10,2001) and
 mktime(0,0,0,9,9,2001), I want to know how many days are from timestamp1
to
 timestamp2 or how many hours, or how many seconds, thnx

define(SECONDS_PER_DAY, 86400);
define(SECONDS_PER_HOUR, 3600);
define(SECONDS_PER_MINUTE, 60);

$seconds = abs($time2 - $time1);

$days = (int) ($seconds / SECONDS_PER_DAY);
$seconds -= $days * SECONDS_PER_DAY;

$hours = (int) ($seconds / SECONDS_PER_HOUR);
$seconds -= $hours * SECONDS_PER_HOUR;

$minutes = (int) ($seconds / SECONDS_PER_MINUTE);
$seconds -= $minutes * SECONDS_PER_MINUTE;


printf(Total time elapsed was %d d %d:%02d:%02d, $days, $hours, $minutes,
$seconds);



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: multiple select statement

2001-08-23 Thread Hugh Bothwell


Natasha [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 hi,

 i want to know how i can get all selected values of a multiple select
statement using $HTTP_POST_VARS

The name of your select must be an array, ie

select name='myvar[]' multiple
optionA
optionB
optionC
/select

If A and B are selected, you will get $myvar[0] = 'A' and $myvar[1] = 'B'
(for example).

The safe way to enumerate the values is with foreach, ie

foreach($myvar as $val) {
  // do something with $val
}

Hope this helps.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Dynamic check boxes...

2001-08-23 Thread Hugh Bothwell


Jeff Lewis [EMAIL PROTECTED] wrote in message
009201c12bff$de696af0$76a1a8c0@LEWISJCIT">news:009201c12bff$de696af0$76a1a8c0@LEWISJCIT...
 I have a form where users can enter a link
 (kind of a free for al links type of thing)
 When they add their site to the database
 a 0 is added to the approved field.

 When I load an admin script I can check
 all of the ones that have a 0 in that field.
 I want to have checkboxes form down the
 side of them so I can check the ones I want
 approved.

 Is it possible to have them all update with the
 click of one submit button?

There are two obvious approaches to this:

First, with JavaScript, you could write a
'select all' button, which checks all the checkboxes,
then submits the form normally.

Or, you could have a submission button
that tells PHP to approve all listed items
whether checked or not, ie

input type='submit' name='submit' value='Checked'
input type='submit' name='submit' value='All'


The problem with this is that unchecked checkboxes
simply don't appear when the form is submitted; you
need some way to get a full list of the IDs in question.


A quick fix I have found is as follows, for each option:

input type='hidden' name='cb307' value='No'
input type='checkbox' name='cb307' value='Yes'

NOTE: the name is NOT an array, and the hidden
field must come before the checkbox.
This way, if the checkbox is not checked, the 'No'
value comes through; otherwise it is over-written
by 'Yes'.


Another option would be to keep a comma-delimited
list of IDs and write 'em all into a single hidden
field, ie

input type='checkbox' name='cb305' value='Yes'
input type='checkbox' name='cb306' value='Yes'
input type='checkbox' name='cb307' value='Yes
input type='hidden' name='idlist' value='305,306,307'


Hope this helps...



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Need help to create HTML table with 2 columns.

2001-08-23 Thread Hugh Bothwell


John Bass [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi All,

 I am trying to generate a table with two columns.  Each column should
print
 2 fields named image_link and web_url.  Have spent over week looking
 documentations and trying different coding but nothing is working.  Any
help
 will be greatly appreciated.

The other answers are generally correct but a bit hard to follow.
Try this:

?php

// declare variables
$col = 0;
$numcols = 0;

// == fn startTable ===
function startTable($columns) {
global $col, $numcols;

// reset variables
$col = 0;
$numcols = (int) $columns;

// start table
echo \ntable;
}

// === fn addColumn ==
function addColumn($str) {
global $col, $numcols;

// first column? start row
if ($col == 0)
echo \n\ttr;

// echo cell contents
echo \n\t\ttd$str/td;

// last column? end row and reset
$col++;
if ($col == $numcols) {
echo \n\t/tr;
$col = 0;
}
}

//  fn endTable ===
function endTable() {
global $col, $numcols;

// pad the table as necessary
for ($i = $col; $i  $numcols; $i++)
addColumn('nbsp;');

// end table
echo \n/table;
}


// === MAIN =

mysql_connect(host, user, pwd)
or die(Error connecting: .mysql_error());

$query = SELECT image_link,web_url FROM testdata;
$result = mysql_db_query(db, $query)
or die(Error querying: .mysql_error());

startTable(2);
while ($row = mysql_fetch_array($result))
addColumn( $row[image_link].'br'.$row[web_url] );
endTable();
?

How's that?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: The future of PHP

2001-08-23 Thread Hugh Bothwell


Christopher Cm Allen [EMAIL PROTECTED] wrote in message
003201c12be2$f9309b00$[EMAIL PROTECTED]">news:003201c12be2$f9309b00$[EMAIL PROTECTED]...
 Greetings Php'ers:
 2 cents
 bahh to servelts-asp these are new kids on the block. Template this or
that,
 it doesnt matter, most templates are for lazy peeps anyways :)

Heck, I'm lazy; that's why I use PHP  ;-)
Like everything else, you use the tool for the job.

JSP has its good points, mainly for higher-end
applications.  If I need continuous communication
between client and server, I'll use it instead.

But for getting a simple page going,
PHP is quicker.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Please Help - getting a hightlight depending on selected page

2001-08-22 Thread Hugh Bothwell


Martin Hughes [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 OK here's the code in the page:

 !-- Start Navigation --
 div id=navbar
 table class=navtable width=160 cellpadding=4
 !-- Navigation Bar Heading --
 tr
  td class=navheadWelcome/td
 /tr
 trtd class=navtext id=sela href=Home/a/td/tr
 trtd class=navtexta href=Introduction/a/td/tr
 trtd class=navtexta href=Changes amp; Cuts/a/td/tr
 trtd class=navtexta href=Scores/a/td/tr
 trtd class=navtexta href=Orchestra/a/td/tr
 trtd class=navtexta href=Synthesizers/a/td/tr
 trtd class=navtexta href=Sound System/a/td/tr
 trtd class=navtexta href=Articles/a/td/tr
 trtd class=navtexta href=21st Century Les
 Miseacute;rables/a/td/tr
 trtd class=navtexta href=Information/a/td/tr
 trtd class=navtexta href=Discussion Forums/a/td/tr

 /table
 /div
 !-- End Navigation --


 I am using this 1 page as the php 'template' with content added depending
on
 the url. For example, to go to the synthesizers page the url is:
 index.php?sect=5id=0page=31

 where sect=5 is the part that sets the menu highlight (the menu is alway
the
 same, hard-coded into the page - all I want to do is change the css
id=sel
 from Home to Synthesizers.

div id=navbar
table class=navtable width=160 cellpadding=4
trtd class=navheadWelcome/td/tr

?php

$index = array(
Home,
Introduction,
Changes amp; Cuts,
Scores,
Orchestra,
Synthesizers,
Sound System,
Articles,
21st Century Les Miseacute;rables,
Information,
Discussion Forums
);

$items = count($index);
for($i = 0; $i  $items; $i++) {
echo \ntrtd class='navtext';

if ($sect == $i)
echo  id='sel';

echo a href='index.php?sect=$i'.$index[$i]./a;

echo /td/tr;
}
?

/table
/div




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




  1   2   >