php-general Digest 5 Jul 2013 17:10:43 -0000 Issue 8285

Topics (messages 321528 through 321544):

PHP 5.4.17 released!
        321528 by: Stas Malyshev

Re: Web dev, DB and "proper db design".
        321529 by: Tony Marston
        321530 by: Lester Caine
        321531 by: Tony Marston
        321532 by: Lester Caine

Can this work?
        321533 by: Karl-Arne Gjersøyen
        321534 by: Stuart Dallas
        321535 by: Tedd Sperling
        321536 by: Karl-Arne Gjersøyen
        321537 by: Karl-Arne Gjersøyen
        321538 by: Stuart Dallas
        321539 by: Karl-Arne Gjersøyen
        321540 by: Stuart Dallas
        321541 by: Ashley Sheridan

Hmm.. I got NULL here. Why?
        321542 by: Karl-Arne Gjersøyen
        321543 by: Karl-Arne Gjersøyen

strlen ?
        321544 by: Jim Giner

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Hello!

The PHP development team announces the immediate availability of PHP
5.4.17. About 20 bugs were fixed. All users of PHP are encouraged to
upgrade to this release.

For source downloads of PHP 5.4.17 please visit our
downloads page: http://www.php.net/downloads.php

Windows binaries can be found on windows.php.net/download/

The list of changes are recorded in the ChangeLog:
http://www.php.net/ChangeLog-5.php#5.4.17

Stanislav Malyshev
PHP 5.4 Release Master

--- End Message ---
--- Begin Message --- "Tamara Temple" wrote in message news:557a0092-2b7d-49f4-ae3d-593968dd3...@gmail.com...


On Jul 4, 2013, at 8:02 AM, Jim Giner <jim.gi...@albanyhandball.com> wrote:

On 7/4/2013 6:42 AM, Richard Quadling wrote:
Hi.

I've just had a conversation regarding DB, foreign keys and their benefits.

I was told "I've never worked on a web application where foreign keys were
used in the database".

As someone who has spent 25 years working on accounting/epos systems on MS
SQL Server (yep, windows) and now in a web environment and hearing the
above, ... well, ... slightly concerned.

So, in the biggest broadest terms, what do you lot do?

DBs with no foreign keys (constrainted or not).
ORM builders with manual definition of relationships between the tables.
Inline SQL where you have to just remember all the relationships.
Views for simple lookups? How do you handle updatable views (does mysql
support them?)
etc.

Is there a difference in those in 'startups' and web only situations, or
those doing more traditional development (split that as you like - I'm just
trying to get an understanding and not go off on one!).

No definitive answers, and I hope I get some wide experiences here.

Thanks for looking.

Richard.

I"m going to guess that your source of such drivel never learned about such things. Probably thinks that a 'key' has to be defined as such in the db, whereas we know what a FK really is.

Don't worry. As a former big iron guy and then a c/s guy and now a (new) web guy, things haven't changed.

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


So, like Jim, I'm just going to speculate your correspondent has never actually designed anything very interesting. I can't really imagine how one does not use foreign keys, unless one does the entire relationship mapping between tables in the source… what
a waste that would be.

"Tamara Temple" wrote in message news:557a0092-2b7d-49f4-ae3d-593968dd3...@gmail.com...


On Jul 4, 2013, at 8:02 AM, Jim Giner <jim.gi...@albanyhandball.com> wrote:

On 7/4/2013 6:42 AM, Richard Quadling wrote:
Hi.

I've just had a conversation regarding DB, foreign keys and their benefits.

I was told "I've never worked on a web application where foreign keys were
used in the database".

As someone who has spent 25 years working on accounting/epos systems on MS
SQL Server (yep, windows) and now in a web environment and hearing the
above, ... well, ... slightly concerned.

So, in the biggest broadest terms, what do you lot do?

DBs with no foreign keys (constrainted or not).
ORM builders with manual definition of relationships between the tables.
Inline SQL where you have to just remember all the relationships.
Views for simple lookups? How do you handle updatable views (does mysql
support them?)
etc.

Is there a difference in those in 'startups' and web only situations, or
those doing more traditional development (split that as you like - I'm just
trying to get an understanding and not go off on one!).

No definitive answers, and I hope I get some wide experiences here.

Thanks for looking.

Richard.

I"m going to guess that your source of such drivel never learned about such things. Probably thinks that a 'key' has to be defined as such in the db, whereas we know what a FK really is.

Don't worry. As a former big iron guy and then a c/s guy and now a (new) web guy, things haven't changed.

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


So, like Jim, I'm just going to speculate your correspondent has never actually designed anything very interesting. I can't really imagine how one does not use foreign keys, unless one does the entire relationship mapping between tables in the source… what a
waste that would be.=

I was designing and building database applications before relational databases became popular, and in those old hierarchical and network databases there were no such things as foreign key constraints. Database integrity had to be handled in the code, which is what we did. When I started working with relational databases there were features of the language, such as FK constraints, which were rarely used even though they were there. When I started working on web applications the predominant database was MySQL, and the vast majority of ISPs would only offer MyISAM and not Innodb, and MyISAM does not support FK constraints.

There are some programmers who complain that without foreign keys being defined in the database, how do you recognise relationships to build into SELECT statements? Simple. Every primary key is in the format ‘<tablename>_id’, so if you see this format in a table, and <tablename> is a different table, then it’s a foreign key. This is actually easier to identify than having to look in a separate place.

Remember that there is a difference between a foreign key and a foreign key constraint. Foreign keys can exist without constraints, so saying that you cannot use a field as a foreign key in a SELECT statement without having a constraint defined in the database is just plain wrong.

--
Tony Marston

http://www.tonymarston.net
http://www.radicore.org
--- End Message ---
--- Begin Message ---
Tony Marston wrote:
I was designing and building database applications before relational databases
became popular, and in those old hierarchical and network databases there were
no such things as foreign key constraints. Database integrity had to be handled
in the code, which is what we did. When I started working with relational
databases there were features of the language, such as FK constraints, which
were rarely used even though they were there. When I started working on web
applications the predominant database was MySQL, and the vast majority of ISPs
would only offer MyISAM and not Innodb, and MyISAM does not support FK 
constraints.

This was my point about MySQL ... what database were you using before MySQL came along?

There are some programmers who complain that without foreign keys being defined
in the database, how do you recognise relationships to build into SELECT
statements? Simple. Every primary key is in the format ‘<tablename>_id’, so if
you see this format in a table, and <tablename> is a different table, then it’s
a foreign key. This is actually easier to identify than having to look in a
separate place.

Remember that there is a difference between a foreign key and a foreign key
constraint. Foreign keys can exist without constraints, so saying that you
cannot use a field as a foreign key in a SELECT statement without having a
constraint defined in the database is just plain wrong.

Certainly in some instances then managing everything in code makes sense. Cross database working for instance. So everything works the same for each engine. But the main advantage of adding constraints in the database is that it protects the foreign entries from being deleted while they are still in use. One of the problems I end up having to recover is where a hickup in the PHP or user side of things has deleted an entry, or more usually the whole table! In this case a properly implemented constraint would have prevented the problem. While using a constraint to manage the deletion of detail elements has a place in reducing traffic between program and datbase, the protection of detail elements is the more useful reason for maintaining them.

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

--- End Message ---
--- Begin Message ---
"Lester Caine"  wrote in message news:51d6987c.9050...@lsces.co.uk...

Tony Marston wrote:
I was designing and building database applications before relational databases became popular, and in those old hierarchical and network databases there were no such things as foreign key constraints. Database integrity had to be handled
in the code, which is what we did. When I started working with relational
databases there were features of the language, such as FK constraints, which were rarely used even though they were there. When I started working on web applications the predominant database was MySQL, and the vast majority of ISPs would only offer MyISAM and not Innodb, and MyISAM does not support FK constraints.

This was my point about MySQL ... what database were you using before MySQL came along?

I used ORACLE and SOLID, and before that Hewlett Packard's IMAGE (network DB) and Data General's INFOS (hierarchical DB).

There are some programmers who complain that without foreign keys being defined
in the database, how do you recognise relationships to build into SELECT
statements? Simple. Every primary key is in the format ‘<tablename>_id’, so if you see this format in a table, and <tablename> is a different table, then it’s a foreign key. This is actually easier to identify than having to look in a
separate place.

Remember that there is a difference between a foreign key and a foreign key constraint. Foreign keys can exist without constraints, so saying that you cannot use a field as a foreign key in a SELECT statement without having a
constraint defined in the database is just plain wrong.

Certainly in some instances then managing everything in code makes sense. Cross database working for instance. So everything works the same for each engine. But the main advantage of adding constraints in the database is that it protects the foreign entries from being deleted while they are still in use. One of the problems I end up having to recover is where a hickup in the PHP or user side of things has deleted an entry, or more usually the whole table! In this case a properly implemented constraint would have prevented the problem. While using a constraint to manage the deletion of detail elements has a place in reducing traffic between program and database, the protection of detail elements is the more useful reason for maintaining them.

In my framework I define relationships and any constraints in my data dictionary, and these are enforced by a standard module in the framework. This means that any RESTRICTED constraints can be detected in the code without executing a DELETE and having it abort.

--
Tony Marston

http://www.tonymarston.net
http://www.radicore.org
--- End Message ---
--- Begin Message ---
Tony Marston wrote:
Certainly in some instances then managing everything in code makes sense.
Cross database working for instance. So everything works the same for each
engine. But the main advantage of adding constraints in the database is that
it protects the foreign entries from being deleted while they are still in
use. One of the problems I end up having to recover is where a hickup in the
PHP or user side of things has deleted an entry, or more usually the whole
table! In this case a properly implemented constraint would have prevented the
problem. While using a constraint to manage the deletion of detail elements
has a place in reducing traffic between program and database, the protection
of detail elements is the more useful reason for maintaining them.

In my framework I define relationships and any constraints in my data
dictionary, and these are enforced by a standard module in the framework. This
means that any RESTRICTED constraints can be detected in the code without
executing a DELETE and having it abort.

My own database management framework pre-dates PHP switching from dBase originally, to Interbase and then Firebird as it was open sourced (just as we had paid for a large number of Interbase licenses :( ). So I've grown up using the tools in the database, but have to back pedal some of the time where a cross database solution is required. I'm much more comfortable with getting the database to manage things and will often drop triggers in rather than coding that in PHP. So "proper db design"is probably still geared around what we are used to rather than any had and fast rules?

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

--- End Message ---
--- Begin Message ---
Hello. I have a form in HTML/PHP with for loops that generate a selected
list like this:
for($i = 1; $i< 25;$i++ ){
 <option value="<?php echo "$i"; ?><?php echo "$i"; ?></option>
}

The lists look like this:

<form action="index.php
<view-source:http://localhost/%7Ekarl/kasen/io/kp/index.php>"
method="post"><select name="valgt_dynamit_polse_1-25kg"><option
value="1-25" selected="selected">1-25</option><option
value="1">1</option><option value="2">2</option><option
value="3">3</option><option value="4">4</option><option
value="5">5</option><option value="6">6</option><option
value="7">7</option><option value="8">8</option><option
value="9">9</option><option value="10">10</option><option
value="11">11</option><option value="12">12</option><option
value="13">13</option><option value="14">14</option><option
value="15">15</option><option value="16">16</option><option
value="17">17</option><option value="18">18</option><option
value="19">19</option><option value="20">20</option><option
value="21">21</option><option value="22">22</option><option
value="23">23</option><option value="24">24</option><option
value="25">25</option></select> Kg&nbsp;<select
name="valgt_dynamit_polse_26-50kg"><option value="26-50"
selected="selected">26-50</option><option
value="26">26</option><option value="27">27</option><option
value="28">28</option><option value="29">29</option><option
value="30">30</option><option value="31">31</option><option
value="32">32</option><option value="33">33</option><option
value="34">34</option><option value="35">35</option><option
value="36">36</option><option value="37">37</option><option
value="38">38</option><option value="39">39</option><option
value="40">40</option><option value="41">41</option><option
value="42">42</option><option value="43">43</option><option
value="44">44</option><option value="45">45</option><option
value="46">46</option><option value="47">47</option><option
value="48">48</option><option value="49">49</option><option
value="50">50</option></select> Kg&nbsp;

What I try to do with it is to register the selected value and do something
with it. The lists is weight in KG. I hope to select only one value between
1-25kg OR 26-50kg. I don't know if this is possible? What do you think?

Thanks.
Karl

--- End Message ---
--- Begin Message ---
On 5 Jul 2013, at 14:56, Karl-Arne Gjersøyen <karlar...@gmail.com> wrote:

> Hello. I have a form in HTML/PHP with for loops that generate a selected
> list like this:
> for($i = 1; $i< 25;$i++ ){
> <option value="<?php echo "$i"; ?><?php echo "$i"; ?></option>
> }
> 
> The lists look like this:
> 
> <form action="index.php
> <view-source:http://localhost/%7Ekarl/kasen/io/kp/index.php>"
> method="post"><select name="valgt_dynamit_polse_1-25kg"><option
> value="1-25" selected="selected">1-25</option><option
> value="1">1</option><option value="2">2</option><option
> value="3">3</option><option value="4">4</option><option
> value="5">5</option><option value="6">6</option><option
> value="7">7</option><option value="8">8</option><option
> value="9">9</option><option value="10">10</option><option
> value="11">11</option><option value="12">12</option><option
> value="13">13</option><option value="14">14</option><option
> value="15">15</option><option value="16">16</option><option
> value="17">17</option><option value="18">18</option><option
> value="19">19</option><option value="20">20</option><option
> value="21">21</option><option value="22">22</option><option
> value="23">23</option><option value="24">24</option><option
> value="25">25</option></select> Kg&nbsp;<select
> name="valgt_dynamit_polse_26-50kg"><option value="26-50"
> selected="selected">26-50</option><option
> value="26">26</option><option value="27">27</option><option
> value="28">28</option><option value="29">29</option><option
> value="30">30</option><option value="31">31</option><option
> value="32">32</option><option value="33">33</option><option
> value="34">34</option><option value="35">35</option><option
> value="36">36</option><option value="37">37</option><option
> value="38">38</option><option value="39">39</option><option
> value="40">40</option><option value="41">41</option><option
> value="42">42</option><option value="43">43</option><option
> value="44">44</option><option value="45">45</option><option
> value="46">46</option><option value="47">47</option><option
> value="48">48</option><option value="49">49</option><option
> value="50">50</option></select> Kg&nbsp;
> 
> What I try to do with it is to register the selected value and do something
> with it. The lists is weight in KG. I hope to select only one value between
> 1-25kg OR 26-50kg. I don't know if this is possible? What do you think?

If the range of acceptable values is 1-50, why do you have two select fields 
instead of one?

<?php
for ($i = 1; $i <= 50; $i++) {
?>
<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
<?php
}
?>

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

--- End Message ---
--- Begin Message ---
On Jul 5, 2013, at 9:56 AM, Karl-Arne Gjersøyen <karlar...@gmail.com> wrote:
> The lists look like this:
> 
> <form action="index.php
> <view-source:http://localhost/%7Ekarl/kasen/io/kp/index.php>"
> method="post"><select name="valgt_dynamit_polse_1-25kg"><option
> value="1-25" selected="selected">1-25</option><option
> value="1">1</option><option value="2">2</option><option


Review this:

http://sperling.com/php/select/

Also, omit 'multiple' in the select statement.

Other than that, the demo shows how to gather the information you want.

Cheers,

tedd

_____________________
tedd.sperl...@gmail.com
http://sperling.com

--- End Message ---
--- Begin Message ---
2013/7/5 Stuart Dallas <stu...@3ft9.com>

> On 5 Jul 2013, at 14:56, Karl-Arne Gjersøyen <karlar...@gmail.com> wrote:
>
> > Hello. I have a form in HTML/PHP with for loops that generate a selected
> > list like this:
> > for($i = 1; $i< 25;$i++ ){
> > <option value="<?php echo "$i"; ?><?php echo "$i"; ?></option>
> > }
> >
> > The lists look like this:
> >
> > <form action="index.php
> > <view-source:http://localhost/%7Ekarl/kasen/io/kp/index.php>"
> > method="post"><select name="valgt_dynamit_polse_1-25kg"><option
> > value="1-25" selected="selected">1-25</option><option
> > value="1">1</option><option value="2">2</option><option
> > value="3">3</option><option value="4">4</option><option
> > value="5">5</option><option value="6">6</option><option
> > value="7">7</option><option value="8">8</option><option
> > value="9">9</option><option value="10">10</option><option
> > value="11">11</option><option value="12">12</option><option
> > value="13">13</option><option value="14">14</option><option
> > value="15">15</option><option value="16">16</option><option
> > value="17">17</option><option value="18">18</option><option
> > value="19">19</option><option value="20">20</option><option
> > value="21">21</option><option value="22">22</option><option
> > value="23">23</option><option value="24">24</option><option
> > value="25">25</option></select> Kg&nbsp;<select
> > name="valgt_dynamit_polse_26-50kg"><option value="26-50"
> > selected="selected">26-50</option><option
> > value="26">26</option><option value="27">27</option><option
> > value="28">28</option><option value="29">29</option><option
> > value="30">30</option><option value="31">31</option><option
> > value="32">32</option><option value="33">33</option><option
> > value="34">34</option><option value="35">35</option><option
> > value="36">36</option><option value="37">37</option><option
> > value="38">38</option><option value="39">39</option><option
> > value="40">40</option><option value="41">41</option><option
> > value="42">42</option><option value="43">43</option><option
> > value="44">44</option><option value="45">45</option><option
> > value="46">46</option><option value="47">47</option><option
> > value="48">48</option><option value="49">49</option><option
> > value="50">50</option></select> Kg&nbsp;
> >
> > What I try to do with it is to register the selected value and do
> something
> > with it. The lists is weight in KG. I hope to select only one value
> between
> > 1-25kg OR 26-50kg. I don't know if this is possible? What do you think?
>
> If the range of acceptable values is 1-50, why do you have two select
> fields instead of one?


The select list has values between 1 and 200. Therefore I split it up for
every 25th value.

Karl

--- End Message ---
--- Begin Message ---
2013/7/5 Tedd Sperling <tedd.sperl...@gmail.com>

> On Jul 5, 2013, at 9:56 AM, Karl-Arne Gjersøyen <karlar...@gmail.com>
> wrote:
> > The lists look like this:
> >
> > <form action="index.php
> > <view-source:http://localhost/%7Ekarl/kasen/io/kp/index.php>"
> > method="post"><select name="valgt_dynamit_polse_1-25kg"><option
> > value="1-25" selected="selected">1-25</option><option
> > value="1">1</option><option value="2">2</option><option
>
>
> Review this:
>
> http://sperling.com/php/select/
>
> Also, omit 'multiple' in the select statement.
>
> Other than that, the demo shows how to gather the information you want.
>
> Cheers,
>
> tedd
>
> _____________________
> tedd.sperl...@gmail.com
> http://sperling.com


Thank you very much! <http://www.karl-arne.name/>

--- End Message ---
--- Begin Message ---
On 5 Jul 2013, at 15:05, Karl-Arne Gjersøyen <karlar...@gmail.com> wrote:

> 2013/7/5 Stuart Dallas <stu...@3ft9.com>
> 
>> On 5 Jul 2013, at 14:56, Karl-Arne Gjersøyen <karlar...@gmail.com> wrote:
>> 
>>> Hello. I have a form in HTML/PHP with for loops that generate a selected
>>> list like this:
>>> for($i = 1; $i< 25;$i++ ){
>>> <option value="<?php echo "$i"; ?><?php echo "$i"; ?></option>
>>> }
>>> 
>>> The lists look like this:
>>> 
>>> <form action="index.php
>>> <view-source:http://localhost/%7Ekarl/kasen/io/kp/index.php>"
>>> method="post"><select name="valgt_dynamit_polse_1-25kg"><option
>>> value="1-25" selected="selected">1-25</option><option
>>> value="1">1</option><option value="2">2</option><option
>>> value="3">3</option><option value="4">4</option><option
>>> value="5">5</option><option value="6">6</option><option
>>> value="7">7</option><option value="8">8</option><option
>>> value="9">9</option><option value="10">10</option><option
>>> value="11">11</option><option value="12">12</option><option
>>> value="13">13</option><option value="14">14</option><option
>>> value="15">15</option><option value="16">16</option><option
>>> value="17">17</option><option value="18">18</option><option
>>> value="19">19</option><option value="20">20</option><option
>>> value="21">21</option><option value="22">22</option><option
>>> value="23">23</option><option value="24">24</option><option
>>> value="25">25</option></select> Kg&nbsp;<select
>>> name="valgt_dynamit_polse_26-50kg"><option value="26-50"
>>> selected="selected">26-50</option><option
>>> value="26">26</option><option value="27">27</option><option
>>> value="28">28</option><option value="29">29</option><option
>>> value="30">30</option><option value="31">31</option><option
>>> value="32">32</option><option value="33">33</option><option
>>> value="34">34</option><option value="35">35</option><option
>>> value="36">36</option><option value="37">37</option><option
>>> value="38">38</option><option value="39">39</option><option
>>> value="40">40</option><option value="41">41</option><option
>>> value="42">42</option><option value="43">43</option><option
>>> value="44">44</option><option value="45">45</option><option
>>> value="46">46</option><option value="47">47</option><option
>>> value="48">48</option><option value="49">49</option><option
>>> value="50">50</option></select> Kg&nbsp;
>>> 
>>> What I try to do with it is to register the selected value and do
>> something
>>> with it. The lists is weight in KG. I hope to select only one value
>> between
>>> 1-25kg OR 26-50kg. I don't know if this is possible? What do you think?
>> 
>> If the range of acceptable values is 1-50, why do you have two select
>> fields instead of one?
> 
> The select list has values between 1 and 200. Therefore I split it up for
> every 25th value.

Ok, but why?

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

--- End Message ---
--- Begin Message ---
2013/7/5 Stuart Dallas <stu...@3ft9.com>

> On 5 Jul 2013, at 15:05, Karl-Arne Gjersøyen <karlar...@gmail.com> wrote:
>
> > 2013/7/5 Stuart Dallas <stu...@3ft9.com>
> >
> >> On 5 Jul 2013, at 14:56, Karl-Arne Gjersøyen <karlar...@gmail.com>
> wrote:
> >>
> >>> Hello. I have a form in HTML/PHP with for loops that generate a
> selected
> >>> list like this:
> >>> for($i = 1; $i< 25;$i++ ){
> >>> <option value="<?php echo "$i"; ?><?php echo "$i"; ?></option>
> >>> }
> >>>
> >>> The lists look like this:
> >>>
> >>> <form action="index.php
> >>> <view-source:http://localhost/%7Ekarl/kasen/io/kp/index.php>"
> >>> method="post"><select name="valgt_dynamit_polse_1-25kg"><option
> >>> value="1-25" selected="selected">1-25</option><option
> >>> value="1">1</option><option value="2">2</option><option
> >>> value="3">3</option><option value="4">4</option><option
> >>> value="5">5</option><option value="6">6</option><option
> >>> value="7">7</option><option value="8">8</option><option
> >>> value="9">9</option><option value="10">10</option><option
> >>> value="11">11</option><option value="12">12</option><option
> >>> value="13">13</option><option value="14">14</option><option
> >>> value="15">15</option><option value="16">16</option><option
> >>> value="17">17</option><option value="18">18</option><option
> >>> value="19">19</option><option value="20">20</option><option
> >>> value="21">21</option><option value="22">22</option><option
> >>> value="23">23</option><option value="24">24</option><option
> >>> value="25">25</option></select> Kg&nbsp;<select
> >>> name="valgt_dynamit_polse_26-50kg"><option value="26-50"
> >>> selected="selected">26-50</option><option
> >>> value="26">26</option><option value="27">27</option><option
> >>> value="28">28</option><option value="29">29</option><option
> >>> value="30">30</option><option value="31">31</option><option
> >>> value="32">32</option><option value="33">33</option><option
> >>> value="34">34</option><option value="35">35</option><option
> >>> value="36">36</option><option value="37">37</option><option
> >>> value="38">38</option><option value="39">39</option><option
> >>> value="40">40</option><option value="41">41</option><option
> >>> value="42">42</option><option value="43">43</option><option
> >>> value="44">44</option><option value="45">45</option><option
> >>> value="46">46</option><option value="47">47</option><option
> >>> value="48">48</option><option value="49">49</option><option
> >>> value="50">50</option></select> Kg&nbsp;
> >>>
> >>> What I try to do with it is to register the selected value and do
> >> something
> >>> with it. The lists is weight in KG. I hope to select only one value
> >> between
> >>> 1-25kg OR 26-50kg. I don't know if this is possible? What do you think?
> >>
> >> If the range of acceptable values is 1-50, why do you have two select
> >> fields instead of one?
> >
> > The select list has values between 1 and 200. Therefore I split it up for
> > every 25th value.
>
> Ok, but why?


I will use my application on iPad and find it more easy to use multiple
select lists than one big list with all 200 values at once.

Karl

--- End Message ---
--- Begin Message ---
On 5 Jul 2013, at 15:24, Karl-Arne Gjersøyen <karlar...@gmail.com> wrote:

> 2013/7/5 Stuart Dallas <stu...@3ft9.com>
> 
>> On 5 Jul 2013, at 15:05, Karl-Arne Gjersøyen <karlar...@gmail.com> wrote:
>> 
>>> 2013/7/5 Stuart Dallas <stu...@3ft9.com>
>>> 
>>>> On 5 Jul 2013, at 14:56, Karl-Arne Gjersøyen <karlar...@gmail.com>
>> wrote:
>>>> 
>>>>> Hello. I have a form in HTML/PHP with for loops that generate a
>> selected
>>>>> list like this:
>>>>> for($i = 1; $i< 25;$i++ ){
>>>>> <option value="<?php echo "$i"; ?><?php echo "$i"; ?></option>
>>>>> }
>>>>> 
>>>>> The lists look like this:
>>>>> 
>>>>> <form action="index.php
>>>>> <view-source:http://localhost/%7Ekarl/kasen/io/kp/index.php>"
>>>>> method="post"><select name="valgt_dynamit_polse_1-25kg"><option
>>>>> value="1-25" selected="selected">1-25</option><option
>>>>> value="1">1</option><option value="2">2</option><option
>>>>> value="3">3</option><option value="4">4</option><option
>>>>> value="5">5</option><option value="6">6</option><option
>>>>> value="7">7</option><option value="8">8</option><option
>>>>> value="9">9</option><option value="10">10</option><option
>>>>> value="11">11</option><option value="12">12</option><option
>>>>> value="13">13</option><option value="14">14</option><option
>>>>> value="15">15</option><option value="16">16</option><option
>>>>> value="17">17</option><option value="18">18</option><option
>>>>> value="19">19</option><option value="20">20</option><option
>>>>> value="21">21</option><option value="22">22</option><option
>>>>> value="23">23</option><option value="24">24</option><option
>>>>> value="25">25</option></select> Kg&nbsp;<select
>>>>> name="valgt_dynamit_polse_26-50kg"><option value="26-50"
>>>>> selected="selected">26-50</option><option
>>>>> value="26">26</option><option value="27">27</option><option
>>>>> value="28">28</option><option value="29">29</option><option
>>>>> value="30">30</option><option value="31">31</option><option
>>>>> value="32">32</option><option value="33">33</option><option
>>>>> value="34">34</option><option value="35">35</option><option
>>>>> value="36">36</option><option value="37">37</option><option
>>>>> value="38">38</option><option value="39">39</option><option
>>>>> value="40">40</option><option value="41">41</option><option
>>>>> value="42">42</option><option value="43">43</option><option
>>>>> value="44">44</option><option value="45">45</option><option
>>>>> value="46">46</option><option value="47">47</option><option
>>>>> value="48">48</option><option value="49">49</option><option
>>>>> value="50">50</option></select> Kg&nbsp;
>>>>> 
>>>>> What I try to do with it is to register the selected value and do
>>>> something
>>>>> with it. The lists is weight in KG. I hope to select only one value
>>>> between
>>>>> 1-25kg OR 26-50kg. I don't know if this is possible? What do you think?
>>>> 
>>>> If the range of acceptable values is 1-50, why do you have two select
>>>> fields instead of one?
>>> 
>>> The select list has values between 1 and 200. Therefore I split it up for
>>> every 25th value.
>> 
>> Ok, but why?
> 
> 
> I will use my application on iPad and find it more easy to use multiple
> select lists than one big list with all 200 values at once.

In that case I would recommend using a text input field and validate it with 
javascript and then validate it again on the server-side with PHP. With 
multiple select fields the only way you'll know which one the user (i.e. you) 
meant is by resetting the others to an empty value whenever one of them changes.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

--- End Message ---
--- Begin Message ---
Can't you just use a number field, which is a hell of a lot easier (especially 
on an iPad) to use than a bunch of select lists.

"Karl-Arne Gjersøyen" <karlar...@gmail.com> wrote:

>2013/7/5 Stuart Dallas <stu...@3ft9.com>
>
>> On 5 Jul 2013, at 15:05, Karl-Arne Gjersøyen <karlar...@gmail.com>
>wrote:
>>
>> > 2013/7/5 Stuart Dallas <stu...@3ft9.com>
>> >
>> >> On 5 Jul 2013, at 14:56, Karl-Arne Gjersøyen <karlar...@gmail.com>
>> wrote:
>> >>
>> >>> Hello. I have a form in HTML/PHP with for loops that generate a
>> selected
>> >>> list like this:
>> >>> for($i = 1; $i< 25;$i++ ){
>> >>> <option value="<?php echo "$i"; ?><?php echo "$i"; ?></option>
>> >>> }
>> >>>
>> >>> The lists look like this:
>> >>>
>> >>> <form action="index.php
>> >>> <view-source:http://localhost/%7Ekarl/kasen/io/kp/index.php>"
>> >>> method="post"><select name="valgt_dynamit_polse_1-25kg"><option
>> >>> value="1-25" selected="selected">1-25</option><option
>> >>> value="1">1</option><option value="2">2</option><option
>> >>> value="3">3</option><option value="4">4</option><option
>> >>> value="5">5</option><option value="6">6</option><option
>> >>> value="7">7</option><option value="8">8</option><option
>> >>> value="9">9</option><option value="10">10</option><option
>> >>> value="11">11</option><option value="12">12</option><option
>> >>> value="13">13</option><option value="14">14</option><option
>> >>> value="15">15</option><option value="16">16</option><option
>> >>> value="17">17</option><option value="18">18</option><option
>> >>> value="19">19</option><option value="20">20</option><option
>> >>> value="21">21</option><option value="22">22</option><option
>> >>> value="23">23</option><option value="24">24</option><option
>> >>> value="25">25</option></select> Kg&nbsp;<select
>> >>> name="valgt_dynamit_polse_26-50kg"><option value="26-50"
>> >>> selected="selected">26-50</option><option
>> >>> value="26">26</option><option value="27">27</option><option
>> >>> value="28">28</option><option value="29">29</option><option
>> >>> value="30">30</option><option value="31">31</option><option
>> >>> value="32">32</option><option value="33">33</option><option
>> >>> value="34">34</option><option value="35">35</option><option
>> >>> value="36">36</option><option value="37">37</option><option
>> >>> value="38">38</option><option value="39">39</option><option
>> >>> value="40">40</option><option value="41">41</option><option
>> >>> value="42">42</option><option value="43">43</option><option
>> >>> value="44">44</option><option value="45">45</option><option
>> >>> value="46">46</option><option value="47">47</option><option
>> >>> value="48">48</option><option value="49">49</option><option
>> >>> value="50">50</option></select> Kg&nbsp;
>> >>>
>> >>> What I try to do with it is to register the selected value and do
>> >> something
>> >>> with it. The lists is weight in KG. I hope to select only one
>value
>> >> between
>> >>> 1-25kg OR 26-50kg. I don't know if this is possible? What do you
>think?
>> >>
>> >> If the range of acceptable values is 1-50, why do you have two
>select
>> >> fields instead of one?
>> >
>> > The select list has values between 1 and 200. Therefore I split it
>up for
>> > every 25th value.
>>
>> Ok, but why?
>
>
>I will use my application on iPad and find it more easy to use multiple
>select lists than one big list with all 200 values at once.
>
>Karl

Can't you just use a number field, which is a hell of a lot easier (especially 
on an iPad) to use than a bunch of select lists.
Thanks,
Ash

--- End Message ---
--- Begin Message ---
My PHP Source
=============
<?php
    include('../../tilkobling.php');
    $sql = "SELECT kg_pa_lager FROM dynamit WHERE valgt_lager =
'$valgt_lager' AND varenr = '$varenr'";
    $resultat = mysql_query($sql, $tilkobling) or die(mysql_error());
    while($rad = mysql_fetch_array($resultat)){
        $kg_pa_lager = $rad['kg_pa_lager'];
        echo "$kg_pa_lager";
        }
        var_dump($sql);
        echo "<br />";
        var_dump($kg_pa_lager);
    ?>

My var_dump() value;
==================
string(84) "SELECT kg_pa_lager FROM dynamit WHERE valgt_lager = 'Tengs' AND
varenr = 'EDY22X180'"
NULL

My Database table:
===============
mysql> SELECT * FROM dynamit;
+------------+-------------+---------------+--------+-------+----------+------------+-------------+
| leverandor | valgt_lager | type          | dim_mm | un_nr | varenavn |
varenr     | kg_pa_lager |
+------------+-------------+---------------+--------+-------+----------+------------+-------------+
| Orica      | Tengs       | Papirpatroner | 22x180 | 0081  | Dynamit  |
EDY22X180K | 100         |
| Orica      | Tengs       | Papirpatroner | 25x180 | 0081  | Dynamit  |
EDY25X180  | 100         |
| Orica      | Tengs       | Plastpølse   | 45x540 | 0081  | Dynamit  |
EDY45X540  | 100         |
+------------+-------------+---------------+--------+-------+----------+------------+-------------+
3 rows in set (0.00 sec)

mysql>

The Problem:
==========
If I do this:
$sql = "SELECT kg_pa_lager FROM dynamit WHERE valgt_lager = '$valgt_lager'";
I got 100100100 for kg_pa_lager

But if I do this:
$sql = "SELECT kg_pa_lager FROM dynamit WHERE valgt_lager = '$valgt_lager'
AND varenr = '$varenr'";
I got NULL.

Look at varenr = EDY22X180 in the select where and that it is in the table
under varenr.
But why is kg_pa_lager NULL?

This is strange to me but I guess you know why?
Thanks for your advice.

Karl

--- End Message ---
--- Begin Message ---
My PHP Source
=============
<?php
    include('../../tilkobling.php');
    $sql = "SELECT kg_pa_lager FROM dynamit WHERE valgt_lager =
'$valgt_lager' AND varenr = '$varenr'";
    $resultat = mysql_query($sql, $tilkobling) or die(mysql_error());
    while($rad = mysql_fetch_array($resultat)){
        $kg_pa_lager = $rad['kg_pa_lager'];
        echo "$kg_pa_lager";
        }
        var_dump($sql);
        echo "<br />";
        var_dump($kg_pa_lager);
    ?>

My var_dump() value;
==================
string(84) "SELECT kg_pa_lager FROM dynamit WHERE valgt_lager = 'Tengs' AND
varenr = 'EDY22X180'"
NULL

My Database table:
===============
mysql> SELECT * FROM dynamit;
+------------+-------------+---------------+--------+-------+----------+------------+-------------+
| leverandor | valgt_lager | type          | dim_mm | un_nr | varenavn |
varenr     | kg_pa_lager |
+------------+-------------+---------------+--------+-------+----------+------------+-------------+
| Orica      | Tengs       | Papirpatroner | 22x180 | 0081  | Dynamit  |
EDY22X180K | 100         |
| Orica      | Tengs       | Papirpatroner | 25x180 | 0081  | Dynamit  |
EDY25X180  | 100         |
| Orica      | Tengs       | Plastpølse   | 45x540 | 0081  | Dynamit  |
EDY45X540  | 100         |
+------------+-------------+---------------+--------+-------+----------+------------+-------------+
3 rows in set (0.00 sec)

mysql>

The Problem:
==========
If I do this:
$sql = "SELECT kg_pa_lager FROM dynamit WHERE valgt_lager = '$valgt_lager'";
I got 100100100 for kg_pa_lager

But if I do this:
$sql = "SELECT kg_pa_lager FROM dynamit WHERE valgt_lager = '$valgt_lager'
AND varenr = '$varenr'";
I got NULL.

Look at varenr = EDY22X180 in the select where and that it is in the table
under varenr.
But why is kg_pa_lager NULL?

This is strange to me but I guess you know why?
Thanks for your advice.

Karl

I got the solution. I had forget to write "K" at end of the serial number.
Now it is OK.
Karl

--- End Message ---
--- Begin Message --- Trying to manage line breaks in some output I'm generating and using strlen to measure the lengths of the strings I'm printing. Discovered something strange (to me!) in that strlen is returning +1 more than it should.

The strings are from a query of my database - simple name fields. But everyone of them is coming back with a length that is one more than I see.

Ex.

Mike Hall  comes back as 10, not 9
F.B. comes back as 5, not 4.

I've looked at my data and counted the chars - there is no extra space at the beginning or end in my table.

Anyone have an explanation?

--- End Message ---

Reply via email to