FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Syntax for adding text prefix to a post variable?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Syntax for adding text prefix to a post variable? [message #170258 is a reply to message #170257] Sat, 23 October 2010 08:46 Go to previous messageGo to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma:
Senior Member
GarryJones wrote:

> A user can mark each item as "10% paid" and/or "90% paid".

They could mark *one* item as *both* 10% and 90% paid? Sounds like an error
in your business logic to me.

> Each item has a unique number in a mysql database.
>
> In the php form I give each checkbox a unique number. Every item has 2
> checkboxes.
>
> For instance item 289474 has two checkboxes, I prefix these with 10
> and 90 so its two checkboxes are called "10289474" and "90289474". So
> far so good, I can see these are correct in the html code.
>
> Then when the user presses OK I need to update what has and has not
> been checkedboxed as paid.
>
> If checkbox 10289474 has been checked I need to update item 289474 as
> 10% paid.
> When checkbox 90289474 has been checked I need to update item 289474
> as 90% paid.

Wrong approach. Use

<label><input type="checkbox" name="289474[]" value="10"> 10%</label>
<label><input type="checkbox" name="289474[]" value="90"> 90%</label>

or

<label><input type="radio" name="289474" value="10"> 10%</label>
<label><input type="radio" name="289474" value="90"> 90%</label>

then retrieve the primitive string values of the array $_REQUEST['289474'],
or the primitive string value $_REQUEST['289474'], respectively.

> (In the table I have a column for "10% paid" and another column for
> "90% paid" which I need to set to "yes" when the user checks the
> respective checkbox, the std value is "no" and prefilled on item
> creation)

Would it not be easier, more flexible, and more efficient with queries
to have one field for the percentage and simply store the percentage value?


HTH

PointedEars
--
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
-- Richard Cornford, cljs, <cife6q$253$1$8300dec7(at)news(dot)demon(dot)co(dot)uk> (2004)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Query *.mdb file with ODBC functions
Next Topic: PHP MySQL Web Development - Why Do You Need a PHP & MySQL ...
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 14:35:57 GMT 2024

Total time taken to generate the page: 0.04257 seconds