Jump to content

stern

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

stern's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thankyou Barand, as that did the trick vey well. I must also add that I think it is really great that someone who is just learning php can come here and have many people jumping in to help. Not only are people fast to assist, they do not "talk down" to php "newbee's" like myself, that can sometimes ask really basic questions. You should all feel very proud, as these acts of helping an unknown "other" person is was makes all that is RIGHT with the world. I thank you all
  2. Hello: Im hoping someone can help me with what may be a simple problem for most, but has me loosing my mind  lol. I am new to php (used to Basic, C+ and raw assembler code) and its taking me a while to learn (guess cause im old  lol). Anyway, here is the problem. Im using radio buttons to input multiple choice answers to questions (4 possible answers to each of 100 questions). So 4 copies like this A <input type='radio' name='chk[$qid]' value='1'> Now, when its done (display part works ok) I end up with an array that has all the answers, and its in the form of $_POST['chk'] which if I print_r()  shows it all.  Ok, now my problem The radio buttons set a value of 1 - 4 depending on the answer chosen, BUT, if a question isnt answered, the array ends up with (i guess) a NULL in that spot. So, if I answer questions 1 - 4 and 47 - 50 I get in the array; Array ( [1] => 1 [2] => 2 [3] => 3 [4] => 4 [47] => 4 [48] => 3 [49] => 2 [50] => 1 ) when i print it. Now,  HELP,  HOW can I stop the NULL entry and get a 0 for any radio button set (4 of them) NOT ticked, so that the array will have an entry (1-4 for selections, 0 for didnt answer) for ALL 100 questions (therefore 100 entries long, allowing me to KNOW which answer is for which question when it placed in a BD file). So this is my delema, getting rid of Nulls so that the array will ALWAYS be 100 entries in size. Have tried everything, but cant seem to get anywhere, especially with the $_POST thing (too used to $name values, and most sytax wont work on both types). Anyway, hope i havent rambled to much, and any help anyone can give on how to plug the NULLS with 0's would be greatly appreciated. Stern
  3. That did the trick  :-)  thanks you so much for the help. I must really applaud all the people here, as you are all making it a lot easier for newbee's like me to learn a lot faster  :-) Thank you all :D
  4. I am new to php programing with little background in HTML. Most of my knowledge would be in launguages like C++, assembler and raw machine code. While I am getting better at php data manipulation and DB control (these all make sense) I for the life of me cant get the simple things to work (like radio buttons). What I want to do is make 4 buttons (can only pick one of the 4) and have the choice return a number (1-4). While I can get the buttons to show and work "visually wise) on the screen, for the life of me I cant get it to give me a value (or I at least cant find "where" I supposed to get it from). After reading a post on radio buttons on the forum I tried it, but the "create radio buttons with HTML" part has left me in the dark. Here is a code snippet from the part with the radio buttons, and hopefully someone can tell me which really stupid mistake im doing here  lol             switch($_post["Radiobutton"])             {             case "1":             $val="1";             break;             case "2":             $val="2";             Bbreak;             case "3":             $val="3";             break;             case "4":             $val="4";             break;             default:             $val="0";             echo "  <div align='left'>";             echo "    <table width='956' border='0'>";             echo "      <tr>";             echo "      #$id ";             echo "      $question<br><br>";             echo "      </tr>";             echo "        <td height='24'>&nbsp;</td>";             echo "        <td><div align='center'></div></td>";             echo "        <td><font color='#FFFF80'>A</font>";             echo "        <input type='radio' name='chk' value='1'> $choice1<br>";             echo "      </tr>";             echo "      <tr>";             echo "        <td>&nbsp;</td>";             echo "        <td><div align='center'></div></td>";             echo "        <td><div align='left'><font color='#FFFF80'>B</font>";             echo "        <input type='radio' name='chk' value='2'> $choice2<br>";             echo "      </tr>";             echo "      <tr>";             echo "        <td height='24'>&nbsp;</td>";             echo "        <td><div align='center'></div></td>";             echo "        <td><font color='#FFFF80'>A</font>";             echo "        <input type='radio' name='chk' value='3'> $choice3<br>";             echo "      </tr>";             echo "      <tr>";             echo "        <td>&nbsp;</td>";             echo "        <td><div align='center'></div></td>";             echo "        <td><div align='left'><font color='#FFFF80'>B</font>";             echo "        <input type='radio' name='chk' value='4'> $choice4<br>";             echo "      </tr>";             echo "    </table>";             echo "  </div>";             } Now im sure after looking at this some may laugh them selves silly, as there is probably a way to do it short and simple. Thank you all in advance for any help you can give a newbee  :-) Paul
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.