PHP Web Host - Quality Web Hosting For All PHP Applications Sign up for PayPal and start accepting credit card payments instantly
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
killing-hours
RavenNuke(tm) Development Team


Joined: Oct 01, 2010
Posts: 415
Location: Houston, Tx

PostPosted: Wed Feb 16, 2011 3:45 pm Reply with quote Back to top

Hey all-

I've been at this for a couple days now and I'm so hung up on stupid checkboxes. Maybe one of you will have a better idea of how to handle this before I spill my brains on a wall.

I'm setting a switch of sorts for my system and I'm trying to do it with a form that links checkboxes back to a database. The way the form is created on the page is to run through a while loop and create a table row with the company name and checkbox.

What I can't figure out is how this checkbox is to be "unique" so that when the form is submitted I can switch one of the fields in the database from 0 to 1 or visa verca.

-------------------------

Here's the flow.

3 fields in database: ID, Name, Active

Form is built with "while(list" loop creating a new table row and td's for the table row.

Code:
while(list($id, $name, $active) = $db->sql_fetchrow($query)) {
   
   echo '<tr><td>'.$name.'</td>';
   echo '<td align="center"><input type="checkbox" name="chk" /></tr>';

};


the "Active" field will need to switch from 0 -> 1 or 1 -> 0 based on checkbox status.

------------------------

Any insight or help will be appreciated. Thanks.
View user's profile Send private message
Palbin
Site Admin


Joined: Mar 30, 2006
Posts: 2456
Location: Pittsburgh, Pennsylvania

PostPosted: Wed Feb 16, 2011 7:39 pm Reply with quote Back to top

Code:
name="chk' . $id .'"
View user's profile Send private message
killing-hours
RavenNuke(tm) Development Team


Joined: Oct 01, 2010
Posts: 415
Location: Houston, Tx

PostPosted: Thu Feb 17, 2011 8:33 am Reply with quote Back to top

Right... I tried that Palbin...

Here's the problem with doing it that way though. As the table fills with more companies... I would have to go back re-program the actual submit script to catch the individual "$_POST['chkID']" ....unless there is some other way to pick them up in the script I'm unaware of.

This is one of those types of things that will need to work all on it's own and shouldn't have to be reprogrammed as the table expands.


Last edited by killing-hours on Thu Feb 17, 2011 11:39 am; edited 1 time in total
View user's profile Send private message
Palbin
Site Admin


Joined: Mar 30, 2006
Posts: 2456
Location: Pittsburgh, Pennsylvania

PostPosted: Thu Feb 17, 2011 11:07 am Reply with quote Back to top

Code:
name="chk[' . $id .']"

Then just iterate through the array when the form i submitted.
View user's profile Send private message
killing-hours
RavenNuke(tm) Development Team


Joined: Oct 01, 2010
Posts: 415
Location: Houston, Tx

PostPosted: Thu Feb 17, 2011 11:28 am Reply with quote Back to top

Holy cow... that Idea never even crossed my mind. I was trying to figure out on the script side how to work with an array but nothing seemed plausible. I'll try this when I get a chance and appreciate your insight bud!

on a side note... Did you happen to determine if ajaxModules was safe for use or not?
View user's profile Send private message
Palbin
Site Admin


Joined: Mar 30, 2006
Posts: 2456
Location: Pittsburgh, Pennsylvania

PostPosted: Thu Feb 17, 2011 7:02 pm Reply with quote Back to top

It seems safe. Since it is on the admin side it does not have to be perfect as normal users can not access it.
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum