Re: [PHP-DB] Insert a xml file into a DB

2008-09-23 Thread Matt Anderton
I'm with Yves -- just store the xml files on the local disk and then record
their *location* in the DB if you need to reference them.

if you really want to store the xml in the db, why not just use a 'text'
data type?

-- matt



On Tue, Sep 23, 2008 at 4:35 PM, YVES SUCAET [EMAIL PROTECTED] wrote:

 Why do you need to store the files in a database? Can't you just keep them
 on
 the hard disk and query them with DOM?


 -- Original Message --
 Received: Tue, 23 Sep 2008 03:55:25 PM CDT
 From: ERNESTO PENALOZA [EMAIL PROTECTED]
 To: php-db@lists.php.net
 Subject: [PHP-DB] Insert a xml file into a DB

 Hi there, I've been trying to insert (and retrieve) a xml file into a
 postgres DB into a BLOB field, using some nice examples downloaded from the
 net, but they don't seem to work. Is there a standard way to do this?

 I read about a bytea data type and run some examples, but never understood
 how this data type works. When I retrieve the data, all I could see was a
 number. What should I do with this number? How can I use it to see the xml
 file content.?

 Thank you in advance.


 --
 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




Re: [PHP-DB] mySQL SELECT query

2008-08-29 Thread Matt Anderton
or NOT IN (0,4)

-- matt



On Fri, Aug 29, 2008 at 12:19 PM, Evert Lammerts
[EMAIL PROTECTED]wrote:

 In the SQL standard this would be

 AND NOT ministry_directory.listing_approved=0 AND NOT
 ministry_directory.listing_approved=4

 MySQL supports (and there are probably more RDBs that do):

 AND ministry_directory.listing_approved!=0 AND
 ministry_directory.listing_approved!=4

 On Fri, Aug 29, 2008 at 7:09 PM, Ron Piggott [EMAIL PROTECTED]
 wrote:
  Is there a way to make this part of a SELECT query more concise?
 
  AND ministry_directory.listing_approved NOT LIKE '0' AND
  ministry_directory.listing_approved NOT LIKE '4'
 
  I know of the
 
  IN ( 10, 12 )
 
  command.  Is there something similar available for NOT LIKE?
 
  Ron
 
 
  --
  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




Re: [PHP-DB] Submit Button variable passing

2008-05-03 Thread Matt Anderton
pass the value of reference as an argument to your 'deleteCategory()' and
'renameCategory()' functions:

script type=text/javascript
function deleteCategory(refVal) {
   ... do something with refVal ...
}

function renameCategory(refVal) {
   ... do something with refVal ...
}
/script

$table = table\n;
while($row = mysql_fetch_array($result

 ,MYSQL_ASSOC)) {
$table .= tr\n;
$table .= td . stripslashes($row['category_name']) . /td\n;
$table .= tdinput type=\button\ name=\submit\
  id=\delete\
 value=\Delete Category\ onclick=\deleteCategory(' . $row['reference']
 . ');\/td\n;
$table .= tdinput type=\button\ name=\submit\
  id=\rename\
 value=\Rename Category\ onclick=\renameCategory(' . $row['reference']
 . ');\/td\n;
$table .= /tr\n;
 }
 $table .= /table\n;


hope that helps.

-- matt



On Sat, May 3, 2008 at 1:00 PM, Ron Piggott [EMAIL PROTECTED]
wrote:


 In the PHP script below I need to be able to pass on the value of
 'reference' within the shopping_cart_product table when the Delete
 Category and Rename Category buttons are clicked.  How do I do this?
 Ron



 mysql_connect('localhost',$username,$password);
 @mysql_select_db($database) or die( Unable to select database);

 $query = SELECT *
FROM shopping_cart_category c
LEFT OUTER JOIN shopping_cart_product p
ON c.reference = p.reference
ORDER BY c.category_name ASC;

 $result = mysql_query($query);

 if(!$result) die('error: ' . mysql_error());

 mysql_close();

 $table = table\n;
 while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
$table .= tr\n;
$table .= td . stripslashes($row['category_name']) . /td\n;
$table .= tdinput type=\button\ name=\submit\
  id=\delete\
 value=\Delete Category\ onclick=\deleteCategory();\/td\n;
$table .= tdinput type=\button\ name=\submit\
  id=\rename\
 value=\Rename Category\ onclick=\renameCategory();\/td\n;
$table .= /tr\n;
 }
 $table .= /table\n;

 echo $table;


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




Re: [PHP-DB] Not updating certain fields in same row

2008-03-25 Thread Matt Anderton
I usually pre-populate the form with the values that are already in the
record:

(... using PEAR's MDB2 package -- http://pear.php.net/packages/MDB2 )

$query = SELECT * FROM member WHERE username = ' . $_POST['username'] .
';
$result = $db-query($query);
$member = $result-fetchRow(MDB2_FETCHMODE_ASSOC);

foreach ($member as $key = $value) {
 $$key = $value;
}

form name=member_edit action=?= $_SERVER['PHP_SELF'] ? method=POST
 input type=hidden name=_submit value=1 /
 input type=text name=fname value=?= $fname ? /
 input type=text name=lname value=?= $lname ? /
 input type=text name=email value=?= $email ? /
 
 
 
/form

then when they submit, the record is just repopulated with whatever is in
the form when they submit.  ie -- only fields they changed get changed in
the db.

if($_POST['_submit']) {
 $update = UPDATE member SET .. blah, blah...
}

that way, none of the fields are blank unless they were in the db blank to
begin with.  and you can add client or server-side validation to prevent
that.

-- matt





On Tue, Mar 25, 2008 at 11:59 AM, Jason Pruim [EMAIL PROTECTED] wrote:

 Hi everyone,

 I am attempting to update a record for a login system while leaving
 certain fields untouched if they arn't changed, and am running into
 issues.

 Basically what I want to do, is say I have these fields:

 Field1
 Field2
 Field3
 Field4

 I update Field1 and Field3 but not Field2 and Field4. What I want to
 do is change the values in Field1 and Field3 without touching the
 values in Field2 and Field4.

 I have tried this code:
$tab = \t;
if (!isset($_POST['txtLoginName']) ||
 empty($_POST['txtLoginName'])) {

$loginName =
 mysqli_real_escape_string($chpwpostlink,
 $_POST['txtLoginName']);
}
else
{
$loginName = $tab;
}

 which works the fields that I've changed, but if I don't submit a
 value in the form it sets the field to be blank in MySQL. Which is
 what I am trying to avoid. Any ideas?

 --

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






Re: [PHP-DB] Not updating certain fields in same row

2008-03-25 Thread Matt Anderton
I encrypt my pw's the same way but I usually don't include the password on
an edit my info page.  I create a separate change password screen where
I force them to type in their old password and then type a new one twice. if
the encrypted, salted old password attempt does not match what is in the db,
the form doesn't validate and the password is not changed.

the lost password page is a different beast altogether

but again, the password field is omitted from the edit form AND the update
statement so it is never touched in this process.

that goes for any other field you don't want the user to be able to edit too
-- just don't put it in the form or the update and they can't mess with it.
I usually have an is_admin (yes/no) field and don't want the user to
change that of course.

-- matt



On Tue, Mar 25, 2008 at 12:24 PM, Jason Pruim [EMAIL PROTECTED] wrote:


 On Mar 25, 2008, at 1:17 PM, Matt Anderton wrote:
  I usually pre-populate the form with the values that are already in
  the
  record:
 
  (... using PEAR's MDB2 package -- http://pear.php.net/packages/MDB2 )
 
  $query = SELECT * FROM member WHERE username = ' .
  $_POST['username'] .
  ';
  $result = $db-query($query);
  $member = $result-fetchRow(MDB2_FETCHMODE_ASSOC);
 
  foreach ($member as $key = $value) {
  $$key = $value;
  }
 
  form name=member_edit action=?= $_SERVER['PHP_SELF'] ?
  method=POST
  input type=hidden name=_submit value=1 /
  input type=text name=fname value=?= $fname ? /
  input type=text name=lname value=?= $lname ? /
  input type=text name=email value=?= $email ? /
  
  
  
  /form
 
  then when they submit, the record is just repopulated with whatever
  is in
  the form when they submit.  ie -- only fields they changed get
  changed in
  the db.
 
  if($_POST['_submit']) {
  $update = UPDATE member SET .. blah, blah...
  }
 
  that way, none of the fields are blank unless they were in the db
  blank to
  begin with.  and you can add client or server-side validation to
  prevent
  that.
 
  -- matt

 Hi Matt,

 That's what I'm doing for most of the fields, but how would you handle
 a password that has been MD5'ed and includes some variables to make it
 harder to crack? :)

 ie: $PW = md5($salt$password);

 I can't undo the MD5 and I don't really want to... Just want to be
 able to change it rather then view what it is.

 
 
 
 
 
 
  On Tue, Mar 25, 2008 at 11:59 AM, Jason Pruim [EMAIL PROTECTED]
  wrote:
 
  Hi everyone,
 
  I am attempting to update a record for a login system while leaving
  certain fields untouched if they arn't changed, and am running into
  issues.
 
  Basically what I want to do, is say I have these fields:
 
  Field1
  Field2
  Field3
  Field4
 
  I update Field1 and Field3 but not Field2 and Field4. What I want to
  do is change the values in Field1 and Field3 without touching the
  values in Field2 and Field4.
 
  I have tried this code:
$tab = \t;
if (!isset($_POST['txtLoginName']) ||
  empty($_POST['txtLoginName'])) {
 
$loginName =
  mysqli_real_escape_string($chpwpostlink,
  $_POST['txtLoginName']);
}
else
{
$loginName = $tab;
}
 
  which works the fields that I've changed, but if I don't submit a
  value in the form it sets the field to be blank in MySQL. Which is
  what I am trying to avoid. Any ideas?
 
  --
 
  Jason Pruim
  Raoset Inc.
  Technology Manager
  MQC Specialist
  3251 132nd ave
  Holland, MI, 49424-9337
  www.raoset.com
  [EMAIL PROTECTED]
 
 
 
 

 --

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






Re: [PHP-DB] Multiple values in SELECT query

2008-03-09 Thread Matt Anderton
I like the IN keyword:

SELECT * FROM table WHERE name LIKE ABC AND listing_type IN ('1','2');

works kinda like PHP's in_array

-- matt



On Sun, Mar 9, 2008 at 1:34 PM, Ron Piggott [EMAIL PROTECTED]
wrote:

 What is the correct syntax for where the results may be 1 or 2?  What
 have I done wrong?

 SELECT * FROM table WHERE name LIKE ABC AND listing_type = 1 or 2

 ???

 Ron


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




Re: [PHP-DB] mysql_connect() Help

2008-03-08 Thread Matt Anderton
Manysh -- maybe you missed the MySQL extension installation?

2nd or 3rd screen in the setup process there is a list of extensions -- none
of them are installed by default.

Your manual method of creating the 'ext' directory is a step in the right
direction, but you probably have a missing directive or two in your php.ini.

something like...
[PHP_MYSQL]
extension=php_mysql.dll

but there may be some other directives you are missing - port numbers, etc.
best to just reinstall.

-- matt


On Sat, Mar 8, 2008 at 5:53 PM, Manysh [EMAIL PROTECTED] wrote:

 Thanks for your input, Jon. Few more observations...

 Yes, I have PHP+Apache+MySQL installed for private use. I am just
 trying to connect to the database successfully first and will create
 other users when I make a successful connection. I made the changes as
 below and still cannot connect to the database. The echo After
 connecting to the database... is not in an if statement. I modified
 the script to make it real simple for me

 I found this document:
 http://www.artfulsoftware.com/php_mysql_win.html which outlines
 installation and configuration steps for MySQL and PHP. Unfortunately,
 I can't get it to work. One thing I noticed is that my PHP
 inatallation didn't have any ext directory so I manually created one
 and copied php_mysqli.dll to this directory and restarted my computer.
 It didn't work still. Any comments/ideas?
 
 ?php
 /*- DATABASE CONNECTION INFO-*/
 $hostname=localhost;
 $mysql_login=admin;
 $mysql_password=admin;

 echo Connected successfully yet? Probably not.;

 $link = @mysql_connect($hostname,$mysql_login,$mysql_password);
 if (!$link) {
//die('Could not connect: ' . mysql_error());
echo Some problem here;
 }
 else
echo Connected?;

 $dbname = 'sampleapp';
 $dbselect = @mysql_select_db($dbname);

 if ($dbselect)
echo Connected to the database;
 else
echo Still not connected to the database;
 mysql_close($link);
 ?
 





 On Sat, Mar 8, 2008 at 3:07 PM, Jon L. [EMAIL PROTECTED] wrote:
  Since you seem to want to handle the errors yourself, you may try using
 the
  @ operator on the mysql functions.
  It'll silence any errors or warning that the functions might usually
  generate; but, of course, you'll be left to test for errors yourself.
 
 
$link = @mysql_connect($hostname,$mysql_login,$mysql_password);
 
@mysql_select_db($dbname);
 
  With that, the following statement should return any errors that MySQL
 would
  otherwise generate:
 
 
if (!$link) {
  die (mysql_error());
}
 
 
  Now, I don't see any reason for the 2nd echo (i.e., echo  After
 connecting
  to the database...;) to not be called.
  Is it in an if statement or other structure/scope in your actual script?
 
  However, I do see a reason for another to never be called:
 
 
if (!$link) {
  die('Could not connect: ' . mysql_error());
  echo Some problem here;
}
 
  Once you call die, script execution discontinues.
  The echo after it will never be called, either by !$link returning false
 to
  if or by die being called first.
 
 
  On another note...
  This sounds like you have PHP  MySQL installed for private use.
  But, even if that's the case, I don't recommend connecting to the admin
  account unless you really need to.
 
  You should check out the following page on adding users:
  http://dev.mysql.com/doc/refman/5.0/en/adding-users.html
 
  And read up on the following commands:
  CREATE USER: http://dev.mysql.com/doc/refman/5.0/en/create-user.html
  GRANT: http://dev.mysql.com/doc/refman/5.0/en/grant.html
 
  - Jon L.
 
 
 
  On Sat, Mar 8, 2008 at 1:36 PM, Manysh [EMAIL PROTECTED] wrote:
  
  
  
   Hi,
  
   I am trying to make a connection to the MySQL database from PHP but it
   seems like I am missing a step or something and hence cannot connect
   to the database. I have tried everything but I can't figure out why.
   Please suggest/help (I am a beginner in PHP/MySQL/Apache).
  
   I am using MySQL 5.0.51a-community-nt on my Windows XP machine. PHP
   version used is 5.2 and Apache version is 2.2.
  
   Code Snippet:
  
   $hostname=localhost;
   $mysql_login=admin;
   $mysql_password=admin;
   //$database=sampleapp;
  
   echo Print this...; // THIS MESSAGE IS PRINTED
  
   $link = mysql_connect($hostname,$mysql_login,$mysql_password);
  
   echo  After connecting to the database...; // THIS DOES NOT PRINT
   if (!$link) {
   die (mysql_error()); // NOR THIS ONE
   }
  
   $dbname = 'sampleapp';
   mysql_select_db($dbname);
  
   echo $link;
  
   if (!$link) {
  die('Could not connect: ' . mysql_error());
  echo Some problem here;
   }
   //echo 'Connected successfully';
   mysql_close($link);
   ?
  
   Any help is appreciated.
   Thanks,
   Manysh
  
   --
   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 

Re: [PHP-DB] mysql_connect() Help

2008-03-08 Thread Matt Anderton
httpd.conf should have something like this:

PHPIniDir C:/Program Files/PHP/
LoadModule php5_module C:/Program Files/PHP/php5apache2.dll
AddType application/x-httpd-php .php

... but all that should have been taken care of by the PHP installer.

-- matt

On Sat, Mar 8, 2008 at 9:16 PM, Manysh [EMAIL PROTECTED] wrote:

 Matt - you're right! I did the manual install and its partially
 working now. I say partially because it works fine when I run it from
 the command window however when I run it from the web browser I get a
 blank page. I restarted Apache but that didn't help. The script is
 pasted below. Am I missing from the Apache side now? I have configured
 http.conf too... is there anything else I need to take care of?
 Thanks
 
 ?php
 /*- DATABASE CONNECTION INFO-*/
 $hostname=localhost;
 $mysql_login=testuser;
 $mysql_password=testuser;

 echo Connected successfully yet? Probably not.;

 $link = @mysql_connect($hostname,$mysql_login,$mysql_password);
 if (!$link) {
//die('Could not connect: ' . mysql_error());
echo Some problem here;
 }
 else
echo Connected?;

 $dbname = 'sampleapp';
 $dbselect = @mysql_select_db($dbname);

 if ($dbselect)
echo Connected to the database;
 else
echo Still not connected to the database;
 mysql_close($link);
 ?

  On Sat, Mar 8, 2008 at 7:22 PM, Matt Anderton [EMAIL PROTECTED]
 wrote:
  Manysh -- maybe you missed the MySQL extension installation?
 
  2nd or 3rd screen in the setup process there is a list of extensions --
 none
  of them are installed by default.
 
  Your manual method of creating the 'ext' directory is a step in the
 right
  direction, but you probably have a missing directive or two in your
 php.ini.
 
  something like...
  [PHP_MYSQL]
  extension=php_mysql.dll
 
  but there may be some other directives you are missing - port numbers,
 etc.
  best to just reinstall.
 
  -- matt
 
 
 
 
   On Sat, Mar 8, 2008 at 5:53 PM, Manysh [EMAIL PROTECTED] wrote:
   Thanks for your input, Jon. Few more observations...
  
   Yes, I have PHP+Apache+MySQL installed for private use. I am just
   trying to connect to the database successfully first and will create
   other users when I make a successful connection. I made the changes as
   below and still cannot connect to the database. The echo After
   connecting to the database... is not in an if statement. I modified
   the script to make it real simple for me
  
   I found this document:
   http://www.artfulsoftware.com/php_mysql_win.html which outlines
   installation and configuration steps for MySQL and PHP. Unfortunately,
   I can't get it to work. One thing I noticed is that my PHP
   inatallation didn't have any ext directory so I manually created one
   and copied php_mysqli.dll to this directory and restarted my computer.
   It didn't work still. Any comments/ideas?
   
   ?php
   /*- DATABASE CONNECTION INFO-*/
   $hostname=localhost;
   $mysql_login=admin;
   $mysql_password=admin;
  
   echo Connected successfully yet? Probably not.;
  
   $link = @mysql_connect($hostname,$mysql_login,$mysql_password);
   if (!$link) {
  //die('Could not connect: ' . mysql_error());
  echo Some problem here;
   }
   else
  echo Connected?;
  
   $dbname = 'sampleapp';
   $dbselect = @mysql_select_db($dbname);
  
   if ($dbselect)
  echo Connected to the database;
   else
  echo Still not connected to the database;
   mysql_close($link);
   ?
   
  
  
  
  
  
   On Sat, Mar 8, 2008 at 3:07 PM, Jon L. [EMAIL PROTECTED] wrote:
Since you seem to want to handle the errors yourself, you may try
 using
  the
@ operator on the mysql functions.
It'll silence any errors or warning that the functions might usually
generate; but, of course, you'll be left to test for errors
 yourself.
   
   
  $link = @mysql_connect($hostname,$mysql_login,$mysql_password);
   
  @mysql_select_db($dbname);
   
With that, the following statement should return any errors that
 MySQL
  would
otherwise generate:
   
   
  if (!$link) {
die (mysql_error());
  }
   
   
Now, I don't see any reason for the 2nd echo (i.e., echo  After
  connecting
to the database...;) to not be called.
Is it in an if statement or other structure/scope in your actual
 script?
   
However, I do see a reason for another to never be called:
   
   
  if (!$link) {
die('Could not connect: ' . mysql_error());
echo Some problem here;
  }
   
Once you call die, script execution discontinues.
The echo after it will never be called, either by !$link returning
 false
  to
if or by die being called first.
   
   
On another note...
This sounds like you have PHP  MySQL installed for private use.
But, even if that's the case, I don't recommend connecting to the
 admin
account unless you really need to.
   
You should check out

Re: [PHP-DB] New to PHP/MySQL - Need help with images

2008-01-05 Thread Matt Anderton
how about like this:

echo table\ntr;
$result = @mysql_query(SELECT image FROM specials);
while($row = mysql_fetch_row($result)) {
   echo tdimg src= . $row[0] .  //td\n;
}
echo /tr\n/table\n;

hope it helps!
matt

On Jan 5, 2008 4:51 PM, Thomas [EMAIL PROTECTED] wrote:

 I'm attempting to make a table with one row and 3 columns holding three
 different images. I want each image URL to be called from my database.
 Everything is set-up in my database. When I use the following code, it
 places the same picture across the three columns and does this three times
 (creating three rows.) I want a different picture to be placed across the
 three columns and to have only one row. What can I do?

 Here is the code:

 $result = @mysql_query('SELECT image FROM specials');
 $num=mysql_numrows($result);
 $i = 0;
 while ($i  $num) {
 $image=mysql_result($result,$i,image);
 ?
 table
 tr
 td
 img src=? echo $image; ?
 /td
 td
 img src=? echo $image; ?
 /td
 td
 img src=? echo $image; ?
 /td
 /tr
 ?
 $i++;
 }
 echo /table;
 ?

 --
 Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

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




Re: [PHP-DB] Re: [PHP] the opposite of a join?

2007-10-03 Thread Matt Anderton
you could do a RIGHT OUTER JOIN WHERE the company table is on the right to
show you the companies that do not exist in the contacts table:

SELECT a.name, b.name
FROM contacts a
RIGHT OUTER JOIN company b
ON a.company_id = b.id
WHERE a.name IS NULL;

results:
+--+---+
| name | name  |
+--+---+
| NULL | Company C |
+--+---+

contacts:
++--++
| id | name | company_id |
++--++
|  1 | Gerald Ford|  2 |
|  2 | Jimmy Carter |  1 |
|  3 | Bill Clinton |  2 |
++--++

company:
++---+
| id | name  |
++---+
|  1 | Company A |
|  2 | Company B |
|  3 | Company C |
++---+

-- matt



On 10/3/07, Zoltán Németh [EMAIL PROTECTED] wrote:

 2007. 10. 3, szerda keltezéssel 05.21-kor [EMAIL PROTECTED] ezt írta:
  I have a company table and a contacts table.  In the contacts table,
 there
  is a field called companyID which is a link to a row in the company
 table.
 
 
 
  What is the easiest way to query the company table for all the company
 rows
  whose ID is NOT linked to in the contact table? Basically, the opposite
 of a
  join?
 

 maybe something like

 SELECT * FROM company WHERE (SELECT COUNT(*) FROM contact WHERE
 company_id = company.company_id)=0

 it's not very efficient, but I don't have any better idea. someone else?

 greets
 Zoltán Németh

 
 
  Thanks
 
 
 
  J
 
 
 

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




Re: [PHP-DB] php portfolio

2007-04-19 Thread Matt Anderton

awesome guys.  thanks a lot.  one thing I think I DO have going for me --
true I have only flown solo, never worked on a team, but my current project
was designed entirely to someone else's specs.  I knew there would be lots
of changes as it went along and I think I did a decent job of working in
some basic OOP so I would only have to make changes once.

I guess what I still don't get is how do I go about exposing the code for
it?  it is a live web site -- I don't want the average visitor to see chunks
of code all over the place.  do I put up a separate copy on a separate
website?  point the employer to the real deal first, then give him a link to
a behind the scenes version?  and then what?  just throw in pre tags
-- this is how I did this part?

~ matt


On 4/19/07, bedul [EMAIL PROTECTED] wrote:


nope.. nothing dumb on your question.
- Original Message -
From: Matt Anderton [EMAIL PROTECTED]
To: php-db@lists.php.net
Sent: Thursday, April 19, 2007 8:49 AM
Subject: [PHP-DB] php portfolio


 I have a kind-of off topic rookie question:

 most programmers have a web portfolio right?  -- a URI to put on their
 resume that has examples of their work.  what do employers expect to see
if
 they ask for such an example?  a working web app?  links to multiple
working
 web apps?  actual code?
well the style of your code make how good you are...
but remember.. if you work alone.. that's no problem.. the problem is when
u
work on a team
-

 I am dying to break into PHP/MySQL programming and have gotten a nibble
from
 an employer who is asking for such a URI.  I don't have any professional
 programming experience, but have several small projects that I would
like
an
 interested employer to see.  what is the best way to present it/them?
just
 a link to one of my finished projects?  can an experienced programmer
get
a
 strong enough sense of how I code by looking at the end result (probably
a
 dumb question)?
my suggestion was.. to improve your skill.. U have to be complained and
meet
problem during your programing. more problem will improve your prog skill.
but don't stress because of it


 thanks,
 matt





[PHP-DB] php portfolio

2007-04-18 Thread Matt Anderton

I have a kind-of off topic rookie question:

most programmers have a web portfolio right?  -- a URI to put on their
resume that has examples of their work.  what do employers expect to see if
they ask for such an example?  a working web app?  links to multiple working
web apps?  actual code?

I am dying to break into PHP/MySQL programming and have gotten a nibble from
an employer who is asking for such a URI.  I don't have any professional
programming experience, but have several small projects that I would like an
interested employer to see.  what is the best way to present it/them?  just
a link to one of my finished projects?  can an experienced programmer get a
strong enough sense of how I code by looking at the end result (probably a
dumb question)?

thanks,
matt


[PHP-DB] populating multi-dimensional array

2007-04-11 Thread Matt Anderton

long-time reader, first-time poster.

I am trying to use PEAR's 'hierselect' in HTML_Quickform.

I have category and subcategory tables.  I want to populate a
drop-down based on category, then populate the subcategory based on
the user's category selection.

mysql desc category;
++-+--+-+-++
| Field  | Type| Null | Key | Default | Extra  |
++-+--+-+-++
| cat_id | int(11) | NO   | PRI | NULL| auto_increment |
| name   | varchar(30) | YES  | | NULL||
++-+--+-+-++
2 rows in set (0.00 sec)

mysql desc subcategory;
+---+-+--+-+-++
| Field | Type| Null | Key | Default | Extra  |
+---+-+--+-+-++
| sc_id | tinyint(4)  | NO   | PRI | NULL| auto_increment |
| name  | varchar(30) | YES  | | NULL||
| cat   | tinyint(4)  | YES  | | NULL||
+---+-+--+-+-++
3 rows in set (0.01 sec)

here's what I *THINK* the code should look like:


9  $form = new HTML_QuickForm('catForm','POST');
10
11  $form-addElement('header', null, 'Add a New Category');
12
13  $main = array();
14  $secondary = array();
15
16  $query1 = SELECT * FROM category;
17  $result1 = $db-query($query);
18  while ($result-fetchInto($row1)) {
19$main[($row1[0])] = $row1[1];
20  }
21
22  for ($i = 0; $i  count($main); $i++) {
23$query2 = SELECT * FROM subcategory WHERE cat =  . $i;
24$result2 = $db-query($query2);
25$while ($result2-fetchInto($row2)) {
26  $secondary[$i][] = $row2[1];
27}
28  }
29
30  $sel = $form-addElement('hierselect', 'cats', 'Categories: ');
31  $sel-setMainOptions($main);
32  $sel-setSecOptions($secondary);
33  $form-addElement('submit', 'btnSubmit', 'Submit');
34
35  $form-display();


but I keep getting unexpected '[' on line 25

is there a problem with populating the $secondary array that way?

thanks,
matt

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



Re: [PHP-DB] Re: populating multi-dimensional array

2007-04-11 Thread Matt Anderton

thanks for the advice Roberto!  the typos in (2) WERE the cause of my
problems.

I appreciate the comments on my SQL queries and table structures too.
sloppy rookie mistakes.

~ matt


On 4/11/07, Roberto Mansfield [EMAIL PROTECTED] wrote:


Matt Anderton wrote:
 long-time reader, first-time poster.

 I am trying to use PEAR's 'hierselect' in HTML_Quickform.


A few things:

1. SQL style: avoid SELECT * and list your field names in the specific
order you want them. What you have works, but you are assuming the field
order in your statement. It isn't self documenting either. In a week,
month, year -- will you or the next programmer know what fields *
represents?

2. This may be a typo in your post, but line 25 uses $while instead of
while. Also in line 17, your use $result1, but just $result in the
next line.

3. For clearer code, use the same field name for foreign keys in your
tables. So in subcategory, use cat_id instead of cat. It is also a
good idea to keep the field types identical when matching on keys.

3. Your code would be cleaner with a join:


$query1 = SELECT cat.cat_id,
  cat.name AS cat_name,
  subcat.sc_id,
  subcat.name AS subcat_name
 FROM category cat,
  subcategory subcat
WHERE subcat.cat = cat.cat_id
 ORDER BY cat.name, subcat.name;

$result = $db-query($query);
while ( $result-fetchInto($row) ) {
  $main[$row[0]] = $row[1];
  $secondary[$row[0]][$row[2]] = $row[3];
}


Hope that helps.
Roberto

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