Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Checkbox Problem, He Always Pick The Variable Of The Last One


I have currently 2 awards in the database, with this script i pick them out of the database and define if they are selected and if the user unselect it then pass a variable to the database. Now it works almost good except that the script always looks to the 2nd award(last one), if the 2nd one is unselected then it updates award 1 and award 2 as unselected, when i unselect the 1st award and select the 2nd award then he updates the database with both selected(1st one and 2nd one), so the problem is that he always listening to the 2nd(last) variable/award. Does someone have a solution for this problem because i cant figure it out, greatly appreciated. PHP Code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Passing A Checkbox Variable To A MySQL Db
Im the webmaster for a boxers website, and rather frequently, the publicist sends me links to articles about the boxer that I need to post. So, I set up a form that allows me to pull the information as needed and post it.

Basically I have it set up to post the Article Title, Article URL, and Article Date, and I call that information from the db. However, on occassion, one of these links will be a press release, and the only thing that changes is that the text Press Release: is added in front of the article title.

I was thinking about creating an extra field in the table called article_pr, and referencing that on the page, and if the row is empty, it would just pull up a space, and if its marked it just pulls up whatever is in there.

However, on the form, I need to have a check box that asks if it is a press release. If so, I would need it to print this in the code Press Release:<br> Is there a way to have the check box indicate whether it will put that code in the db field?

How To Use A Value From A Pick List?
I'd like to have a form that does the following:
User picks a site from a dropdown list from a MySQL db (that works -
code below, thanks to all those on the web who posted code for this).
Once the value is selected, a second query is run using the site as the
'where' clause and the results are displayed back to the user.

mysql, php, htlm noob. I think once I get this bit,
I'll be able to move forward with more interesting and complex code.

ps - if this message shows up 3 times, my apologies but I've been having
trouble posting.

<html>
<body>
<?php

// connect to db
$db = mysql_connect("localhost");
mysql_select_db("test",$db);

// build query
$sitequery = "SELECT site from sitedata order by site";

// generate result set
$siteresult = mysql_query($sitequery);

// use results
echo "Select a site from the list below: <br><br><select name='site'>";
while($siterow = mysql_fetch_array($siteresult))
echo "<option
value='".$siterow["site"]."'>".$siterow["site"]."</option>";
echo "</select></td>";
?>

</body>
</html>

Pick Up Page Name In PHP?
Is there a way, within a PHP script, to pick up the name of the web page that the script is being run on?

How To Pick The Closest Number
I've been wondering about this for a few days.

I have an array containing 4 numbers:

$listofnumbers = array(0,15,30,45);

Then there's a variable that could contain any number between 0 and 59.

$actualtime = date('i');

Using the above I want to find out which of the numbers in the array is numerically closest to the value of $actualtime. So

if $actualtime = 34 then I want to return the number 30
if $actualtime = 11 then I want to return the number 15 etc.

I'm sure there's a simple solution but can't figure it out.

How Can I Pick All Checked Value In Action Page?
I have a dynamic category list, I have printed those list with check box in the form. I have to check those boxes and submit. How can I pick all checked value in action page? Right now only one value passing from several check boxes while several check boxes checked. Code:

Identifying User's Pick From Selection List
I have an application that uses PHP to access a MySQL table and
extract rows which match the user's search entry. Data from the
matching rows are loaded into an HTML selection list, and the user can
scan the list and highlight a selected item.

My question: In PHP, what is the syntax for identifying which row is
highlighted?

My goal is to pass the unique row ID of the selected item to a
subsequent form where all the fields will be displayed for the user to
edit.

I already have the code that loads the selection list and the code
that displays the fields. I just need to know how to determine the
highlighted item.

I have two PHP books, and both discuss loading the selection list, but
there is no mention of what to do next.

Checkbox
I am trying to make a form with 16 different checkboxes that pass on to an email. Someone got me started with the form but I'm not sure how to incorporate it into my php file.

<INPUT name=other_needs[] type=checkbox id="other_needs[]" value=reception>Reception<TD>

<TD><INPUT name=other_needs[] type=checkbox id="other_needs[]" value=Lunch>Lunch</TD>

How do I refer to the checkboxes in my php file to include the results in the email the script sends?

Checkbox And SQL
What im stuck with at the moment is how to update the SQL database with the new information acquired from a set of check boxes.

What i´ve done so far is to create the checkboxes and got the information from a table which checkboxes is needed and pre check it if it is already enabled. i have two rows in the database 1. Module_Name (name of a module) 2. is_enabled (is the module enabled 1 or 0). Code:


Checkbox Value
if i have 10 checkbox for customer interest..  how do i save that to database?? need to create 10 fields in the database??  after save.. how to display back when customer view his data.. if i choose swimming.. next time when i view back.. how to show swimming in the checkbox being checked

Checkbox
I have a database column which either holds the value 1 or 0.

Now if there is a 1 in this column I want to produce a checkbox button that is ticked, and if a 0 then nothing ticked.  So I thought it would work like this:

<input name="dayTwo[]" type="text" id="dayTwo" value="<?php echo $databaseArray['d2']?>" size="6" />

However, it does not seem to work?

Checkbox
I am creating an email form with checkbox included.

And I need the checkbox to be ticket when I enter the form though links.

IE

List of checkbox's

checkbox 1
checkbox 2
checkbox 3
checkbox 4

say I was another page and I click on a link (call the link checkbox 1) I would like the checkbox to be ticked automatically. I know this makes no sense but I hope you get the idea.

Checkbox
i have a checkbox array of some unknown size.its a dynamic array created.
i want to know out of all checkboxes how many r selected and which are they?
and then insert the data in the table based on that. i hav written the code as follows:-

<?
$no=0;
$friendname= $_POST['friendname'];
$storecount=$_POST['storeid'];
while($no<$storecount)
{
   if($friendname[$no])
   {
      $sql = "INSERT INTO groupfriends (groupid, username) VALUES ('$stid[$no]', '$friendname[$no]')";

      $result = mysql_query($sql) or die('Query

failed. ' . mysql_error());
   }
   $no=$no+1;
}
?>

i dont think this will work.it will add all the checkoxes data to the table. i want to insert only of those which r selected.

Checkbox Values
Basically, I have 2 checkbox's which are printed out for each record within my table. On the next form, each checkbox is tested for being "checked" and the database is updated accordingly.

This is fine. My problem is that I dont want users to be able to select both check-box's at the same time. After talking to "andnaess" on an earlier post and doing some reading, I decided upon using some javascript to do what i wanted.

I have found a script which does exactly what i want, and i am now incorporating it into my original php script.

I am having problems assigning a name and value variable with an array to my checkbox's. Is this possible, or have i got the wrong idea?

Checkbox Confusion!!!!
I have page1.php that displays some articles from a database by the condition 'on'

What I want to do is have checkboxes so that the articles you check won't be displayed on the web page the next time it's brought up. Essentially turn the articles checked to the 'off' condition and leave the articles that are not checked to the 'on' condition.

When you hit the submit button I want it to go to a page2.php to run an update query to change the 'on' condition to the 'off' condition for the specific articles that were previously checked. (My Primary Key in the database is Article_Number)

I think i have page1.php correct (don't quote me on this!)

<input type='checkbox' name='Display_Article' value='off'>";

But I'm completely lost on what to do for the page2.php

if($submit) {

for ($i=0; $i<count($Display_Article); $i++) {
//echo "<li>".$Display_Article[$i]."</li>";

$sql="Update articles set Display_Article='$Display_Article[$i]' where Article_Number='$Article_Number'";
$result=mysql_query($sql) or die ("Update Query Failed");
}

Checkbox Problem?
I am having trouble with checkboxes. How do you have a checkbox that it it is not checked it will still allow the form to be submitted. I am using checkboxes now, and if all the checkboxes are not checked, then it says that each of the ones that aren't checked are undefined variables why?

Problem With Checkbox
When i click on submit then the table wont be updated. I wanted to try to update the colom aw with the desired awardsid but i also wonder what happens if i have selected 2 or more checkboxes and whats entered then in the table aw, 1 & 2 or ? PHP Code:

Retain Checkbox Value
Just a quick question regarding the way to do something rather than the
actual code :-

I have a page which has some links that go through to a HTML form and
each link will check a certain checkbox. I want the form to retain the
checked status of any checkboxes that are set to checked when the user
goes back to the previous page.

Would this be best done using sessions or is there another way I could
use? I don't mind using sessions as I have used them before. I would
like to avoid using cookies but I don't really have any strong
objections to using them, it's just that they're not 100% reliable (but
then, what is?).

CheckBox Question
i started a php site in dreamweaver and i try fill data into MySql
database.

i set up a page with a form and i can fill in all the fields.

just for one field, i like to have several checkboxes. every checkbox
has a value, and they should fill the same field with their vale when
checked. i also want to keep my text box, so i can write additional
information.

at the moment, when i click more than one checkbox, only the value of
the first checkbox appears in the database. also, if there is already
some data in this cell, it delete previous data, but i would like to
keep it. preferably it should just add to information allready in the
database.

Disable Checkbox
I have a checkbox that I set by php code to be either "checked" or "".
I want to disable the ability of the user to check or uncheck it. I
tried "readonly", but that didn't work.

Checkbox Problem !
I try to display the multiple checkbox in my form and the quantity of this are depends on how many records in my database (usually the record is more than 500). So how big space it takes to display. And to solve the spaces problem, i thing i better display with horizontal scrollbar to save the space. But i don't know to do it.

Checking A Checkbox
Is it possible to preset the values of form elements with php - so that when
the client gets the page certain boxes are checked or completed - on the
fly - based on their HTML id.

Javascript has a way of doing this - but i need the functionality of PHP
too - so if i can move the whole thing over to php it owuld be better .

javascript example -

document.forms['form1'].elements['radiobuttonno'].checked = true;

Checkbox Array
checkbox arrays do not hold their respective positions as do other field arrays that are established to store the contents of selected records. The problem is that when you "uncheck" one of the elements and then repost, that array element disappears and the whole array collapses and renumbers itself with only the remaining "checked" ones -- simply useless when dealing with records in a table where all the field array elements should be in sync.

I consider it a bug -- why does the array have to collapse? Why can't it just hold a null value and keep its position? The only fix is to never hold checkbox values in an array. Store them in individual variables numbered like an array, then do an "eval" to retrieve the contents. Here's the whole thing in action: Code:

Checkbox Not Between Date
I get a database for « News » on Internet.
Side Admin, I would like a form to know witch "News" are Online or
not.

In my database mysql I get :

Date_start
and
Date_end

Outside this date, the « News » are unvisible.

In my form I put a checkbox « Off_line »

If it's check, all the news outside Date_start
And Date_end must be visible.

I tryed like this

In Head :
<?php
if (isset($HTTP_GET_VARS["date_off"]))
{
$ date_off =$HTTP_GET_VARS["date_off"];
}
else
{
$ date_off =0;
}
?>

In my form for checkbox :
<input <?php if ("CURRENT_DATE NOT BETWEEN $row_R_news['date_start']
AND $row_R_news['date_end'] ",1) {echo "checked="checked"";} ?>
name=" date_off " type="checkbox" id=" date_off " value="1">

For my request sql :
SELECT t_news.*
FROM t_news
WHERE $date_off

Checkbox Array
I have a list of checkboxes. The name for each is being pulled up from a database. Each (minus irrelevent or implicit code) looks like this ...

<input type=checkbox name=assnid$assnarray[assnid] value=1>

or...peaking at the HTML, the list looks like this:

<input type=checkbox name=assnid1 value=1>
<input type=checkbox name=assnid2 value=1>
<input type=checkbox name=assnid3 value=1>

and so on...
Anybody know how to post the selected checkboxes into $assnidarray?
For example, assuming all are chosen, $assnidarray would be (1,2,3,...).

Checkbox Array
I have a checkbox array containing the id of a record in a MySQL database.
The checkboxes are created dynamically depending on what is stored in the
database. I want to send the checkbox array to my stop_subscriptions.php
file, running the code on all checked boxes, however I dont seem to be able
to actually send the array, I was hoping that someone could steer me in the
right direction.

<?php
$sql = "SELECT i.type, i.title , s.inj_id FROM inj_subscription s,
injustices i WHERE s.member_id = '$user' AND i.inj_id = s.inj_id AND
s.inj_id IS NOT null" ;
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result) ;
if ($row) {
echo "<div><span>Specific Subsriptions:</span><br/>" ;
$table_start ='<table width="90%" table name="table2" align="center"
cellspacing="0" border="0">
<tr>
<form method="post" action="stop_subscription.php">
<th width="20%">Type</th>
<th width="70%">Title</th>
<th width="10%"></th>
<input type="submit" name="Submit" value="Submit"
style="font-size:10px"/><p>
<input type="hidden" name="stop_subscription"
value="1"/>
</form>
</tr>'
echo $table_start;
$rownum = 0;
while($row) {
$rownum++;
$style = rowcolor($rownum);
$table_rows .= '<td id="td" align="center"
style="'.$style.'padding:5px;" >'."
".'<form><input type="checkbox"
name="deletethis[]" value="'.$row['inj_id'] . '"></form></td>'."
";
echo "<tr>" . $table_rows . "</tr>";
$row = mysql_fetch_assoc($result) ;
}
echo '</table><Br/></div><br/>'
}
?>

Checkbox Is Checked
how do u say that if the checkbox is checked, than do something.

Checkbox Without Array
I have a question regarding implementing a checkbox that DOESN'T use arrays -- everything i find when i google has arrays in it!  So, I'm hoping someone here can help me come up with a solution to my problem.

I have a checkbox that a user can check (default will be to have it NOT checked) - and once it's checked, to keep it checked until the user unselects it again.

Here's my checkbox code:
<input type ="submit" name="cv_permission" type="checkbox">

What do I have to do to keep it turned 'ON' once it's checked?

Checkbox FormMailer
Ive got this problem and i have no idea how to fix it. Ive been trying to do it in PERL, but thats not my strong point, and i know a lot more PHP than perl. But still dont know enough to try and achive what i want to do.

Basically i am trying to have a web form in which the company fills out the form and can select which people to send the form to. Code:

$_POST Checkbox
I'm trying to create a validate members page that lists all the unvalidated members and beside it is a checkbox with the name attribute being the member's name. Is there a way to create a foreach loop to check all the $_POST and check if it's empty, and if not, do something?

For Each None Checked Checkbox
I need help with foreach none checked checkbox as value, can you even do that. I tryed the !isset(); function but i'm not sure it would work because the none checked box would not of run with the $_POST ( i think ) this is an example table of what i'm looking for help with:

({num}) = the value
[] = the checkbox.

(1)(2)(3)(4)
 [] []  [] []

the person checks the one(s) they wish to keep and the none checked ones get swaped for diffrant values. I'm not quite sure if it is possible, but i will ask anyway to see if anyone as a solution.

Checkbox Blues
I have the following checkboxes where I am using an array called check[] ...

<input name = "check[]" type = "checkbox" value = 'somevalue1' />
<input name = "check[]" type = "checkbox" value = 'somevalue2' />
<input name = "check[]" type = "checkbox" value = 'somevalue3' />

When selected by the user, I wish to delete the selected records using this code ...

// capture checkbox data
$data = $_POST['check'];

// start delete loop
foreach ($data as $key => $value )
   {
    // create SQL string
    $SQL = 'DELETE FROM ' . $table . ' WHERE name = "' . $value .'"';
   
    // run SQL query
    code goes here
   }

This code works fine ! BUt the javascipt functionality that references it does not work ! What I would like to know is how I can do the same thing but AVOID using the check[] array, by using checkboxes like this ...

<input name = "check" type = "checkbox" value = 'somevalue1' />
<input name = "check" type = "checkbox" value = 'somevalue2' />
<input name = "check" type = "checkbox" value = 'somevalue3' />

Has anyone got any good references for dealing with checkboxes in php ?

Checkbox Data In The Database
I want to display the checkboxes taken from the database from table “const_skills”, but the checkboxes and its values do not appear ($html_skills). Can anyone figure this out. Below is the codes that I’ve been using.
Thanks in advance.

<?php
include "dbinfo.php3";

function get_checkbox_labels($table_name) {
/* make an array */
$arr = array();

/* construct the query */
$query = "SELECT * FROM $table_name";

/* execute the query */
$qid = mysql_query($query);

/* each row in the result set will be packaged as
an object and put in an array */
while($row= mysql_fetch_object($qid)) {
$array[count($arr)] = $row;
}
return $arr;
}

/* Prints a nicely formatted table of checkbox choices.
$arr is an array of objects that contain the choices
$num is the number of elements wide we display in the table
$width is the value of the width parameter to the table tag
$name is the name of the checkbox array
$checked is an array of element names that should be checked
*/

function make_checkbox_html($arr, $num, $width, $name, $checked) {

/* create string to hold out html */
$str = "";

/* make it */
$str .= "<table width="$width" border="0">n";
$str .= "<tr>n";

/* determine if we will have to close add
a closing tr tag at the end of our table */
if (count($arr) % $num != 0) {
$closingTR = true;
}

$i = 1;
if (isset($checked)) {
/* if we passed in an array of the checkboxes we want
to be displayed as checked */
reset($arr);
while (list(, $ele)=each($arr)) {
$str .= "<td><input type="checkbox" name="$name" value="$ele->id"";

reset($checked);
while (list(, $entry)=each($checked)) {

if ($entry == $ele->id) {
$str .= "checked";
continue;
}
}
$str .= ">";
$str .= "$ele->value";

if ($i % $num == 0) {
$str .= "</tr>n<tr>";
} else {
$str .= "</td>n";
}
$i++;
}

} else {
/* we just want to print the checkboxes. none will have checks */
reset($arr);
while (list(, $ele)=each($arr)) {
$str .= "<td><input type="checkbox" name="$name" value="$ele->id">";
$str .= "$ele->value";

if ($i % $num == 0) {
$str .= "</tr>n<tr>";
} else {
$str .= "</td>n";
}
$i++;
}
}
/* tack on a closing tr tag if necessary */
if ($closingTR == true) {
$str .= "</tr></table>n";
} else {
$str .= "</table>n";
}
return $str;
}
/* get the checkbox labels */
$skills = get_checkbox_labels("const_skills");

/* create the html code for a formatted set of
checkboxes */
$html_skills = make_checkbox_html($skills, 3, 400, "skills[]",$checked);
?>

<html>
<body bgcolor="#ffffff" text="#000000" id=all>
<br>
<form name="skills" method="POST" action="insertskills.php3">
Check off your web development skills:
<? echo "$html_skills"; ?>
<br>
<br>
<input type="submit" value="Submit">
</form>
</body>
</html>

Record Unchecked Checkbox
Is there a way to record a checkbox that is not checked?

Checking For Checkbox Array
I'm working on a page for an e-commerce site that has a form than lists items in an order placed by a customer. The form serves two purposes: to edit
and save the details of the items (i.e. number of items, price, etc.) and to split the order (i.e. select certain items to remove from the order and
use to create a new separate order). Each item has a checkbox next to it, and the name for the checkbox is "name[]" so an array of the checked items
is created and passed to the processing script. The logic I want to use to determine if the items are being saved or being split out is by looking at
the $name array. However, if I try something like "if ($_POST['name'])" and none of the checkboxes are checked, I get an Undefined Index error (it
works fine if there are items checked). What is a valid way to check to see if the $name array exists so I know which action to take?

Smarty: Checkbox Validation
I have smth. like this:

file.php:
<?php

SmartyValidate::connect($smarty);
//SmartyValidate::register_form('register');

$smarty->assign('nl_id',0);
$smarty->assign('nl_sel',$Fnewsletter);
$smarty->assign('nl_name','Fnewsletter');
$smarty->assign('pp_id',0);
$smarty->assign('pp_sel',$pp);
$smarty->assign('pp_name','Fnewsletter');

if(SmartyValidate::is_valid($_POST) == true) {
// Register

} else {
// Form displayed with hints ex. "You forget e-mail"
$smarty->assign($_POST);
$smarty->display("register_form.tpl");
}

?>

Theme.tpl

{$duplikacja_usera}
<p>{validate field="Flogin" criteria="notEmpty" message=" Podaj
login "}</p>
<p>{validate field="Fhaslo" criteria="notEmpty" message=" Podaj
hasL,o "}</p>
<p>{validate field="Fhaslo" criteria="isEqual"
field2="Fhaslorepeat" message=" HasL,o nie zgadza siÄ™ z
powyLLszym "}</p>
<p>{validate field="Fimie" criteria="notEmpty" message=" Podaj imie
"}</p>
<p>{validate field="Fnazwisko" criteria="notEmpty" message=" Podaj
nazwisko "}</p>
<p>{validate field="Fmail" criteria="isEmail" message=" Podaj
poprawny e-mail "}</p>
<p>{validate field="Fulica" criteria="notEmpty" message=" Podaj
ulice "}</p>
<p>{validate field="Fnumer" criteria="notEmpty" message="Podaj
numer domu "} </p>
<p>{validate field="Fkod" criteria="notEmpty" message=" Podaj kod
pocztowy "}</p>
<p>{validate field="Fmiasto" criteria="notEmpty" message=" Podaj
miasto "}</p>
<BR>
<form name="register" onsubmit="return check(this)"
action="index.php/mode/register" method="POST">
<input type="hidden" name="akcja" value="rejestruj">
<input type="text" name="Flogin" value="{$Flogin}" maxlength="20"
class="login_in" style="width:150px"></div>
<input type="password" name="Fhaslo" maxlength="20" class=""
class="login_in" style="width:150px"></div>
<input type="password" name="Fhaslorepeat" maxlength="20" class=""
class="login_in" style="width:150px">
<input type="text" name="Fimie" value="{$Fimie}"
maxlength="20" class="login_in" style="width:150px">
<input type="text" name="Fnazwisko"
value="{$Fnazwisko}" maxlength="100" class="login_in"
style="width:150px">
{validate field="Fnazwisko" criteria="notEmpty"
message=" Podaj nazwisko "}</div>

{html_checkboxes name="Fnewsletter" values=$nl_id
selected=$nl_sel}..........

Checkbox In Mysql Fields
PHP selects and shows a list of records. Next to each record is a check
box. If user checks the box the record(s) is selected and appended to
another 2nd DB....when the user finally presses a button

Basically I hope you get my drift, pretty normal but powerful stuff...
Are there any tutorials or snips on how I'd do this?

What Goes Into The Database When You Submit Via A Checkbox?
I have a simple form with a checkbox and I thought that when the box is checked and I submit to the MySQL database then the number 1 would appear in the database and if it wasn't checked then a 0 would appear. But whether it is checked or not, a 0 appears. How do I make it so that a 1 appears if the box is checked?

How To Give A Value To Non Selected Checkbox
I would like to get a value for a non selected checkbox in a form.

Imagine my form contains :

<input type='checkbox' name='t[0]' value=&#391;'>
<input type='checkbox' name='t[1]' value=&#391;'>

When I analyse $t, if first checkbox is not selected and second is, I have :
$t[0] has no value. $t[1] equals 1
and count($t) equals 1

I would like to find a way to get :
$t[0] equals 0. $t[1] equals 1
and count($t) equals 2

Checkbox Search Engine
I wanted to create a search engine with checkboxes. In my database are names of our programmers and what programming languages they can write.

I got one (.html) form and one (.php) file that searches the database. Every time I try to connect to the database, I get a blank page?! Could someone help me, I don’t know what’s wrong. Below you can find the tables and files. Code:

Form Processing With Checkbox ?
I am currently writing a webpage that displays a list of records (
each record has a checkbox associated with it) to allow users to
select any record they want to delete (much like in "hotmail" or
"yahoo" e-mail where u can select particular message to delete) ?

Anybody have any idea how to do it ?

And one more question, I like to write my page so that when the user
click on a checkbox associated with a record. That record (that row)
is highlighted (like in "hotmail"), anybody has any idea how to do it
?

Clearing Checkbox Property
I am currently working on a phonebook system whereby people can add their own names to the database. So I also have an edit facility. Within my form however I have 3 checkboxes. What I need to know is say someone clears their checkbox, how do I get that to clear the table field??

At the moment, if they de-select the field then it adds it doesn't change the field. Also note, i created a separate column for each of the checkbox fields (they are called roles1, roles2, and roles3). I have included my code for how I can tell if the box should be checked or not. Code:

Php Checkbox And Textbox Combo
I have a form which asks:

How did you know about us?

--friend
--flyer, where_______
--web
--other, _______

I want to store in the db whether the user checked the box and on
certain questions, store the additional description, as indicated by
the _____

How do I go about in doing this? I need help getting the values to
perform an INSERT in the mysql table using php.

Retaining Checkbox Entries
I have a table with entries that are ever increasing and each one has an ID number and I want to be able to associate any of those ID numbers to a file, so I created a pages that shows the ID numbers, 100 at a time. Seeing that there are over 800 entries, I have paginated the results and give the user the ability to move back and forward thru the entries to check off which of the IDs they want to use.

However, if IDs on the first page are checked and then the user moves to the second page to check some more, if they go back to the first page, the IDs are unchecked.

- how to keep track and display which of the IDs were checked and
- how to send the information of which ones were chosen to the next step of the process for adding to the table.

Update Column With Checkbox
I have a basic page that shows a basic table of the database (names, address, number of tickets purchased.) I also just made a column with a checkbox. I would like to be able to check a number of boxes and probably hit a update button or something like that and have it UPDATE the DB by adding now() into the MailedTickets column for the multiple rows that I checked. PHP Code:

Checkbox Array Problem
I have a form which contains several fields. One of which is a group of
checkboxes that can all be selected, and if they are - all values should be
passed as an array.

Each checkbox is Named as follows. myCheckBoxName[]

myCheckBoxName[]

I have the following code on the following page to pick up the results from
the querystring.

while(list($key, $value) = each($HTTP_POST_VARS))
{
$keys = $keys . "$key, ";
$values= $values . "'$value', ";
echo("$key = $value <br>" );
}

But the field which contains multiple checkboxes only displays the value
"array" - and nothing else.

Keeping The 'check' In 'checkbox'
I have a list of checkboxes that are built on the fly from the db.

"SELECT id, name FROM $table_name WHERE name !='$startlocation'";

$boxes.="<input type='checkbox' name='attend[]' value='$id' $isChecked>$choosename<br>";

When the user checks one or many and then submits - I loop through the checkbox array to see which values get returned Like so ...

$attend[] is the dynamic array
for ($i=0;$i<count($attend);$i++) {
$boxres.= "$attend[$i]";}

Question is - when the user submits the form (to same page) - the checkboxes reset and selections are lost. Is there a way to "mark" checked to those initial selections after the user submits?

Checkbox Forms, Php & Mysql
I'm about to add some checkboxes to a form, and then store the data in
a column on a MySQL database. Just wanted to know best practice, at the
moment I'm writing and thinking .. God that's ungly code ...

<input type="checkbox" name="delta" <?php if ($delta==1) { echo
"checked"; }?>> Delta<br>
<input type="checkbox" name="mastercard" <?php if ($mastercard==1) {
echo "checked"; }?>> Mastercard<br>
<input type="checkbox" name="solo" <?php if ($solo==1) { echo
"checked"; }?>> Solo<br>
<input type="checkbox" name="switch" <?php if ($switch==1) { echo
"checked"; }?>> Switch<br>
<input type="checkbox" name="visa" <?php if ($visa==1) { echo
"checked"; }?>> Visa<br>

MySQL database fields ...
delta binary(1) No 0
mastercard binary(1) No 0
solo binary(1) No 0
switch binary(1) No 0
visa binary(1) No 0

When I output the fields, I get "on" or empty, and am wondering whether I am
making a good decision to do the code this way. Now I need to figure out how
to update the database based on the forms output.

Generate Checkbox List
I have a table with two fields:
1) groups_id
2) groups_name

The data contained is simple:

groups_idgroups_name
---------------------------
1 Group A
2 Group B
3 Group C
4 Group D

I would like to dynamically create a checkbox selection similar to:

<input name="sel_group" type="checkbox" value="1">Group A<BR>
<input name="sel_group" type="checkbox" value="2">Group B<BR>
<input name="sel_group" type="checkbox" value="3">Group C<BR>
<input name="sel_group" type="checkbox" value="4">Group D<BR>

So I need a script that'll take this information from the groups table
and create the above.

Input Type = Checkbox ?
I have a HTML form that contains checkboxes. Let's say you are ordering a Hamburger. You need to thick boxes for additional toppings (ie pickles, onions etc)At the end ths order will be written to a file. How can I get the PHP to recognise whether which boxes are checked?


Copyright © 2005-08 www.BigResource.com, All rights reserved