473,385 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

checkbox - how to select and siplay info from db

Hello,

I'm having a code that shows in a list checkbox and next the row name i have on my database
I want to select a checkbox and when i press display to show me tha information of the specific category if checked with my checkbox

ScreenShot:



Here is my code:

Expand|Select|Wrap|Line Numbers
  1. <table style="width: 100%">
  2.    <tr>
  3.       <td colspan="3" class="titlebarmain"><strong>Select &amp; View</strong></td>
  4.    </tr>
  5.    <tr>
  6.       <td class="titlebarmainwhiter" style="height: 22px;">Selections</td>
  7.       <td class="titlebarmainwhiter" style="width: 203px; height: 22px;">&nbsp;</td>
  8.       <td class="titlebarmainwhiter">&nbsp;</td>
  9.    </tr>
  10.    <tr>
  11.       <td>   
  12.         &nbsp;<td style="width: 185px">   
  13. <?php
  14. $result = mysql_query("SELECT * FROM players_category ORDER BY sort_order ASC");
  15. while($row = mysql_fetch_array($result))
  16.   {
  17.   $name = @$row["name"];
  18. $cid = @$row["id"];
  19.  
  20.   echo "<tr>";
  21.     echo "<td><input type=\"checkbox\" name=\"$name\" value=\"$cid\"> $name</td>";
  22.  // echo "<td class='selOverview'>" . $row['name'] . "</td>";
  23.   echo "</tr>";
  24. }
  25. ?>
  26. </td>
  27.       <td style="width: 203px"></td>
  28.       <td>&nbsp;</td>
  29.    </tr>
  30.    <tr>
  31.       <td colspan="3">   
  32.       <input type="submit" name="display_player_cat" value="Display" class='button' ></td>
  33.    </tr>
  34. </table>
  35. <br>
  36.  
P.S Please show me examples base on my code so i will understant please

Thank you
May 4 '09 #1
7 2156
prabirchoudhury
162 100+
Expand|Select|Wrap|Line Numbers
  1. <table style="width: 100%"> 
  2.    <tr> 
  3.       <td colspan="3" class="titlebarmain"><strong>Select &amp; View</strong></td> 
  4.    </tr> 
  5.    <tr> 
  6.       <td class="titlebarmainwhiter" style="height: 22px;">Selections</td> 
  7.       <td class="titlebarmainwhiter" style="width: 203px; height: 22px;">&nbsp;</td> 
  8.       <td class="titlebarmainwhiter">&nbsp;</td> 
  9.    </tr> 
  10.    <tr> 
  11.       <td>    
  12.         &nbsp;<td style="width: 185px">
  13.   <!-- have to declear a form here --->   
  14.   <form name=form_chk action="self.php" method="POST">  
  15. <?php 
  16. $result = mysql_query("SELECT * FROM players_category ORDER BY sort_order ASC"); 
  17. while($row = mysql_fetch_array($result)) 
  18.   { 
  19.   $name = @$row["name"]; 
  20. $cid = @$row["id"]; 
  21.   ?> 
  22.  
  23.    <tr>
  24.   <td><input type="checkbox" name="<? echo $cid;?>" value="<? echo $cid;?>" <? if ($_POST[$row[id]] == $row[id]){ echo "CHECKED";}?> onchange="this.form.submit()" > <? echo $name; ?> </td>
  25.     <? 
  26.      if ($_POST[$row[organisationID]] == $row[organisationID]){
  27.          // checking if the checkbox is being checked then bring the details 
  28.          // and it is auto submit
  29.     ?>
  30.          <p>
  31.          Category name: <? echo $row[name]; ?><br>
  32.          other detail: <? echo $row[other]; ?><br>
  33.          More details: <? echo $row[more]; ?><br>
  34.       </p>
  35.  
  36.   </tr>
  37.  
  38.  
  39. <? 
  40. ?>
  41. </form> 
  42. </td> 
  43.       <td style="width: 203px"></td> 
  44.       <td>&nbsp;</td> 
  45.    </tr> 
  46.    <tr> 
  47.       <td colspan="3">    
  48.       <input type="submit" name="display_player_cat" value="Display" class='button' ></td> 
  49.    </tr> 
  50. </table> 
  51. <br> 
  52.  



hope tis gonna help you
My blog

My Site
May 6 '09 #2
Hey, thanks for your help,

Im getting this error all the time..
Expand|Select|Wrap|Line Numbers
  1. Notice: Use of undefined constant id - assumed 'id' in 
  2.  
and the line:
Expand|Select|Wrap|Line Numbers
  1.   <td><input type="checkbox" name="<? echo $cid;?>" value="<? echo $cid;?>" <? if ($_POST[$row[id]] == $row[id]){ echo "CHECKED";}?> onchange="this.form.submit()" > <? echo $name; ?> </td>
  2.  
Any ideas?

tHANK YOU
May 6 '09 #3
Ciary
247 Expert 100+
Expand|Select|Wrap|Line Numbers
  1.   <td><input type="checkbox" name="<? echo $cid;?>" value="<? echo $cid;?>" <? if ($_POST[$row['id']] == $row['id']){ echo "CHECKED";}?> onchange="this.form.submit()" > <? echo $name; ?> </td>
this should solve it. i've put quotes around 'id' in the brackets
May 6 '09 #4
Expand|Select|Wrap|Line Numbers
  1. Notice: Undefined index: 77 in 'DIRECTION' on line 38
  2. onchange="this.form.submit()" > [U20]Multiskillers 
  3.  
same error with diferent numbers :)))
May 6 '09 #5
Ciary
247 Expert 100+
i'm not sure about what's causing that notice. but you might consider the next code to avoid html-errors.
Expand|Select|Wrap|Line Numbers
  1. <td><input type="checkbox" name="<? echo $cid;?>" value="<? echo $cid;?>" <? if ($_POST[$row['id']] == $row['id']){ echo "checked="checked";}?> onchange="this.form.submit()" /> <? echo $name; ?> </td>
  2.  
May 6 '09 #6
Expand|Select|Wrap|Line Numbers
  1. Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in 
  2.  
is there any other way doing this? like java or something?
May 6 '09 #7
Ciary
247 Expert 100+
java will make it even more complicated. the error you showed means you just forgot a ';' somewhere. you might check your code for more errors like these. don't forget that you need to end every command with ;
May 6 '09 #8

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

Similar topics

1
by: Ben Munday | last post by:
Hi all, I have a problem with a Checkbox in a JTable. When i add the Checkbox into the JTable it displays the String representation of the Checkbox, which is not what i want. So, i created a...
4
by: Hexman | last post by:
Hello All, I'd like to find out the best way to add a cb column to a dgv and process efficiently. I see at least two ways of doing it. ------------------------------- 1) Add a cb to the dgv,...
4
by: mamun | last post by:
Hi All, I have the following situation and am looking for answer in C#. I have a datagrid and putting checkbox next to each record. In the header I have a Delete button. I want users to...
7
by: Srikanth Ram | last post by:
Hi, I'm creating a PHP application. In this a dynamic table with the fields in the database is generated in a page. I have placed a checkbox in each row of the table to approve/disapprove...
3
by: uremog | last post by:
I have a set of of check boxes. onClick, the checkboxes call check_radio and recup_checkbox. the referenced radios function as group selectors. check_radio just unchecks the radios if someone...
8
by: nick02895 | last post by:
I am not a programmer, just putting bits and pieces I've found on the net. I am missing something here, can you help? The "publishcityonline" checkbox is not sending the required 0 or 1 to mysql...
3
realin
by: realin | last post by:
Hiya all, i am in deep trouble, i thought it was an easy task, but now its getting on my nerves. Well i have a div on a form, which contains a number of checkboxes, as <div...
0
by: creejohn | last post by:
Hi all-- I'm really stumped here. I have a (c# 2.0) calendar control that loads a menu for each day inside the cell corresponding to that day in the dayrender event. That is all working great. I...
1
by: ahilar12 | last post by:
Hi all, I am new to php,my question is that in this following code i am retrieving many rows from the database which is working good.i want to delete a particular row(s) which is checked(checkbox)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.