RE: [PHP] Average of column...
if you do a $res = mysql_fetch_row($age_result) $res[0] will be the value of AVG(age). > -Original Message- > From: Jeff Lewis [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, July 10, 2001 5:27 PM > To: [EMAIL PROTECTED] > Subject: [PHP] Average of column... > > > I am trying to obtain the average age for a few teams in my database. > > Am using the below code: > > $age_result = mysql_query("select AVG(age) FROM bat_rost WHERE ownerID = > '$teamID'"); > while(($row = mysql_fetch_object($age_result))){ > $age=$row->age; > echo "Average age - ".$teamID.$age;} > > How can I get the average age from this? > > Jeff > > > -- > 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 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] Average of column...
hm, not too surprising, no colon delimiter... $age_result = mysql_query("select AVG(age) FROM bat_rost WHERE ownerID = '$teamID'"); $res = mysql_fetch_row($age_result); $age = $res[0]; echo "Average age - $teamID$age"; should work actually... btw, if teamID is numeric, you have to omit the ' thingys... > -Original Message- > From: Jeff Lewis [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, July 10, 2001 5:54 PM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: RE: [PHP] Average of column... > > > This doesn't work: > > $age_result = mysql_query("select AVG(age) as avgage FROM bat_rost WHERE > ownerID = '$teamID'"); > $row = mysql_fetch_object($age_result); > $age=$avgage; > echo "Average age - ".$teamID.$avgage; > > Neither does this: > > $age_result = mysql_query("select AVG(age) as avgage FROM bat_rost WHERE > ownerID = '$teamID'"); > $res = mysql_fetch_row($age_result) > $age=$res[0]; > echo "Average age - ".$teamID.$avgage; > > > > -Original Message- > > From: Remo Pini [mailto:[EMAIL PROTECTED]] > > Sent: Tuesday, July 10, 2001 11:41 AM > > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > > Subject: RE: [PHP] Average of column... > > > > > > if you do a > > > > $res = mysql_fetch_row($age_result) > > > > $res[0] will be the value of AVG(age). > > > > > > > -Original Message- > > > From: Jeff Lewis [mailto:[EMAIL PROTECTED]] > > > Sent: Tuesday, July 10, 2001 5:27 PM > > > To: [EMAIL PROTECTED] > > > Subject: [PHP] Average of column... > > > > > > > > > I am trying to obtain the average age for a few teams in my database. > > > > > > Am using the below code: > > > > > > $age_result = mysql_query("select AVG(age) FROM bat_rost > WHERE ownerID = > > > '$teamID'"); > > > while(($row = mysql_fetch_object($age_result))){ > > > $age=$row->age; > > > echo "Average age - ".$teamID.$age;} > > > > > > How can I get the average age from this? > > > > > > Jeff > > > > > > > > > -- > > > 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 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 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] How to select a line from a web page source?
The simplest way I could think of would be to use a regex: /^(.*Jim.*)$/g (g=global) and then using $1 (the content of the parenthesis), this would give you the whole line containing "Jim". Greets, remo ps: is perl syntax, needs to be adjusted for php... > Hi there: > > I wanna select a line from a table which is in a php page resulted of a > mysql_query > > So far what i have is a way to search the text from only line and > then limit > the characters in substr ( ) > Thats a really wierd way to do it, i think, and my problem its the page im > trying to do its a template wich gives me a difentent line depending of > $user i choose. > > The code i have so far its this: > > $filename = "http://localhost/all.php";; > > $fcontents = join('', file ($filename)); > > $first = strstr ($fcontents, $user); > > $rest = substr ($first, 0, 108); > > wich works for example if $user = guessit , but if I use $user = > Jim doenst > work anymore cause "jim" its a word smaller than "guessit", and the limit > 108 will give in that case characters of next line > > heres part of the source of the page where im trying to grab lines : > > cow154 align=center>2377 > mer244 align=center>044 > luis340 align=center>040 > Flix438 align=center>745 > Rulerman535 align=center>035 > Jim635 align=center>1348 > guessit735 align=center>2459 > womo834 align=center>2357 > jay94 align=center>48 > > > As u can see, "guessit" line is 4 characters longer than "jim" and the 108 > limit wil give me in case of jim line 4 chars of next line. > -- 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] array from mysql help?
To be destructive, I would use a sensible data-representation in mysql, yours seems to suck... something like table x idx as integer, auto_increment, primary key node as text parent as int (this points to the parent primary key) But here is what I would do with the current data structure (recursive stuff): get all nodes of the current level (starting with 1): select distinct parent_cat from where level = this gives you all nodes... now with each node do: select child_cat from where level = and parent_cat = this gives you all children... then increase the level and redo from start... it is possible to wrap all that up in a query, but the handling would be much worse and since neither the amount of levels nor the uniqueness of the nodenames is given, that could turn out to be rather nasty. hope this helps a little... remo > I want to create an array like this: > > $tree = array ( > "first" => array ("stuff1", "stuff2", "stuff3"), > "second" => array ("stuff1", "stuff2") > ); > > > based on tree of information, stored in a database table: > > level parent_cat child_cat > -- > 1 first first > 1 second second > 2 first stuff1 > 2 first stuff2 > 2 first stuff3 > 2 second stuff1 > 2 second stuff2 > > > That translates to a structure like this: > > > firstsecond >| | > |-|||---| > stuff1 stuff2stuff3 stuff1 stuff2 > > > Can someone point me towards an SQL example that would help me > structure the > query, and an example of how to reference information in it once > I have it? > e.g. a while list/each but for a multidimensional 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]
RE: [PHP] Need some help with this idea!
select * from whatnot order by timestampcolumn desc limit 1 if the "limit 1" doesn't work with your db, just fetch the first result only... greets, remo > -Original Message- > From: Chris Cocuzzo [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, July 24, 2001 8:28 AM > To: [EMAIL PROTECTED] > Subject: [PHP] Need some help with this idea! > > > hey- > > I want to select the oldest show from a database to display on my > main page, > since the oldest show is also the show happening closest to any current > time(if that makes sense...). I included a timestamp field in my table of > shows in anticipation of checking that to find out what was the oldest. > however, I'm wondering how I should go about doing that exactly. > my idea was > the scan through just that column of timestamps, find the lowest one, and > then make a selection from the db based on the timestamp. Can any give me > some examples of code to scan through a column like i mentioned, > or give me > better ideas on how to do this?? > > thanks > chris > > > -- > 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 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] indexing files
hi i'm trying to index several files (ms office, pdf, txt, html) using php and LINUX, are any suggestions and/or libraries for that around? greets, remo Remo Pini Pini Computer Trading http://www.pct.ch Tel: +41 1 822 1000 Fax: +41 1 882 4000 Mob: +41 79 216 1551 -- 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] Insecurity with PHP authorization
Or you could tell your webserver to deny everything except access to redirect.php, this saves you from moving everything to some obscure place... > -Original Message- > From: Michael Mehlmann [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, August 07, 2001 10:18 AM > To: Stefen Lars > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP] Insecurity with PHP authorization > > > If you don't have a very high load, then you could move all not-php-files > out of htdocs-root and use a pseudo-root directory > htdocs/../rawfiles as root > for redirect.php. > For example image.jpg is placed in htdocs/../rawfiles/images then > access it > with /redirect.php?/images/image.jpg ! > redirect.php only checks for authorization and then does a fpassthru! > that won't cost much! > > hth > Michael > > > Hello all > > > > I have just implemented a mySQL authorization: each html and php page > > checks > > to see whether a user is logged in by checking a cookie in the user > > browser. > > The user can log out and edit her profile (including password). > If a page > > is > > called without the user being logged in, he is presented with a log in > > form. > > This works very well. There is an SSL connection to the server. Only a > > hash > > value of the password is stored in the database. > > > > However, if I directly request a graphic (or a ZIP file etc) from the > > site, > > by entering: > > https://www.myserver.com/photo.jpg for example, I can download > that file > > without being logged in (naturally). > > > > In the particular *intranet* project that I am working on, this is > > particularly undesirable, as only personnel at the company’s four > > locations > > may have access to the intranet. And there certainly will be a lot of > > ‘confidential’ ZIP and graphic files placed on the server. > > > > I do realize that if I were to place a .htaccess file in the > root of the > > intranet server, I could prevent the above from happening, but then I > > loose > > the advantage of having the users profile in a database, where > a user can > > easily change her password. Allowing a web user to edit a > password in the > > .htaccess file poses more problems than it solves, especially as it > > certainly could occur that more than one persons wants to edit his > > password > > simultaneously. > > > > Could anyone suggest a method to allow a user to easily edit > his password, > > > > but at the same time, not allow direct access to specific > non-PHP files on > > > > the intranet server? > > > > Perhaps one method would be to restrict access to the > company’s four > > gateway > > servers (IP addresses). However, I feel this is not to secure, and these > > IPs > > could be spoofed (and this does not really solve the problem). > > > > Any enlightenment on this subject would be well received. > > > > TIA > > > > S. > > > > > > _ > > Get your FREE download of MSN Explorer at > http://explorer.msn.com/intl.asp > > > > > > -- > > 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] > > > > -- > Aufgepasst - jetzt viele 1&1 New WebHosting Pakete ohne > Einrichtungsgebuehr + 1 Monat Grundgebuehrbefreiung! > http://puretec.de/index.html?ac=OM.PU.PU003K00736T0492a > > > -- > 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 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]