Jump to content

maskme

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

maskme's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks a million Sasa, it works like a charm... Array ( [recordid] => Array ( [0] => 1 [1] => 2 ) [sports] => Array ( [0] => Array ( [0] => Cricket [1] => Basketball ) [1] => Array ( [0] => Basketball ) ) [submit] => submit ) How it works is by using Multi Dimensional Arrays. Cool I've understood how this works perfectly. Amazing stuff!!! Thanks a lot
  2. Thanks Sasa, but what next, what happens once i post. I'm not good at arrays, i would appreciate, if you could guide me how do i retrieve from these multiple values???
  3. Hi Thanks for your prompt reply Here is the section that works with no hitch gives me all the selection as per the user had done while filling up the form initially <form name="frm1" method="post" action="sports.php?page=update"> <table cellspacing="0" cellpadding="0" border="0"> <? $squery = "select * from user_sports"; $sresult = mysql_query($squery) or die ("Query Failed"); while( $row = mysql_fetch_array( $sresult ) ) { $sports = explode(";",$row['sports']); ?> <tr> <td> <input name="recordid[]" type="hidden" value="<? echo $row['urecord'] ?>"> <input name="sports[]" type="checkbox" id="sports[]" value="Football" <? if (is_array($sports) == TRUE) { if (in_array("Football", $sports)) echo "CHECKED"; } ?>> Football<br> <input name="sports[]" type="checkbox" id="sports[]" value="Cricket" <? if (is_array($sports) == TRUE) { if (in_array("Cricket", $sports)) echo "CHECKED"; } ?>> Cricket <br> <input name="sports[]" type="checkbox" id="sports[]" value="Basketball" <? if (is_array($sports) == TRUE) { if (in_array("Basketball", $sports)) echo "CHECKED"; } ?>> Basketball </td> </tr> <? } ?> </table> </form> Here is the section which does not work, for which i need to be able to update. <? if ($page == "update") { for ($j=0; $j < count($recordid); $j++) { if (count($sports[$j]) == 0) $sportslist = "None"; else { for ($i=0; $i < count($sports[$j]); $i++) { $sportslist .= $sports[$i].";"; } } echo $recordid[$j]; echo "<br>"; echo $sportslist; echo "<br>"; //$utpquery = "UPDATE user_sports SET sports='$sportslist' where urecord = $recordid[$j]"; //$utpresult = mysql_query($utpquery) or die("Query failed 1"); } //header("Location: sports.php"); //exit; } ?> Please let me know where it is going wrong
  4. Hi I did the Print it comes following id followed by the checkbox selection. It never adds the Basketball or Cricket though it is ticked. 12 Football; 13 Football; Football; 14 Football;Football;Football; 15 Football;Football;Football;Football; I'm going nuts over this.
  5. Dear All I've 15 records displaying in a page. Each record has a field called "Sports" which stores values separated by semicolon ";" "Football;Cricket;Basketball" When I'm retrieving the values, i use explode and assign each values of check box. Works perfect with No Problem. I'm storing the Record ID as a hidden field. I'm the admin and I uncheck "Football" or "Basketball" in couple of records and click on Submit and give the following code if ($action == "submit") { for ($j=0; $j < count($recordid); $j++) { if (count($sports[$j]) == 0) $sportslist = "None"; else { for ($i=0; $i < count($sports[$j]); $i++) { $sportslist .= $sports[$i].";"; } } $utpquery = "UPDATE user_sports SET sports='$sportslist' where urecord = $recordid[$j]"; $utpresult = mysql_query($utpquery) or die("Query failed 1"); } header("Location: verifyrecord.php"); exit; } Once I execute the above, I check the Database and find the ones which I had Unchecked have become in Multiples For e.g. "Basketball;Basketball;Basketball;Basketball;Basketball;" I don't know what am I doing wrong here. Could anyone give me a Hint??? Thanks
×
×
  • 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.