[PHP-DB]how to handle exception in php

2010-05-01 Thread Bavithra R
hi friends

I am doing a simple student mark details project.
for calculating rank I need to compare the total marks one by one.
To do so i use *for loop.* so atlast while reaching the end of the table it
shows the following warning.
*
Warning*: mysql_result()
[function.mysql-result]:
Unable to jump to row 18 on MySQL result index on line *50*

It is because it has no next value to compare.How to use try..catch
exception handling in this.?Or any other suggestion.
Can anybody help me

--Bavithra


Re: [PHP-DB] How to use PHP to fill in existing pdf document

2010-05-01 Thread Karl DeSaulniers

Just a thought,
You may be able to instead of having them download, just display it  
as a html page
and the fields will be there, then attach a PHP mail script to it  
somehow with a macro or something to that effect.
Have it call on this php script to send the message and/or store in  
the database.
The php script will have to be attached to the basic pdf before its  
uploaded, but I think that is possible.

Might be worth some investigating. Doesn't seem to difficult.

Karl


On May 2, 2010, at 12:18 AM, Karl DeSaulniers wrote:


Hi Ron,
I have done this once before and what I had to do was let the user  
download the pdf that had the fields in it, they fill in the fields  
and email the pdf back, right from acrobat.
In the pdf, you set the fields to lock after they finish and  
submit. You can also have them sign the document virtually then  
lock the whole document.
Then you set it up to email the pdf back to you. They will need a  
email program for this on their computer of course. Like Eudora or  
Mail or Outlook.
You can put a notice link in the PDF to an upload form on your site  
if they do not have a mail program.


You will need Acrobat Professional to do this though. There may be  
another one I don't know of.

HTH,

Karl


On May 1, 2010, at 10:36 PM, listread wrote:

Yes, I've looked hard at fdpf and see how it is used to generate a  
new pdf, but I need to simply fill in the form fields in an  
existing pdf.  If it can do that, I'm not finding the feature


Thanks,

- Ron

On 5/1/2010 7:43 PM, Gary wrote:

"listread"  wrote in message
news:4bdc9ced.3060...@cze.com...

Yes, we can first ask the user to fill in a form, but then comes  
the part

I don't understand - how to covert it to pdf.

It would be best if we could just fill in the fields on an  
existing form,
but it would also work to print the printer friendly form to the  
server's
printer queue, which could really be a postscript file we could  
then
convert to pdf.  In that case, I need to learn how to get PHP to  
print to

the server's printer...

- Ron

On 5/1/2010 7:53 AM, nagendra prasad wrote:

I am not sure if this works for your project but you can first  
ask user

to
fill the form in PHP and then convert it into PDF. What say?





__ Information from ESET Smart Security, version of virus
signature database 5078 (20100501) __

The message was checked by ESET Smart Security.

http://www.eset.com





Ron

Take a peek at this

http://fpdf.org/

Writing to a pdf from php is very cumbersome, this seems to take  
some of the

sting out.

Gary



__ Information from ESET Smart Security, version of virus  
signature database 5078 (20100501) __


The message was checked by ESET Smart Security.

http://www.eset.com









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



Karl DeSaulniers
Design Drumm
http://designdrumm.com


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



Karl DeSaulniers
Design Drumm
http://designdrumm.com


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



Re: [PHP-DB] How to use PHP to fill in existing pdf document

2010-05-01 Thread Karl DeSaulniers

Hi Ron,
I have done this once before and what I had to do was let the user  
download the pdf that had the fields in it, they fill in the fields  
and email the pdf back, right from acrobat.
In the pdf, you set the fields to lock after they finish and submit.  
You can also have them sign the document virtually then lock the  
whole document.
Then you set it up to email the pdf back to you. They will need a  
email program for this on their computer of course. Like Eudora or  
Mail or Outlook.
You can put a notice link in the PDF to an upload form on your site  
if they do not have a mail program.


You will need Acrobat Professional to do this though. There may be  
another one I don't know of.

HTH,

Karl


On May 1, 2010, at 10:36 PM, listread wrote:

Yes, I've looked hard at fdpf and see how it is used to generate a  
new pdf, but I need to simply fill in the form fields in an  
existing pdf.  If it can do that, I'm not finding the feature


Thanks,

- Ron

On 5/1/2010 7:43 PM, Gary wrote:

"listread"  wrote in message
news:4bdc9ced.3060...@cze.com...

Yes, we can first ask the user to fill in a form, but then comes  
the part

I don't understand - how to covert it to pdf.

It would be best if we could just fill in the fields on an  
existing form,
but it would also work to print the printer friendly form to the  
server's

printer queue, which could really be a postscript file we could then
convert to pdf.  In that case, I need to learn how to get PHP to  
print to

the server's printer...

- Ron

On 5/1/2010 7:53 AM, nagendra prasad wrote:

I am not sure if this works for your project but you can first  
ask user

to
fill the form in PHP and then convert it into PDF. What say?





__ Information from ESET Smart Security, version of virus
signature database 5078 (20100501) __

The message was checked by ESET Smart Security.

http://www.eset.com





Ron

Take a peek at this

http://fpdf.org/

Writing to a pdf from php is very cumbersome, this seems to take  
some of the

sting out.

Gary



__ Information from ESET Smart Security, version of virus  
signature database 5078 (20100501) __


The message was checked by ESET Smart Security.

http://www.eset.com









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



Karl DeSaulniers
Design Drumm
http://designdrumm.com


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



Re: [PHP-DB] How to use PHP to fill in existing pdf document

2010-05-01 Thread listread
Yes, I've looked hard at fdpf and see how it is used to generate a new 
pdf, but I need to simply fill in the form fields in an existing pdf.  
If it can do that, I'm not finding the feature


Thanks,

- Ron

On 5/1/2010 7:43 PM, Gary wrote:

"listread"  wrote in message
news:4bdc9ced.3060...@cze.com...
   

Yes, we can first ask the user to fill in a form, but then comes the part
I don't understand - how to covert it to pdf.

It would be best if we could just fill in the fields on an existing form,
but it would also work to print the printer friendly form to the server's
printer queue, which could really be a postscript file we could then
convert to pdf.  In that case, I need to learn how to get PHP to print to
the server's printer...

- Ron

On 5/1/2010 7:53 AM, nagendra prasad wrote:
 

I am not sure if this works for your project but you can first ask user
to
fill the form in PHP and then convert it into PDF. What say?


   


__ Information from ESET Smart Security, version of virus
signature database 5078 (20100501) __

The message was checked by ESET Smart Security.

http://www.eset.com



 

Ron

Take a peek at this

http://fpdf.org/

Writing to a pdf from php is very cumbersome, this seems to take some of the
sting out.

Gary



__ Information from ESET Smart Security, version of virus signature 
database 5078 (20100501) __

The message was checked by ESET Smart Security.

http://www.eset.com





   



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



Re: [PHP-DB] How to use PHP to fill in existing pdf document

2010-05-01 Thread Gary



"listread"  wrote in message 
news:4bdc9ced.3060...@cze.com...
> Yes, we can first ask the user to fill in a form, but then comes the part 
> I don't understand - how to covert it to pdf.
>
> It would be best if we could just fill in the fields on an existing form, 
> but it would also work to print the printer friendly form to the server's 
> printer queue, which could really be a postscript file we could then 
> convert to pdf.  In that case, I need to learn how to get PHP to print to 
> the server's printer...
>
> - Ron
>
> On 5/1/2010 7:53 AM, nagendra prasad wrote:
>> I am not sure if this works for your project but you can first ask user 
>> to
>> fill the form in PHP and then convert it into PDF. What say?
>>
>>
>
>
> __ Information from ESET Smart Security, version of virus 
> signature database 5078 (20100501) __
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
>
Ron

Take a peek at this

http://fpdf.org/

Writing to a pdf from php is very cumbersome, this seems to take some of the 
sting out.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5078 (20100501) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP-DB] How to use PHP to fill in existing pdf document

2010-05-01 Thread Kesavan Rengarajan
Search for pdflib or fpdf. They help you with generating PDF files  
from a php script.


Sent from my iPhone

On 02/05/2010, at 7:28 AM, listread  wrote:

Yes, we can first ask the user to fill in a form, but then comes the  
part I don't understand - how to covert it to pdf.


It would be best if we could just fill in the fields on an existing  
form, but it would also work to print the printer friendly form to  
the server's printer queue, which could really be a postscript file  
we could then convert to pdf.  In that case, I need to learn how to  
get PHP to print to the server's printer...


- Ron

On 5/1/2010 7:53 AM, nagendra prasad wrote:
I am not sure if this works for your project but you can first ask  
user to

fill the form in PHP and then convert it into PDF. What say?





--
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] How to use PHP to fill in existing pdf document

2010-05-01 Thread listread
Yes, we can first ask the user to fill in a form, but then comes the 
part I don't understand - how to covert it to pdf.


It would be best if we could just fill in the fields on an existing 
form, but it would also work to print the printer friendly form to the 
server's printer queue, which could really be a postscript file we could 
then convert to pdf.  In that case, I need to learn how to get PHP to 
print to the server's printer...


- Ron

On 5/1/2010 7:53 AM, nagendra prasad wrote:

I am not sure if this works for your project but you can first ask user to
fill the form in PHP and then convert it into PDF. What say?

   



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



Re: [PHP-DB] How to use PHP to fill in existing pdf document

2010-05-01 Thread nagendra prasad
I am not sure if this works for your project but you can first ask user to
fill the form in PHP and then convert it into PDF. What say?


[PHP-DB] How to use PHP to fill in existing pdf document

2010-05-01 Thread listread

Greetings PHP gurus!

Does anyone know of a way to use PHP to fill in the form fields in an 
existing pdf document residing on the server?


We want the end result to be the creation of a unique pdf document for 
each visitor which can either be emailed or stored in a directory on the 
server.


We prefer to do this without any server side dependencies, other than 
files residing on the website.


Thanks in advance for your help.

- Ron

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



Re: [PHP-DB] grabbing from multiple tables

2010-05-01 Thread Karl DeSaulniers

@Peter
To be honest, this is my first one.
So the margin for error is probably there, I just cant see it.
BUT, I did get this database file pre-made from WebAssist.
Its their E-Commerce database file they gave out. (Sorry if I am  
repeating myself)
So the structure was set up by another and I am adopting it so I can  
learn how this is done.


I was wondering the same as you when I saw the options and options  
group tables.
I figured there was a structure there I could not understand at the  
time,

but continued on knowing I would come across the answer somehow.

You are probably right in the notion that the multiple tables are not  
needed, but
I am wondering then why they were included in the template if they  
are not.

Again, an answer I knew I would come across sooner or later.
Just looks like later then sooner. :)

I do appreciate the help, it has helped me narrow a few things down.
I'll let you know if I am successful.

Best,

On May 1, 2010, at 3:59 AM, Peter Lind wrote:


I'm starting to wonder about your data model.


Karl DeSaulniers
Design Drumm
http://designdrumm.com



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



Re: [PHP-DB] grabbing from multiple tables

2010-05-01 Thread Karl DeSaulniers

GOLD!
Thank you.

Karl


On May 1, 2010, at 4:12 AM, Peter Lind wrote:


On 1 May 2010 11:00, Karl DeSaulniers  wrote:

Thank you Peter... again.. :)
Which would be the source field and which the target field?


You place the constraint on the table that has the foreign key. Using
your example:

Table 1 = products
* id = primary key

Table 2 = productoptions
* product_id = foreign key

On table 2 you would place a constraint like this (in SQL):
CONSTRAINT FOREIGN KEY (product_id) REFERENCES products (id) ON  
DELETE CASCADE


This will delete any rows in table 2 if a matching row in table 1 is
deleted (i.e. if you delete a product, all rows in table 2 matching
options to products will be deleted as well, if they reference the
deleted product).

If instead you want to make sure that no product can be deleted while
it still has options attached, use this:

CONSTRAINT FOREIGN KEY (product_id) REFERENCES products (id) ON  
DELETE NO ACTION


I don't really know how this translates into your "source" and
"target" but I would guess source means the primary key on table 1 and
target means the foreign key on table 2 ... though, thinking about it,
it would make at least as much sense the other way round. Best see if
you can find some documentation to translate those terms into
something SQL-centric

Regards
Peter

--

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51



Karl DeSaulniers
Design Drumm
http://designdrumm.com


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



Re: [PHP-DB] grabbing from multiple tables

2010-05-01 Thread Peter Lind
On 1 May 2010 11:00, Karl DeSaulniers  wrote:
> Thank you Peter... again.. :)
> Which would be the source field and which the target field?

You place the constraint on the table that has the foreign key. Using
your example:

Table 1 = products
* id = primary key

Table 2 = productoptions
* product_id = foreign key

On table 2 you would place a constraint like this (in SQL):
CONSTRAINT FOREIGN KEY (product_id) REFERENCES products (id) ON DELETE CASCADE

This will delete any rows in table 2 if a matching row in table 1 is
deleted (i.e. if you delete a product, all rows in table 2 matching
options to products will be deleted as well, if they reference the
deleted product).

If instead you want to make sure that no product can be deleted while
it still has options attached, use this:

CONSTRAINT FOREIGN KEY (product_id) REFERENCES products (id) ON DELETE NO ACTION

I don't really know how this translates into your "source" and
"target" but I would guess source means the primary key on table 1 and
target means the foreign key on table 2 ... though, thinking about it,
it would make at least as much sense the other way round. Best see if
you can find some documentation to translate those terms into
something SQL-centric

Regards
Peter

-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51


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



Re: [PHP-DB] grabbing from multiple tables

2010-05-01 Thread Karl DeSaulniers

Thank you Peter... again.. :)
Which would be the source field and which the target field?

Karl


On May 1, 2010, at 3:22 AM, Peter Lind wrote:


On 30 April 2010 20:49, Karl DeSaulniers  wrote:

No, please confuse me. I need to know this stuff.

@Peter thanks for that introduction to foreign keys. Since my  
productoptions
table is based off of items in products, optionGroups and options,  
would I

use foreign keys for this?


If I read you correct, your productoptions table is basically a lookup
table and as such all your fields should be foreign keys. Because,
each field is a reference to another table - and it's vital to data
consistency that they cannot point to a row in a table that doesn't
exist.

--

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51



Karl DeSaulniers
Design Drumm
http://designdrumm.com


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



Re: [PHP-DB] grabbing from multiple tables

2010-05-01 Thread Peter Lind
On 1 May 2010 10:13, Karl DeSaulniers  wrote:
> What is the SQL query I can use to get an item that has two IDs?
> Something to the effect of...
>
> $q = "SELECT OptID = '$OptID' FROM ".PRODUCT_OPTIONS." WHERE ProdID =
> '$ProdID' AND OptGrpID='$OptGrpID'";

Close but no cigar.

$q = "SELECT OptID FROM ".PRODUCT_OPTIONS." WHERE ProdID = '$ProdID'
AND OptGrpID='$OptGrpID'";

I am assuming that you have escaped $ProdID and $OptGrpID :)

> Is this correct or am I missing something?
> A single group ID can have multiple option IDs set to it.
> A single product ID can have multiple group IDs set to it.

You're looking at a many-to-many table - a row should be unique given
all three IDs. Only those three IDs together should form a unique row.

> I am trying to single out a product option.
> The option has a group ID and a product ID assigned to it.
>

I'm starting to wonder about your data model. Should options always be
in groups? I'm guessing that you need one of three things:
1. Split up the product options table. A product can have some
individual options and some group options - these have nothing to do
with each other and you need to be able to set them without regard for
each other.
2. Remove the productOptionID from the product options table. A
product only has option groups, no individual options.
3. Remove the groupOptionID from the product options table. A product
only has individual options, regardless of the option group these
options belong to.

Regards
Peter

-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51


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



Re: [PHP-DB] grabbing from multiple tables

2010-05-01 Thread Peter Lind
On 30 April 2010 20:49, Karl DeSaulniers  wrote:
> No, please confuse me. I need to know this stuff.
>
> @Peter thanks for that introduction to foreign keys. Since my productoptions
> table is based off of items in products, optionGroups and options, would I
> use foreign keys for this?

If I read you correct, your productoptions table is basically a lookup
table and as such all your fields should be foreign keys. Because,
each field is a reference to another table - and it's vital to data
consistency that they cannot point to a row in a table that doesn't
exist.

-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51


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



Re: [PHP-DB] grabbing from multiple tables

2010-05-01 Thread Karl DeSaulniers

What is the SQL query I can use to get an item that has two IDs?
Something to the effect of...

$q = "SELECT OptID = '$OptID' FROM ".PRODUCT_OPTIONS." WHERE ProdID =  
'$ProdID' AND OptGrpID='$OptGrpID'";


Is this correct or am I missing something?
A single group ID can have multiple option IDs set to it.
A single product ID can have multiple group IDs set to it.

I am trying to single out a product option.
The option has a group ID and a product ID assigned to it.

TIA

Karl


On Apr 30, 2010, at 3:54 PM, Karl DeSaulniers wrote:


To elaborate a little more,

In essence, the options and the option groups will be added to the  
database by an admin,

the products will be added by admins and employees alike.

When an employee goes to add a product, I want them to be able to  
choose from a dropdown
or a table with names and radio buttons or checkboxes to select the  
options for that product.

Selecting the option will corolate their option groups when selected.

The productID, optionID and optionGroupID will be stored in the  
productoptions table when the product gets submitted.


That simple. Or I think that simple.. :)

Karl

On Apr 30, 2010, at 2:59 PM, David Murphy wrote:




-Original Message-
From: Karl DeSaulniers [mailto:k...@designdrumm.com]
Sent: Friday, April 30, 2010 1:50 PM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] grabbing from multiple tables

No, please confuse me. I need to know this stuff.

@Peter thanks for that introduction to foreign keys. Since my
productoptions table is based off of items in products, optionGroups
and options, would I use foreign keys for this?

@DZvonko Thanks for trying to protect me, but I am a big boy. :) Do
you have an example of how this JOIN works? Since my productoptions
table is based off of items in products, optionGroups and options,
would I use JOIN for this? And how?

I am looking for the quickest and easiest obviously, but not against
learning the longer and harder.
I just really wanted to know how to use the foreign key in a real
situation.
If JOIN is a more viable solution, I'm all ears.

Any examples or tutorials someone can send me?

Thanks,

Karl


On Apr 30, 2010, at 6:41 AM, DZvonko Nikolov wrote:


Hi,

don't confuse the guy. Just use JOIN clause and you will be fine.
Check for the right syntax and don't complicate more. He said he
is quite new, so discuss about foreign keys will only confuse him.

Use JOIN and pure SQL and you will be fine.

Cheers
DZvonko

--- On Fri, 4/30/10, Peter Lind  wrote:

From: Peter Lind 
Subject: Re: [PHP-DB] grabbing from multiple tables
To: "Karl DeSaulniers" 
Cc: "php-db@lists.php.net" 
Date: Friday, April 30, 2010, 12:31 PM

On 30 April 2010 12:26, Karl DeSaulniers   
wrote:

Thanks Peter.
So what is the logic behind foreign keys? Why use them?


Constraints. When using, for example, the InnoDB engine in MySQL,  
you

can set foreign key fields on tables. These ensure that your record
will always be bound to a proper record in the connected table - so,
for instance, you won't find yourself in the situation that you have
deleted a record from table1 but table2 still references the table1
record. Also, they're very useful for tying models together
automatically, as you can deduce relationships between models by
foreign keys, for instance (this is simplified but covers a lot of
cases).

Regards
Peter

--

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51


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




Karl DeSaulniers
Design Drumm
http://designdrumm.com


Karl I am finding it hard to grasp why you are  doing things this  
way why

not  have


A products table  with enums  for size/color?  Then on the edit  
page, you
can  read the  product tables schema to get the enum options  and  
explode

them in PHP...



Aka

$tData=$db->QuerryToArray("desc products");
$tSizes = explode(",",$tData['Sizes']);
$tColors = explode(",",$tData['Colors']);
$objSmarty->assign("AvailableColors",$tColors);
$objSmarty->assign("AvailableSizes",$tSizes);


Then in the  post system...

$ProductSettings=$db-QueryToArray("select * from products where
id='{$this->CurrentProductID}'");
$NewProductSettings=$this->GetProductEditInputs();

Foreach ($NewProductSettings as $Setting=>$Value)
  If($ProdcutSettings[$Setting] !== $Value)
$tUpdates[$Setting]=$Value;
Return
($db->UpdateFromArray("products",$tUpdates,"id='{$this- 
>CurrentProductID}'")

)? TRUE : FALSE;

Since the  table would be using an ENUM or SET the  column size is  
very

small  but also very granular.


I think breaking the tables apart is actually more complicated  
than its

worth for your needs.



Karl DeSaulniers
Design Drumm
http://designdrumm.com


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



Karl DeSaulniers
Design