RE: [PHP-DB] alphabetical sorting... limiting and paginatingonnext set of letter group

2003-07-30 Thread Ow Mun Heng
Hi Ramil,

I'm also facing a similar problem, I would like to get the list
based on user Input. 

Please input 1st Letter of designers wanted : A, D, P

I've tried using OR but it somehow screws things up.

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Ramil G. Sagum [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 30, 2003 11:38 AM
To: [EMAIL PROTECTED]
Cc: Aaron Wolski
Subject: RE: [PHP-DB] alphabetical sorting... limiting and
paginatingonnext set of letter group


On Wed, 2003-07-30 at 11:17, Aaron Wolski wrote: 
 Hey,
 
 Thanks.
 
 Is there anyway this can be performed one function/loop?
 

yes of course. =) just create a function that takes in two letters as a
parameter,
then build the query string from it.


function($char_begin, $char_end)

{
  $q_begin = strtolower($char_begin);
  $q_end = chr(ord(strtolower($char_begin))+1);
  $query = SELECT designer_name FROM designer WHERE designer_name BETWEEN
'.$q_begin.' AND '.$q_end.' ORDER BY designer_name;


  //do your query here.
}


 I knew it was possible with several queries.. I guess I was just looking
 for a all_in_one solution.
 
 Thanks for your help!

 Aaron
 
 -Original Message-
 From: Ramil G. Sagum [mailto:[EMAIL PROTECTED] 
 Sent: July 29, 2003 11:07 PM
 To: Aaron Wolski
 Subject: Re: [PHP-DB] alphabetical sorting... limiting and paginating
 onnext set of letter group
 
 On Wed, 2003-07-30 at 10:36, Aaron Wolski wrote:
  Hi Guys,
  What I would like to do is:
  Pattern Designers:
   
  A/B/C
   
  Artists Collection The
  Barrick Samplers
  Bent Creek
  Bobbie G. Designs
  Calico Crossroads
  Charland Designs
  Country Cross Stitch
 
  Click for D/E/F
  Click for G/H/I
  Click for J/K/L
   
  When the user clicks on one of the another Letter Groupings... the
  A/B/C changes to whatever they selected as does the displayed
 results
  for their selection.
   
  Is this even possible?
   
  Aaron
 
 yes it is. =)
 
 try for a/b/c
 
 SELECT designer_name FROM designer WHERE designer_name BETWEEN 'a' AND
 'd' ORDER BY designer_name;
 
 for d/e/f :
 
 SELECT designer_name FROM designer WHERE designer_name BETWEEN 'd' AND
 'g' ORDER BY designer_name;
 
 for j/k/l:
 
 SELECT designer_name FROM designer WHERE designer_name BETWEEN 'j' AND
 'm' ORDER BY designer_name;
 
 
 
 hope this helps.
 
 
 ramil



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



RE: [PHP-DB] alphabetical sorting... limiting and paginatingonnext set of letter group

2003-07-30 Thread Ow Mun Heng
Hi John,

Your Suggestion worked GREAT! I'm new at this so.. Many Thanks.

Now I can use it as I like it.. 

KEWL...

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: CPT John W. Holmes [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 30, 2003 7:18 PM
To: Ow Mun Heng; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: Aaron Wolski
Subject: Re: [PHP-DB] alphabetical sorting... limiting and
paginatingonnext set of letter group


Where $string = 'A, D, P'

$fstring = str_replace(',',',',$string);
$query = SELECT * FROM Table WHERE LEFT(column,1) IN ('$fstring');

Some validation would be in order, but that's the basic idea. Same idea for
the original question, only you control the value of $string.

---John Holmes...

- Original Message - 
From: Ow Mun Heng [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: Aaron Wolski [EMAIL PROTECTED]
Sent: Wednesday, July 30, 2003 6:53 AM
Subject: RE: [PHP-DB] alphabetical sorting... limiting and paginatingonnext
set of letter group


Hi Ramil,

I'm also facing a similar problem, I would like to get the list
based on user Input.

Please input 1st Letter of designers wanted : A, D, P

I've tried using OR but it somehow screws things up.

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia
DID : 03-7870 5168


-Original Message-
From: Ramil G. Sagum [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 30, 2003 11:38 AM
To: [EMAIL PROTECTED]
Cc: Aaron Wolski
Subject: RE: [PHP-DB] alphabetical sorting... limiting and
paginatingonnext set of letter group


On Wed, 2003-07-30 at 11:17, Aaron Wolski wrote:
 Hey,

 Thanks.

 Is there anyway this can be performed one function/loop?


yes of course. =) just create a function that takes in two letters as a
parameter,
then build the query string from it.


function($char_begin, $char_end)

{
  $q_begin = strtolower($char_begin);
  $q_end = chr(ord(strtolower($char_begin))+1);
  $query = SELECT designer_name FROM designer WHERE designer_name BETWEEN
'.$q_begin.' AND '.$q_end.' ORDER BY designer_name;


  //do your query here.
}


 I knew it was possible with several queries.. I guess I was just looking
 for a all_in_one solution.

 Thanks for your help!

 Aaron

 -Original Message-
 From: Ramil G. Sagum [mailto:[EMAIL PROTECTED]
 Sent: July 29, 2003 11:07 PM
 To: Aaron Wolski
 Subject: Re: [PHP-DB] alphabetical sorting... limiting and paginating
 onnext set of letter group

 On Wed, 2003-07-30 at 10:36, Aaron Wolski wrote:
  Hi Guys,
  What I would like to do is:
  Pattern Designers:
 
  A/B/C
 
  Artists Collection The
  Barrick Samplers
  Bent Creek
  Bobbie G. Designs
  Calico Crossroads
  Charland Designs
  Country Cross Stitch

  Click for D/E/F
  Click for G/H/I
  Click for J/K/L
 
  When the user clicks on one of the another Letter Groupings... the
  A/B/C changes to whatever they selected as does the displayed
 results
  for their selection.
 
  Is this even possible?
 
  Aaron

 yes it is. =)

 try for a/b/c

 SELECT designer_name FROM designer WHERE designer_name BETWEEN 'a' AND
 'd' ORDER BY designer_name;

 for d/e/f :

 SELECT designer_name FROM designer WHERE designer_name BETWEEN 'd' AND
 'g' ORDER BY designer_name;

 for j/k/l:

 SELECT designer_name FROM designer WHERE designer_name BETWEEN 'j' AND
 'm' ORDER BY designer_name;



 hope this helps.


 ramil



-- 
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-DB] RE: Session help...

2003-07-29 Thread Ow Mun Heng
As mentioned previously in this list,

$_SESSION and session_register, session_is_register, is not compatible with
each other.

Anyway, I used your idea as inspiration for my own code.. My code works.. 

Try to change From:
if (!session_is_registered(valid_user)) {

To:
if ($_SESSION['valid_user']){
//your code
}

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: NIPP, SCOTT V (SBCSI) [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 29, 2003 9:19 PM
To: [EMAIL PROTECTED]
Subject: Session help...


Sorry for the slightly off-topic post...  I have a couple pages that
use a login page.  If the user tries to bring up one of these pages without
being logged in, then the pages redirects him to the login page.  After
successful login, the user is directed back to the page they were attempting
to originally load.  For some reason, this is not working and I have been
looking at this off and on for two days now without much luck.  The first
section of code is the snippet that directs users to the login page, and the
second snippet is the code from the login page that sends users back.

First code snippet...

session_start();
if ($sbcuid  $passwd) {
  mysql_select_db($database, $Prod);
  $query = select * from contacts_sa 
   . where sbcuid='$sbcuid' and passwd='$passwd';
  $result = mysql_query($query, $Prod) or die(mysql_error());
  # $data = mysql_fetch_assoc($result);
  $test = mysql_num_rows($result);
  if (mysql_num_rows($result) 0 )
  {
$valid_user = $sbcuid;
$_SESSION['valid_user'] = $sbcuid;
  }
}

if (!session_is_registered(valid_user)) {
  $return_url = $_SERVER['PHP_SELF'];
  $_SESSION['return_url'] = $return_url;
  header('Location: http://ldsa.sbcld.sbc.com/DW/sa_login.php');
  exit();
} else {
  $sbcuid = $valid_user;
}

End of first snippet...

Second code snippet...

session_start();
if ($sbcuid  $passwd) {
  if (isset($_SESSION['return_url'])) {
$link = $_SESSION['return_url'];
} else {
  $link = 'oncall_log.php';
  }
  mysql_select_db($database, $Prod);
  $query = select * from contacts_sa 
   . where sbcuid='$sbcuid' and passwd='$passwd';
  $result = mysql_query($query, $Prod) or die(mysql_error());
  # $data = mysql_fetch_assoc($result);
  $test = mysql_num_rows($result);
  if (mysql_num_rows($result) 0 ) {
$valid_user = $sbcuid;
# session_register(valid_user);
$_SESSION['valid_user'] = $sbcuid;
header(Location: http://.$_SERVER['HTTP_HOST'].$link);
  }
}

End of second snippet...

Thanks in advance for any help.
Scott Nipp
Phone:  (214) 858-1289
E-mail:  [EMAIL PROTECTED]
Web:  http:\\ldsa.sbcld.sbc.com



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



[PHP-DB] WHY need to query 2x to get results

2003-07-22 Thread Ow Mun Heng
Hi,

I have a code that goes like this. Scroll down to the --
sign. How come I need another $result = mysql_query($sql) at that location?
If I don't have it, the results coming out will only start printing from the
2nd Row.. Omitting the 1st.

Results as wanted 

row 1   value1
row 2   value2
row 3   value3

Getting this instead

row 2   value2
row 3   value3



Pls Help.

$result = mysql_query($sql);

$num_results = mysql_num_rows($result);

$row = mysql_fetch_row($result);

echo 'ph4There are ' . $num_results; 
echo ' FA entries found/p/h4' . \n;

echo 'table border=2 cellpadding=5' . \n;
echo 'td colspan=' . sizeof($row) . ' align=center ';
echo '/td' . \n;

# ===
# Print out the Table Field Names
# ===
echo '!-- Results Table Header Field Names --';
echo \n;
echo 'tr' . \n;

for ($k = 0; $k  sizeof($row) ; $k++)
{
echo \t . 'td';
echo mysql_field_name($result,$k);
echo /td \n;
}

# ===
# Print out the Table Results
# ===

$result = mysql_query($sql);   ---==WHY Is THIS
needed

for ($i = 0; $i  $num_results ; $i++)
{
echo tr\n  ;
$row = mysql_fetch_row($result);
for ($j = 0; $j  12 ; $j++)
{
echo \t . 'td';
echo  $row[$j] ;
echo /td \n;
}

echo /tr\n;
}
Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168

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



RE: [PHP-DB] WHY need to query 2x to get results

2003-07-22 Thread Ow Mun Heng
It worked like a charm. (initially I was trying to use reset() guess it was
the wrong call)

One other thing, The 1st call was supposed to get the Column Headers and the
second to get the results. I thought they are independent of each other??
Guess not?

thanks very much.

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Terry Riley [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 22, 2003 7:33 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] WHY need to query 2x to get results


Because you have already fetched one row before outputting the record 
count. Therefore the row pointer is at the second record before you 'print 
out'.

Try putting 

mysql_data_seek($result,0);

in place of your second 

$result = mysql_query($sql);

This should return the pointer to the first retreived record.

Hope that helps

Terry

--Original Message-  

 Hi,
 
   I have a code that goes like this. Scroll down to the 
--
 sign. How come I need another $result = mysql_query($sql) at that 
 location?
 If I don't have it, the results coming out will only start printing 
 from the
 2nd Row.. Omitting the 1st.
 
 Results as wanted 
 
 row 1 value1
 row 2 value2
 row 3 value3
 
 Getting this instead
 
 row 2 value2
 row 3 value3
 
 
 
 Pls Help.
 
   $result = mysql_query($sql);
 
   $num_results = mysql_num_rows($result);
 
   $row = mysql_fetch_row($result); 
   
   echo 'ph4There are ' . $num_results; 
   echo ' FA entries found/p/h4' . \n;
   
   echo 'table border=2 cellpadding=5' . \n;
   echo 'td colspan=' . sizeof($row) . ' align=center ';
   echo '/td' . \n;
 
 # ===
 # Print out the Table Field Names
 # ===
   echo '!-- Results Table Header Field Names --';
   echo \n;
   echo 'tr' . \n;
   
   for ($k = 0; $k  sizeof($row) ; $k++)
   {
   echo \t . 'td';
   echo mysql_field_name($result,$k);
   echo /td \n;
   }
 
 # ===
 # Print out the Table Results
 # ===
   
   $result = mysql_query($sql);   ---==WHY Is THIS
 needed
 
   for ($i = 0; $i  $num_results ; $i++)
   {
   echo tr\n  ;
   $row = mysql_fetch_row($result);
   for ($j = 0; $j  12 ; $j++)
   {
   echo \t . 'td';
   echo  $row[$j] ;
   echo /td \n;
   }
 
   echo /tr\n;
   }
 Cheers,
 Mun Heng, Ow
 H/M Engineering
 Western Digital M'sia 
 DID : 03-7870 5168
 



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



[PHP-DB] Pros/Cons Database vs Excel

2003-07-22 Thread Ow Mun Heng
Hi,

I'm having a problem convincing my boss of the benefits of using a
database vs just using excel as a way of tracking events.

The boss' stance is that excel is more 'simple' columns can be
expanded as and when it's wanted. You can put links into excel that points
to files residing in the system (within the web server's reach), can be
mailed out to distribution lists (some ppl are lazy to need to open up a
browser, log on etc.. to view the data). It can be stored on the web server
for retrieval later etc..

For a database, actually a database can do all of the above but to
me, it's makes more sense as it can store all the above and provide
additional functionality (as long as The code is written to make it more
functional).

Can anyone help me out and give me a few pointers on why using a
database makes more sense then excel.

What's needed:

1. Method for tracking sequence of events (sort of like experiment results)
2. Links embedded inside to relevent files (results of experiment)
3. Can be mailed around
4. additional fields can be added whenever wanted

something like that..


Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168

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



RE: [PHP-DB] getting MySQL column header?

2003-07-21 Thread Ow Mun Heng
Hey John,

This is another person asking the same question as I did..  thanks
again for your help.. :)

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: CPT John W. Holmes [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 22, 2003 4:24 AM
To: Aaron Wolski; [EMAIL PROTECTED]
Subject: Re: [PHP-DB] getting MySQL column header? 


 How would one get the column name/header out of this query so that I
 could display it as the header for my columns? 

Honestly, did you read the manual after I told you last time?? 

$num_fields = mysql_num_fields($result)
for($x=0;$x$num_fields;$x++)
{ echo mysql_field_name($result,$x); }

---John Holmes...

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