Web Hosting Vodahost    

Home Take The Royal Tour! Order Now Features Prices
Go Back   Web Hosting > VodaHost Web Hosting Support > mySQL & PHP

Notices

mySQL & PHP Discussions, information and help with mySQL and PHP.

Reply
 
LinkBack Thread Tools
  #1  
Old 04-26-2008, 06:29 PM
pipesportugal's Avatar
Sergeant Major
 
Join Date: Jul 2007
Location: Oporto - Portugal
Posts: 99
Default put a check box inside of a table

Hello dear colleagues from the VH forum,

Can someone make me the big favour of explaining how we can put a check box inside of a table ?

I mean this when You are listing (for example) Your customers in the screen after a "select" sentence.
I would like to give the opportunity to the user to check the box on the chosen customer/line, in which he wants to perform an operation, which could be chosen from a series of buttons at the end of the listing.

Hope it's clear,

Thanks for all the answers,
pipesportugal
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2  
Old 04-26-2008, 06:38 PM
Watdaflip's Avatar
Brigadier General
 
Join Date: Sep 2005
Location: Cincinnati, Ohio
Posts: 1,638
Default Re: put a check box inside of a table

So to make sure I get you right... you want list all of your customers in a table, each customer on a row, and it just lists down the page. On each row you want to have a check box next to each customer name, and finally at the end of the list have the buttons to perform whatever action on all customers who checkbox was checked?
__________________
Freelance web programming
Do you need help installing a script, or need one written for you? I do freelance web programming (XHTML, CSS, PHP, MySQL). Feel free to contact me through my website and I will get back to you with a quote asap.

Register/Login Script

Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old 04-26-2008, 06:47 PM
pipesportugal's Avatar
Sergeant Major
 
Join Date: Jul 2007
Location: Oporto - Portugal
Posts: 99
Default Re: put a check box inside of a table

Yes, that's it Watdaflip,

Like in the phpmyadmin after You check the box You have then below some buttons where You can decide to edit, delete, etc make, an operation to the chosen line.

On a table, to make a link is very easy because You add the customer number to the link, such as: edit_client.php?client=$client_number, right?

But for a checked box how do I know the customer number ?

Thanks for replying,
pipesportugal
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old 04-26-2008, 07:43 PM
Watdaflip's Avatar
Brigadier General
 
Join Date: Sep 2005
Location: Cincinnati, Ohio
Posts: 1,638
Default Re: put a check box inside of a table

Basically you just set the name of each check box to be... for instance "customer[]", which makes it into an array. Set the value of each check box to be the row number in the database table.

Once submitted you just have to loop through the posted variable as an array, ie

PHP Code:
$count count($_POST['customer']);
for(
$i=0$i $count$i++)
{
// do whatever to each customer id
// each is will be $_POST['customer'][$i]

Of course you will want to verify all posted data is safe.

If you need any more explanation I will try to go more in depth or write you an example
__________________
Freelance web programming
Do you need help installing a script, or need one written for you? I do freelance web programming (XHTML, CSS, PHP, MySQL). Feel free to contact me through my website and I will get back to you with a quote asap.

Register/Login Script

Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old 04-26-2008, 08:29 PM
pipesportugal's Avatar
Sergeant Major
 
Join Date: Jul 2007
Location: Oporto - Portugal
Posts: 99
Default Re: put a check box inside of a table

Hi Watdaflip,

I understand Your code.
That's the code for retrieving the customer number on the "other side / action program" (after the button submiting).

This method will force me to "create" a form, put my listing (everything) inside this form and add a submit button, so that I can pass the array customer[] with the $_POST method to the "action program".

I also checked the html source code at the phpmyadmin page and based on what I saw, this is what it must be done in the table:

$line = "<td><center><input type=checkbox name=customer[] value=$customer_number id=checkbox1 /></td>";
$line .= "...............

This works. I've tested it.

But..... I'd like to use several buttons and javascript and the $_GET method in the browser command to execute the required tasks, but I imagine that it must not be possible.

In case You have any idea I would very much appreciate the help.

Also from my side I will keep my search to evaluate the possibility
of doing it without being forced to "construct" the form.

Thanks,
pipesportugal
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old 04-26-2008, 10:41 PM
pipesportugal's Avatar
Sergeant Major
 
Join Date: Jul 2007
Location: Oporto - Portugal
Posts: 99
Default Re: put a check box inside of a table

Hi,

In fact for the purpose I wanted is better to use a RadioButton, because this way, only one customer will be chosen.

the philosofy would be the same...

....
$line .= "<td><center><input type=radio id=RadioButton1 name=customer[] value=$customer_number</td>";
....

But I would still need to put everything inside of a form and add a submit button and so on.....

Any ideas ? thanks all,
pipesportugal
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old 04-26-2008, 10:42 PM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 8,833
Default Re: put a check box inside of a table

You don't need to construct the main form body. Add the code to the $line variable using a loop, add at the end the ***essary buttons and you are done.
Make sure to add the openin <form and closing /form> tags

I use the same method (with delete icon and a text box for quantity updting) for my shopping cart.

Unless i misread something..
__________________
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old 04-26-2008, 11:13 PM
Watdaflip's Avatar
Brigadier General
 
Join Date: Sep 2005
Location: Cincinnati, Ohio
Posts: 1,638
Default Re: put a check box inside of a table

What are you trying to do, this will help so we know what the problem you are running into.
__________________
Freelance web programming
Do you need help installing a script, or need one written for you? I do freelance web programming (XHTML, CSS, PHP, MySQL). Feel free to contact me through my website and I will get back to you with a quote asap.

Register/Login Script

Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old 04-30-2008, 11:09 PM
pipesportugal's Avatar
Sergeant Major
 
Join Date: Jul 2007
Location: Oporto - Portugal
Posts: 99
Default Re: put a check box inside of a table

Hi, You make quite a great team! Congrats,

I've been able to do it with the form and /form tags and inserted the code manually for the POST method and it works fine.

Watdaflip, what You said at Your first post to my thread made me think that You had got it right, at the first time.

Thank You guys !

Pipesportugal
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +1. The time now is 11:04 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC7
2007 VodaHost.com - All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53