Re: [PHP-DB] PHP/Mysql Script help.

2003-06-05 Thread heilo
hi!

wow - cool code! it is very well structured i think (i like it ;-)! i just
would change 2 little details (thats only what i'd do):

if($id) is not enough for me - first of all i want that it can only be
transportet by GET. secondly i do not want people trying to hack my
mysql-server with some ugly url-hacking. so i test if it is a numeric input.
third it is possible that people may bookmark some ids to access them
directly so i would include a test if the requested id exists or not:

if(isset($_GET['id'])  is_numeric($_GET['id'])
{
$qry = 'SELECT `id` FROM `nuke_race` WHERE `id`='.$id;
$res = mysql_query($qry, $con);
if(mysql_num_rows($res)==0)
echo 'Sorry, this entry has been deleted or was never
created!'.\n;
else
// show entry
}

next - but this is really a small thing - i'd not make a long list of
options i'd create a for-loop like this:

echo 'select name=select size=1'.\n;
for($i = 65; $i = 90; $i++)
echo 'option 
value='.strtolower(chr($i)).''.chr($i).'/option'.\n;
echo '/select'.\n;

oh! i just saw that you use POST anyways. ;) also a possibility (but this
avoids the entries from being bookmarked).

keep phping!

.ma

Fulco of Scarborough [EMAIL PROTECTED] [EMAIL PROTECTED] 0:04 Uhr:

 Greeting everyone, my name is Jason and I am sorry for bugging you since you
 probably get a ton of these emails, but I was hoping you all might be able
 to help me.  I am attempting to design a script that presents the user with
 a form with 26 letters to choose from.  When they pick a letter I want it to
 take them to a list of all the entries in my database that begin with the
 letter they selected in link form.  When they click on the term, I want it
 to pull up the info for that entry.
 
 I am only wanting to get some tips or a sample somewhere you may know of to
 get me going in the right direction.
 
 
 
 Here is my current code so far:
 
 
 
 ?php
 
 require(racesetup.php);
 
 $con = mysql_connect($host, $user, $pass);
 
 
 
 mysql_select_db($db, $con);
 
 
 
 // display individual record
 
 
 
 if ($id) {
 
 
 
  $result = mysql_query(SELECT * FROM nuke_race WHERE id=$id,$con);
 
 
 
  $myrow = mysql_fetch_array($result);
 
 
 
  printf(bRace:/b %s\nbr, $myrow[race]);
 
 echo br; 
 
  printf(bDescription:/b %s\nbr, $myrow[racetxt]);
 
 echo br;
 
 echo brh3a href=\javascript:history.go(-1)\Back/a/h3;
 
 
 
 
 } else {
 
 echo form name=letter method=\post\
 action=\http://st.fulco.net/races.php\;
 
 pPick a letter to begin your search/p
 
 p 
 
   select name=\select\
 
 option value=\a\A/option
 
 option value=\b\B/option
 
 option value=\c\C/option
 
 option value=\d\D/option
 
 option value=\e\E/option
 
 option value=\f\F/option
 
 option value=\g\G/option
 
 option value=\h\H/option
 
 option value=\i\I/option
 
 option value=\j\J/option
 
 option value=\k\K/option
 
 option value=\L\L/option
 
 option value=\m\M/option
 
 option value=\n\N/option
 
 option value=\o\O/option
 
 option value=\p\P/option
 
 option value=\q\Q/option
 
 option value=\r\R/option
 
 option value=\s\S/option
 
 option value=\t\T/option
 
 option value=\u\U/option
 
 option value=\v\V/option
 
 option value=\w\W/option
 
 option value=\x\X/option
 
 option value=\y\Y/option
 
 option value=\z\Z/option
 
   /select
 
 /p
 
 p
 
   input type=\Submit\ name=\letter\ value=\Enter information\
 
 /p
 
 /form
 
 ;  
 
 } else {
 
 
 
 $result = mysql_query(SELECT * FROM nuke_race WHERE race LIKE
 '$letter%',$con);
 
   if ($myrow = mysql_fetch_array($result)) {
 
 
 
 // display list if there are records to display
 
 
 
 do {
 
 
 
   printf(a href=\%s?id=%s\%s/abr\n, $PHP_SELF, $myrow[id],
 $myrow[race]);
 
 
 
 } while ($myrow = mysql_fetch_array($result));
 
 
 
   } else {
 
 
 
 // no records to display
 
 
 
 echo Sorry, no records were found!;
 
   }
 
 
 
 }
 
 ?
 
 
 
 Thanks for your help in advance.
 
 
 
 Yours in Service,
 
 Jason Britton
 
 Scar's http://st.fulco.net/  Legion
 
 http://st.fulco.net http://st.fulco.net/
 
 [EMAIL PROTECTED]
 
 
 
 Vincit imitationem veritas.
 
 
 



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



Re: [PHP-DB] PHP sort from .... best solution?

2003-06-05 Thread heilo
hi

the easier way is as Mike Ford did it very elegantly with this structur:

   function obj_date_compare($a, $b) {
  return strcmp($a-publisertLang, $b-publisertLang);
   }

   ...

   if($ingresser = array_merge($i1 ,$i2))
   {
  $ingresser = usort($ingresser, 'obj_date_compare');
  listIngresser($ingresser);
   }

the for-structure from your admin guy is also a possibility, but i think php
offers cool sort-functions like this usort-function (which was also new to
me - [EMAIL PROTECTED]). so it is not necessary to write your own sorting-algorithm.

.ma

A. Lyse [EMAIL PROTECTED] [EMAIL PROTECTED] 13:40 Uhr:

 Hi again!
 
 I talked to the admin guy and he said there is an easyer way to do this (as
 usual he doenst have the time to show me) so I try here:
 
 He gave me a liddle example in c and a light translation to PHP:
 
 Bubble sort  (exampel written in c, but can easyly be translated to php):
 for (i=0; in-1; i++) {
 for (j=0; jn-1-i; j++)
   if (a[j+1]  a[j]) {  /* compare the two neighbors */
 tmp = a[j]; /* swap a[j] and a[j+1]  */
 a[j] = a[j+1];
 a[j+1] = tmp;
 }
 }
 
 **
 
 More example of Bubble Sort:
 http://www.cs.ust.hk/faculty/tcpong/cs102/summer96/aids/bubble.html
 
 The if-sentense must here be written to
 if($a[$j+1]-publisertLang  $a[$j]-publisertLang)
 where a is $ingresser and $n is the number of elements in $ingresser.
 
 I
 
 The if sentese is going in the php file pastet yesterday.
 
 Not that yeasterdays metod did'nt work, but if somebody has an idea on this
 one and can give me a full example based on the info i've pastet yesterday
 it would be great!
 
 Regards,
 A. Lyse
 
 


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



Re: [PHP-DB] session

2003-06-05 Thread heilo
hi!

well - this is not really a DB-question. and if you take a look at the
php-docu at http://www.php.net/manual/en/language.variables.predefined.php
you'd see that you can access and alter them with $_SESSION or
$HTTP_SESSION_VARS (older versions of php).

.ma

[EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] 3:34 Uhr:

 Hi all,
 I had create a session and stored some value into session.
 ?php
 session();
 session_register(id 123,name leooi);
 ?
 How can i retrieved the value???
 
 TQ
 
 Leooi
 
 
 http://www.incredimail.com/redir.asp?ad_id=309amp;lang=9   IncrediMail -
 Email has finally evolved - Click Here
 http://www.incredimail.com/redir.asp?ad_id=309amp;lang=9 


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



Re: [PHP-DB] PHP sort from a database variable..?

2003-06-04 Thread heilo
hi!

we need information about how the array looks like!

please add the following to your script (after merging $i1 and $i2):

echo 'pre';
print_r($ingresser);
echo '/pre';

and send the resulting output!
you can use array_multisort for this problem. anyways i propose to write
your own news-tool. sorting is really easy if you use SQL - if you cant code
one yourselve i would ask the programmer of this newsmodule to add a
sort-parameter to his functions.

.ma


A. Lyse [EMAIL PROTECTED] [EMAIL PROTECTED] 23:23 Uhr:

 Please dont kill me for posting here. I dont know where else to post. I'm a
 newbie and is completly stuck with a php problem :(
 
 I got this code (among with more though...):
 
 ***
 $i1=hentIngresser($nettstedid,38,$sprakid,$offsetannet,$antallmotor);
 $i2=hentIngresser($nettstedid,39,$sprakid,$offsetannet,$antallmotor);
 
 
 if($ingresser = array_merge($i1 ,$i2))
 listIngresser($ingresser);
 
 
 else
 echo 'Det oppstod en feil ved henting av ingresser.';
 **
 
 This code produce the article feeds on this site:
 http://www.amotor.no/artikler.php
 
 The articles are feeded from $i1 and $i2, but as you can see on the dates
 the newest article does not come first (the code first lists the $i1 THEN
 $i2) but what I want is to get the newest on date first, then older and
 older.
 
 I talked to the owner of the script and he said that he had a variable named
 $publisertLang; //Publish date of the article in  format: mmddhhmmss
 He said I could sort the $ingresser (the merged $i1 and $i2) with the
 $publisertLand as parameter on listIngresser, but the problem I dont know
 how to do that. I've looked through php.net and tryed all sort commands I've
 found.
 
 Can somebody please help me?
 
 P.S Excuse my bad English. It's not my native language.
 
 Regards,
 A. Lyse
 



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



Re: [PHP-DB] PHP sort from a database variable..?

2003-06-04 Thread heilo
sorry, needed some time to hack this one ::)

as your print_r shows that you have to sort an array which includes objects
(in this case an ingress-class - whatever this is). i tried to simulate your
environement and endet up with this:

function array2IngressClass($array)
{
$inst = new ingress();
while(list($key, $val) = each($array))
$inst-$key = $val;
return $inst;
}

function class2Arr($class)
{
return (array)$class;
}

function sortClassArray($array)
{
$arr = array();
$sArr = array();
foreach($array as $ent)
{
$arr[] = class2Arr($ent);
$sArr[] = $ent-publisertLang;
}

array_multisort($arr, SORT_DESC, $sArr);

$cM = count($arr);
for($c = 0; $c  $cM; $c++)
$arr[$c] = array2IngressClass($arr[$c]);

return $arr;
}

/***/

$i1 = hentIngresser($nettstedid,38,$sprakid,$offsetannet,$antallmotor);
$i2 = hentIngresser($nettstedid,39,$sprakid,$offsetannet,$antallmotor);


if($ingresser = array_merge($i1 ,$i2))
{
$ingresser = sortClassArray($ingresser);
listIngresser($ingresser);
}
else
echo 'Det oppstod en feil ved henting av ingresser.';

/***/

does this work? if not which errors occour??

.ma


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



Re: [PHP-DB] PHP sort from a database variable..?

2003-06-04 Thread heilo
did you also copy the functions?

A. Lyse [EMAIL PROTECTED] [EMAIL PROTECTED] 0:40 Uhr:

 I get this error:
 
 Fatal error: Call to undefined function: sortclassarray() in
 /home/amotor/www/list_ingresser_artikler.php on line 25
 
 Regards,
 A. Lyse
 



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



Re: [PHP-DB] PHP sort from a database variable..?

2003-06-04 Thread heilo
ok, add the following lines to your ingress.lib-file:

/***/
// converts any array to an instance of the ingress-class
function array2IngressClass($array)
{
$inst = new ingress();
while(list($key, $val) = each($array))
$inst-$key = $val;
return $inst;
}

// converts any class into an array
function class2Arr($class)
{
return (array)$class;
}

// sorts arrays comeing from hentIngresser() descending
function sortClassArray($array)
{
$arr = array();
$sArr = array();
foreach($array as $ent)
{
$arr[] = class2Arr($ent);
$sArr[] = $ent-publisertLang;
}

array_multisort($arr, SORT_DESC, $sArr);

$cM = count($arr);
for($c = 0; $c  $cM; $c++)
$arr[$c] = array2IngressClass($arr[$c]);

return $arr;
}


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



Re: [PHP-DB] PHP sort from a database variable..?

2003-06-04 Thread heilo
i think this one should now work.

remember that this is no very proper solution! it would be better not to
work with such functions and access the database directly i think.

.ma 

?php
include pubSysDB.lib;

//Klasse som henter ut all relevant informasjon om en ingress og presenterer det som 
et oversiktlig objekt. Sparer brukeren for mye logikk og spørringer.
//Denne er ikke optimalisert ennå.
class Ingress{

var $gyldig;//1 hvis dette er en konsistent ingress, 0 hvis 
det er prolemer som gjør at ingressen ikke kan vises.
var $feil;  //Dersom gyldig er 0 finnes feilmeldingene her, 
separert med ;

var $artikkelid;//ID til den artikkelen som ingressen er ingress for
var $nettstedid;//ID til dette nettstedet
var $artikkellink;  //Link til selve artikkelen
var $overskrift;//Overskriften i ingressen
var $forfatternavn; //Navn på forfatteren
var $forfatterlink; //Link til side med info om forfatteren
var $ingress;   //Selve teksten i ingressen
var $publisert; //Dato da artikkelen ble publisert
var $publisertLang; //Dato da artikkelen ble publisert, på format 
mmddhhmmss
var $bilde; //URL til ingress-bildet

function Ingress($artikkelid,$nettstedid){
$this-artikkelid = $artikkelid;
$this-nettstedid = $nettstedid;
$db = new pubSysDB();
/* Kommenterte ut dette, bevart intakt. Eneste forskjellen er at man MÅ sjekke om 
artikkelen er publisert eller ikke! --
$db-query(SELECT i.overskrift, i.ingress, i.publisert, i.bilde, 
b.fornavn, b.etternavn, a.artikkeltypeid
FROM Ingress i ,Artikkel a, Bruker b, Artikkeltype t
WHERE i.artikkelid=$this-artikkelid
AND i.nettstedid=$this-nettstedid
AND i.artikkelid=a.artikkelid
AND i.nettstedid=a.nettstedid
AND a.forfatterid = b.brukerid
AND a.artikkeltypeid = t.artikkeltypeid
LIMIT 1);
---*/
$db-query(SELECT i.overskrift, i.ingress, i.publisert, i.bilde, 
b.fornavn, b.etternavn, a.artikkeltypeid, DATE_FORMAT(i.publisert,'%Y%m%d%H%i%S') 
publisertLang
FROM Ingress i ,Artikkel a, Bruker b, Artikkeltype t
WHERE i.artikkelid=$this-artikkelid
AND i.nettstedid=$this-nettstedid
AND i.artikkelid=a.artikkelid
AND i.nettstedid=a.nettstedid
AND a.forfatterid = b.brukerid
AND a.artikkeltypeid = t.artikkeltypeid
AND i.publisert IS NOT NULL
LIMIT 1);
if($db-num()){
$row = $db-fetch();
$this-gyldig=1;
$this-overskrift = $row-overskrift;
$this-artikkellink = art.php?artikkelid=.$this-artikkelid;
$this-forfatternavn = $row-fornavn. .$row-etternavn;
$this-forfatterlink = http://www.ikke.no/;;
$this-ingress = $row-ingress;
$publisert = explode(' ',$row-publisert);
$publisert = explode('-',$publisert[0]);
$this-publisertLang = $row-publisertLang;
$this-publisert = $publisert[0].' 
'.$publisert[2].'/'.$publisert[1];
$this-bilde = $row-bilde;
$this-artikkeltypeid = $row-artikkeltypeid;
}else{
$this-gyldig=0;
$this-feil .= Ingressen finnes ikke idatabasen;;
}
}
}

//Returnerer et array med de siste $antall artikler fra og med $offset fra 
$nettstedid, sortert med den nyeste først.
//(Offset er med for at man lett skal kunne lage neste 50 / forrige 50 linker i 
fremvisningen.
//
//INN - nettstedid til nettstedet man vil liste ingresser til, hvilket språk man vil 
ha ingresser pÃ, antall ingresser man vil hente, og offset i disse
//UT - 0 hvis problem oppstod, array med Ingressobjekter hvis alt gikk i orden
function hentIngresser($nettstedid,$typeid,$sprakid,$offset,$antall){
$arr = Array();
$db = new pubSysDB();
if($typeid==0)
$db-query(SELECT artikkelid FROM Ingress WHERE 
nettstedid=$nettstedid AND sprakid=$sprakid ORDER BY publisert DESC LIMIT 
$offset,$antall);
else
$db-query(SELECT i.artikkelid FROM Ingress i, Artikkel a WHERE 
i.artikkelid = a.artikkelid AND a.artikkeltypeid=$typeid AND i.nettstedid=$nettstedid 
AND i.sprakid=$sprakid ORDER BY i.publisert DESC LIMIT 

Re: [PHP-DB] PHP sort from .... best solution?

2003-06-04 Thread heilo
no prob

i think its not the best solution, because its a workaround the
core-problem.
as i said it would be better to access the data directly and without any
functions or complicated classes. this structure is for very complex systems
whose code may change very often. so the highest standard of scaleability is
needed and the code must be very modular. in this case (its only a
news-module) you do not need such a professional and therefore complicated
structure. it is enough to formulate a  simple query and give the news out
with a while-loop.

maybe this is only my personal opinion. i do not want to critisize your code
- but adding this workaround crushes the whole modularity because it is very
specialized on your environement. may be this produces headache if you want
to update your code later on? (this is something that happens to me all the
time with code which is veeery old comeing from times where i didn't thought
of the future :)

well - it works - what more?

.ma 

A. Lyse [EMAIL PROTECTED] [EMAIL PROTECTED] 1:16 Uhr:

 It worked. Thanx!
 
 Why is this a bad solution? Will it slow down the feed?
 
 Regards,
 A. Lyse
 
 


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



Re: [PHP-DB] PHP sort from a database variable..?

2003-06-04 Thread heilo
wow!

thats a much more elegant way to solve this sorting problem!
didn't know usort up to now!

simplebeautiful !! :)

.ma

Ford, Mike   [LSS] [EMAIL PROTECTED] [EMAIL PROTECTED] 11:18
Uhr:

 -Original Message-
 From: heilo [mailto:[EMAIL PROTECTED]
 Sent: 03 June 2003 23:35
 
 sorry, needed some time to hack this one ::)
 
 as your print_r shows that you have to sort an array which
 includes objects
 (in this case an ingress-class - whatever this is). i tried
 to simulate your
 environement and endet up with this:
 
 This looks a bit like a sledgehammer to crack a nut -- why not just use
 usort, like this:
 
  function obj_date_compare($a, $b) {
 return strcmp($a-publisertLang, $b-publisertLang);
  }
 
  ...
 
  if($ingresser = array_merge($i1 ,$i2))
  {
 $ingresser = usort($ingresser, 'obj_date_compare');
 listIngresser($ingresser);
  }
 
 Cheers!
 
 Mike
 
 -
 Mike Ford,  Electronic Information Services Adviser,
 Learning Support Services, Learning  Information Services,
 JG125, James Graham Building, Leeds Metropolitan University,
 Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
 Email: [EMAIL PROTECTED]
 Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


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



Re: [PHP-DB] Dealing with ENUM fields

2003-06-02 Thread heilo
Hi!

there is a much shorter way to do this (which works with ENUM and SET):


$qry = 'SHOW COLUMNS FROM `gruzilla_content` LIKE module';
$res = mysql_query($qry);
if(mysql_num_rows($res)0)
{
$row = mysql_fetch_row($res);
$pattern = #(enum|set)\('(.+?)'\)#i;
$replace = '\\2';
$row[1] = preg_replace($pattern, $replace, $row[1]);
$options = explode(',', $row[1]);
}

$options now contains every value of the enum. I think there is also a
possibility to do this within a query - but currently i do not find the
script on my HD :) - so this is a nice workaround!

.ma


Lisi [EMAIL PROTECTED] [EMAIL PROTECTED] 11:53 Uhr:

 I am forwarding this useful function someone once sent to the list that I
 use often.
 
 Hope this fits your needs.
 
 -Lisi
 
 
 -Original Message-
 From: Russ [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, June 26, 2002 7:47 PM
 To: NIPP, SCOTT V (SBCSI); [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] Populating a dropdown list with ENUM values...
 
 
 G'day Scott:
 
 I wrote this function to do just what you're atfer:
 You may need to mess with it for you're own needs - but go for your
 life!
 
 //function: enum_select() - automatically generate an HTML select
 menu from a MySQL ENUM field
 //1). takes a table name: '$table'
 //2). a name for the menu '$name'
 //3). a CSS class
 function enum_select($table,$name,$class) {
 $sql = SHOW COLUMNS FROM $table;
 $result = mysql_query($sql);
 $select = select name=\$name\ class=\$class\\n\t;
 while($myrow = mysql_fetch_row($result)){
   $enum_field = substr($myrow[1],0,4);
   if($enum_field == enum){
global $enum_field;
$enums = substr($myrow[1],5,-1);
$enums = ereg_replace(',,$enums);
$enums = explode(,,$enums);
foreach($enums as $val) {
 $select .= option
 value=\$val\$val/option\n\t;
 }//end foreach
 }//end if
 }//end while
 $select .= \r/select;
 return $select;
 }//end function
 
 
 All the best.
 Russ
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

Matthias Steinböck
Email: [EMAIL PROTECTED]
Web: http://www.abendstille.at

Frühabendliches Webdesign.
--
Im Übrigen sind wir der Meinung, dass
unsere Gesellschaft Gabel-diskriminierend
Löffel verwendet. Alle Macht den Gabeln!


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



Re: [PHP-DB] Dealing with ENUM fields

2003-06-02 Thread heilo
hi!

i think it would be better to make a second table because then you do not
need any of those scripts and just can use a JOIN. anyways it is better for
the database-management to make it as module as possible and saving those 4
values (which do not change?) in a enum-field - i do not know. If you really
do not want to create a second table i would suppose not to use ENUM but SET
as it provides multiple choice for each row (in your case you just could use
every value). if i understood your problem right - why not just create 4
additional columns which do not really change?

.ma


Lisi [EMAIL PROTECTED] [EMAIL PROTECTED] 12:40 Uhr:

 What's the application? What are the issues with using ENUM verses
 something else?
 
 -Lisi
 
 At 05:32 AM 6/2/03 -0400, Becoming Digital wrote:
 Thanks to both Heilo and Lisi.  These scripts should make things easier.
 
 Is it safe to assume that we are in agreement about the use of an ENUM
 field for
 this application?
 
 Edward Dudlik
 Becoming Digital
 www.becomingdigital.com
 
 
 - Original Message -
 From: heilo [EMAIL PROTECTED]
 To: PHP-DB [EMAIL PROTECTED]
 Sent: Monday, 02 June, 2003 05:11
 Subject: Re: [PHP-DB] Dealing with ENUM fields
 
 
 Hi!
 
 there is a much shorter way to do this (which works with ENUM and SET):
 
 
 $qry = 'SHOW COLUMNS FROM `gruzilla_content` LIKE module';
 $res = mysql_query($qry);
 if(mysql_num_rows($res)0)
 {
 $row = mysql_fetch_row($res);
 $pattern = #(enum|set)\('(.+?)'\)#i;
 $replace = '\\2';
 $row[1] = preg_replace($pattern, $replace, $row[1]);
 $options = explode(',', $row[1]);
 }
 
 $options now contains every value of the enum. I think there is also a
 possibility to do this within a query - but currently i do not find the
 script on my HD :) - so this is a nice workaround!
 
 .ma
 
 
 Lisi [EMAIL PROTECTED] [EMAIL PROTECTED] 11:53 Uhr:
 
 I am forwarding this useful function someone once sent to the list that I
 use often.
 
 Hope this fits your needs.
 
 -Lisi
 
 
 -Original Message-
 From: Russ [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, June 26, 2002 7:47 PM
 To: NIPP, SCOTT V (SBCSI); [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] Populating a dropdown list with ENUM values...
 
 
 G'day Scott:
 
 I wrote this function to do just what you're atfer:
 You may need to mess with it for you're own needs - but go for your
 life!
 
 //function: enum_select() - automatically generate an HTML select
 menu from a MySQL ENUM field
 //1). takes a table name: '$table'
 //2). a name for the menu '$name'
 //3). a CSS class
 function enum_select($table,$name,$class) {
 $sql = SHOW COLUMNS FROM $table;
 $result = mysql_query($sql);
 $select = select name=\$name\ class=\$class\\n\t;
 while($myrow = mysql_fetch_row($result)){
   $enum_field = substr($myrow[1],0,4);
   if($enum_field == enum){
global $enum_field;
$enums = substr($myrow[1],5,-1);
$enums = ereg_replace(',,$enums);
$enums = explode(,,$enums);
foreach($enums as $val) {
 $select .= option
 value=\$val\$val/option\n\t;
 }//end foreach
 }//end if
 }//end while
 $select .= \r/select;
 return $select;
 }//end function
 
 
 All the best.
 Russ
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 Matthias Steinböck
 Email: [EMAIL PROTECTED]
 Web: http://www.abendstille.at
 
 Frühabendliches Webdesign.
 --
 Im Übrigen sind wir der Meinung, dass
 unsere Gesellschaft Gabel-diskriminierend
 Löffel verwendet. Alle Macht den Gabeln!
 
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

Matthias Steinböck
Email: [EMAIL PROTECTED]
Web: http://www.abendstille.at

Frühabendliches Webdesign.
--
Im Übrigen sind wir der Meinung, dass
Sofas neben Trinkautomaten zu den
Bedrohten Tierarten in Gymnasien
Zählen. Wir fordern mehr Sofas!!


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



Re: [PHP-DB] Help with a query please

2003-03-24 Thread heilo
Hi!

I hope, I understood you right: You want to delete a user completely from
your database?
If yes, you can just do it step by step (I hope the last step - putting all
the queries together works):

$uid = 1;

$qry = 'SELECT `Allocation_ID` FROM `WMS_Allocations` WHERE
`User_ID`='.$uid;
$ent = mysql_fetch_array(mysql_query($qry));

$del_qry1 = 'DELETE FROM `WMS_Allocations` WHERE `User_ID`='.$uid;
$del_qry2 = 'DELETE FROM `WMS_Bookings` WHERE
`Allocation_ID`='.$ent['Allocation_ID'];
$del_qry3 = 'DELETE FROM `WMS_User` WHERE `User_ID`='.$uid;

$del_qry = $del_qry1.;\n.$del_qry2.;\n.$del_qry3.;\n;

mysql_query($del_qry);


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



[PHP-DB] Oracle 8?

2003-03-13 Thread heilo
Hi there everybody!

I'm running Win2000 an Oracle 8 server and PHP. Now - just a simple
question: does anybody know any good FAQs or resources/references for
specally this topic??

Thx a lot - .ma


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



Re: [PHP-DB] Playing mp3s using flash and php

2003-03-06 Thread heilo
Hi!

I am currently working on a shop system, which works with flashmx and php
and uses a mysql-database to read the path of the protected mp3s and so the
mp3s are passed to the flashmovie through php using the file-functions. The
shop also reads out the directories and parses the xml-output of the
php-file so that one can choose the files in the flash-movie. I think with a
little work and user-distinguishing it would be possible to create private
playlists.

You can see the shop on http://www.help-music.at/cms_global.php?id=18 (but
its not finished yet...) If you are interested in the fla mail me under
[EMAIL PROTECTED]

- matthias steinböck

James Riley [EMAIL PROTECTED] [EMAIL PROTECTED] 13:45 Uhr:

 Hi there,
 
 Im currently working on a teaching system for the Uni of Vienna. I have a
 problem though. We have over 2000 sound files (mp3s) of phrases and words.
 But students are having problems playing them because of different
 configuration setups.
 
 At the moment they need flash for certain tasks, so it would make sense to
 play the sound through a small flash movie - as they will have the plug-in-
 I am working with Flash MX, but I cant seem to get a movie to get the
 address of the mp3 from the database, and then play it.
 
 It would be perfect if I had a solution of 1 Flash movie/PHP script which
 can pull in the sound link and play the file. This same movie would be
 used throughout the site.
 
 Any help would be brilliant
 
 Thanks a lot
 
 James Riley
 
 


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



Re: [PHP-DB] .htaccess

2003-02-16 Thread heilo
Hi!

Normally one would read that folder with read() and echo all the files
makeing hrefs like this:

$dir = open('/home/username/public_ftp/incoming/');
while($file = $dir-read())
echo 'a href='.$file.''.$file.'/abr'.\n;

Don't forget to make sure, that the path is ok within the href...

- .ma

Matt [EMAIL PROTECTED] [EMAIL PROTECTED] 17:30 Uhr:

 Hey, this isn't totally a php question, but I would appreciate if anyone has
 any advice for me.
 
 I have a php script that accesses a folder, and displays all the photos
 inside the folder. I want to use this script to display images that people
 upload from the anonymous ftp account. I know that when they upload a photo,
 it goes into the:
 
 /home/username/public_ftp/incoming/ folder
 
 Is there a way to access the photos in that folder and display them in
 internet explorer. Someone mentioned using the .htaccess file and adding a
 line to create an alias for the folder.  Can anyone help me out with this?
 What directory does the .htaccess file have to be in, what do I type in to
 create the alias for the folder, etc  Thanks guys.
 
 Matt
 
 


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




[PHP-DB] BLOB

2003-01-27 Thread heilo
Hi everybody out there!

Does anybody know a good reference, where I can lern how to insert binary
data (e.g. Images) into a BLOB-Field of a MySQL-Database?

Any help would be warmely appreciated

- Matthias St.



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




[PHP-DB] BLOB

2003-01-27 Thread heilo
Hi everybody out there!

Does anybody know a good reference, where I can lern how to insert binary
data (e.g. Images) into a BLOB-Field of a MySQL-Database?

Any help would be warmely appreciated

- Matthias St.



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




Re: [PHP-DB] BLOB

2003-01-27 Thread heilo
Thxalot!

I didn't thought it would be that easy *g*


- matthias st.


John W. Holmes [EMAIL PROTECTED] [EMAIL PROTECTED] 14:12 Uhr:

 Does anybody know a good reference, where I can lern how to insert
 binary
 data (e.g. Images) into a BLOB-Field of a MySQL-Database?
 
 Use fopen() to open the image, fread() it into a variable, and insert
 that variable like you would any other one. If the image is coming from
 an input type=file element, then you already have the image data
 present in the $_FILES array that you can insert.
 
 ---John W. Holmes...
 
 PHP Architect - A monthly magazine for PHP Professionals. Get your copy
 today. http://www.phparch.com/
 
 



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




Re: [PHP-DB] function needed

2003-01-24 Thread heilo
Hi!

I hope I understood you right... I would use PCREs:

?php

function getdomainname($string)
{
$pattern = '#(([[:alnum:]]+)(\.))?(.+)(\.)([[:alnum:]]+)#i';
$replace = '\\4';
return preg_replace($pattern, $replace, $string);
}

$var = $_SERVER['SERVER_NAME'];

echo getdomainname($var);

?


.ma

Shahar Tal [EMAIL PROTECTED] [EMAIL PROTECTED] 18:44 Uhr:

 Hey
 
 I'm looking and wondering for a function, as i'm trying to do something, and
 here it is.
 
 I'm using the SSI call :
 !--#echo var=HTTP_HOST --.
 to get the domain name I am on. this will output
 
 www.domain.com.
 
 I would like to use PHP in order to take this string, the output, and cut
 the www. and the .com from it, so only the domain will remain.
 ofcourse we can also have situations whith .org and .net and even where
 there's no www. but the main thing I need is to remove whats
 after the second dot and before the first dot, along with the dots.
 
 I don't mind writing all the posibilities to the function, ie, all the
 possible extenstions that the function may need to cut, I just need it to
 take
 the text from the SSI, and cut everything but the domain part, which is
 the address itself.
 
 what would be the best way to do it?
 thank you!!
 
 



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