Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > PHP Question

PHP Question
Thread Tools
Mac Enthusiast
Join Date: Jul 2003
Status: Offline
Reply With Quote
Mar 25, 2006, 09:13 AM
 
I am trying to write or find a written PHP script that allows a user to check a checkbox, and when they hit submit, the next page has a list of links that are based on those check boxes.

I have contracted with a company to host a small portion of my website on a separate server with proprietary information. They have this checkbox I am talking about- I just don't know how to write the script behind the action on the form.

You can see what I am talking about Here.

Thanks for the advice.
     
Mac Enthusiast
Join Date: Aug 2001
Location: Durango CO
Status: Offline
Reply With Quote
Mar 25, 2006, 09:19 AM
 
Code:
foreach ($_POST['checkboxname'] as $key=>$val) { echo '<div>'.$links[$key].'</div>'; }
something like that should do it - assuming the $links array is predefined somewhere.
The Bitcastle
graphic design, web development, hosting
     
Mac Enthusiast
Join Date: Jul 2003
Status: Offline
Reply With Quote
Mar 25, 2006, 09:26 AM
 
Wow, that's the most blazing fast response I've gotten! Thanks for the input. Now, keep in mind that I am a total non-programmer- but willing to stab at things. In order to define that array, I assume this is via a mysql database? I have created a table that I am trying to populate with links and URL values. Problem is, I don't know what the heck I'm doing.

Any primers on the subject?
     
Professional Poster
Join Date: Jan 2001
Location: Salt Lake City, UT USA
Status: Offline
Reply With Quote
Mar 25, 2006, 10:21 AM
 
Arrays are variables which hold values in a series. It allows them to act as sort of a table for carrying multiple pieces of data. No MySQL required.

The best way to learn this stuff, is (IMO) the online PHP documentation.
http://www.php.net/manual/en/

I recommend that you look at the array function stuff.
2008 iMac 3.06 Ghz, 2GB Memory, GeForce 8800, 500GB HD, SuperDrive
8gb iPhone on Tmobile
     
Mac Enthusiast
Join Date: Jul 2003
Status: Offline
Reply With Quote
Mar 25, 2006, 10:37 AM
 
I have a decent idea about arrays. I just haven't used them. An analogy: you've read about playing basketball, but the first time you pick up the ball, you are not sure what to do with it.

So, that said, I'll hunt and read- but can I ask a few basics:

I assume I define an array in one file, then do an include statement so that the array is included in the script file?

Also, if I want the value of the array to be a web link, I assume I have to be careful with quotes, slashes, etc.?
     
Mac Elite
Join Date: Mar 2002
Location: Clogland
Status: Offline
Reply With Quote
Mar 25, 2006, 01:44 PM
 
Originally Posted by surferboy
I assume I have to be careful with quotes, slashes, etc.?
diligent is the word I think you're looking for
     
Mac Elite
Join Date: Dec 2004
Status: Offline
Reply With Quote
Mar 25, 2006, 01:50 PM
 
Originally Posted by SirCastor
Arrays are variables which hold values in a series. It allows them to act as sort of a table for carrying multiple pieces of data. No MySQL required.

The best way to learn this stuff, is (IMO) the online PHP documentation.
http://www.php.net/manual/en/

I recommend that you look at the array function stuff.
Today I DLed PHP Function Index from Version Tracker. All I can say is
Anyone who denies climate changes naturally is a Climate Change Skeptic.
     
Mac Elite
Join Date: Sep 2003
Location: London
Status: Offline
Reply With Quote
Mar 25, 2006, 03:02 PM
 
may also be worth running the echo like:

Code:
foreach ($_POST['checkboxname'] as $key=>$val) { $output .= '<div>'.$links[$key].'</div>'; } echo $output;
this means you aren't sending to the client until the loop is complete (using network connections) but does mean you use memory on the server to store that info until it's sent to the client.
     
   
Thread Tools
Forum Links
Forum 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
Top
Privacy Policy
All times are GMT -5. The time now is 09:34 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2