473,683 Members | 3,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retriew database values to check boxes

250 Contributor
my php page has 7 check boxes. I stored checked values to database and retrive as binary values. This is the result array
Expand|Select|Wrap|Line Numbers
  1. Array ( [0] => 0 [1] => 1 [2] => 0 [3] => 1 [4] => 0 [5] => 0 [6] => 1 ) 
1 means checked. I want to display these results in check boxes. This is my code. But it doesn't work
Expand|Select|Wrap|Line Numbers
  1. <tr><td><input value="1" type="checkbox"  id="1" name="check" <?php if ($array[0]==1) echo "value=checked";?>/>Fasting 6 hours</td>
  2. <td><input value="2" type="checkbox" id="2" name="check" <?php if ($array[1]==1) echo "value=checked";?>/>Off feeds 3 hours</td>
  3. <td><input value="3" type="checkbox" id="3" name="check" <?php if ($array[2]==1) echo "value=checked";?>/>Full bladder</td></tr>
  4.  <tr>    <td><input value="4" type="checkbox" id="4" name="check" <?php if ($array[3]==1) echo "value=checked";?>/>General anesthesia </td>
  5. <td><input value="5" type="checkbox" id="5" name="check" <?php if ($array[4]==1) echo "value=checked";?>/>Sedation</td></tr>
  6. <tr><td><input value="6" type="checkbox" id="6" name="check" <?php if ($array[5]==1) echo "value=checked";?>/>Steroid cover </td>
  7. <td><input value="7" type="checkbox"  id="7" name="check" <?php if ($array[6]==1) echo "value=checked";?>/>Contact Radiologist </td>
  8. </tr>
please help me.
Sep 1 '09 #1
1 2408
6,050 Recognized Expert Expert
What exactly doesn't happen? What is supposed to happen? Do you get any errors?

It looks like it *should* work.

Actually, on second glance, you should be printing 'checked="check ed"' as this is the correct HTML attribute.

Sep 1 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Bryan Wood | last post by:
I am developing a regisration page that will present a set of check boxes to the viewer. This list of checkboxes is developed from a list in a database so the amount and names of the boxes will change. This portion works just fine. The page content has a user name and password along with several sets of these checkboxes. All the form content of this page is presented in one form. The problem:
by: Renie83 | last post by:
Hi I really am going crazy! I'm using VBScript, ASP, and SQL My page reminds me of a shopping cart but looking at shopping cart examples has not helped! What I have is a page that brings in products ordered by a certain company. Along with those values, I'm creating a text box at the end of each record that a user may or may not enter in an estimated delivery date. If the user does enter in a date I want that row of data submitted to a...
by: clinttoris | last post by:
Hello, If someone could help me it would be appreciated as I am not having much luck. I'm struggling with my asp code and have some questions relating to asp and oracle database. First question. I have a web survey that I am working on and have successfully dynamically taken the info from a database, displayed it on the screen and then taken the users answers and inserted them into a
by: pramodrepaka | last post by:
Hello Guys Plz Help me Here is my problem . Unable to retriew the data beteen oracle and vb by using ADODC control i.e if a table consists of Nll values. i am created table and i got successful connection between oracle and VB6.0 .So i want to add some fields at vb and it should update in oracle(But not all fields) by using Addnew. But it is not able to add some fileld. But it is accepting all fields In a table some...
by: kitesurfer | last post by:
Looking for some help with an email form using php. I am using check boxes in a html form, the values of check boxes are email addresses. The person visiting our site has the ability to select one or more check boxes. The values (email addresses) need to be passed on to the php script which in return sends mails to each of the selected emails. (selected addresses only) The script should also send an email to myself! Your help.......
by: mfaisalwarraich | last post by:
Hi Experts Around the World. Well im new to this paradise (Access). i have no experties in Access but i can still work with my mind :). i wish to request you people as under: I made a table called mainTable, two fields of this table one is SNO and other is Relation are text data types. SNO can be any string values but relation stores value from a combo fox on form called mainForm based on mainTable. Relation values can be "Self",...
by: anusha.vempati9 | last post by:
Hi All, I am calling a cgi file from a perl module. The cgi file contains the HTML form and some HTML fields(like check boxes). In my logic, I am trying to submit the form and calling the same cgi file again. While doing this, i am not able to retain the values of the HTML fields (check boxes values ) which i set earlier before submitting the form.
by: nazimsal | last post by:
Imports System.Data.SqlClient Namespace Accounts Public Class NewAccount Dim cmd As New SqlCommand Dim c As New DatabaseConnection.DataBaseConnaction.ConnectionClass Function CreateAccount(ByVal BankID As String, ByVal Account_TypeID As String, ByVal First_Name As String, ByVal Last_Name As String, ByVal Date_Birth As DateTime, ByVal Citizenship As String, ByVal Civil_Id As Integer, ByVal address As String, ByVal...
by: ghjk | last post by:
I have mysql DB with 4 tables.In my php page I have 4 drop down boxes. I want to retrieve db values to each dropdown box. ex: table 1- "vehicles" table 2- "fruits" tables 3- "animals" drop down ============= $sql="SELECT * FROM animals";
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.