PDA

View Full Version : Need help loading values from an array into a table



kuau
07-25-2008, 10:49 AM
At first this was at least loading the table (incorrectly) but I tried to fix it and now it is creating a cats array but not loading anything at all. It makes less and less sense to me as I get more tired. Please help. Thanks.


while ($row = mysql_fetch_array($result_cat))
{
$count++;
echo '<td width="253"><input type="checkbox" name="cats[]" value="'.$row['cat_id'].'">'.$row['category'].'</td>';
if (($count % 3) == 0){
echo "</tr>";
}
}



if(isset($_POST['cat_id'])) {
$cat_id = $_POST['cats'];
foreach ($cats as $newcatid) {
$query = "INSERT INTO eventcat ( event_id, cat_id ) VALUES ( '" .$neweventid. "', '".$newcatid."' ) ";
}
}

Dal
07-26-2008, 04:31 PM
foreach $cat_id as not $cats as! You missed your own variable.

Hope that helps
Kind regards
Dal

kuau
07-26-2008, 08:06 PM
Thanks. Maybe there are 2 ways of doing it, but this is what fixed it (courtesy of thetestingsite):


if(isset($_POST['cats'])) {

foreach ($_POST['cats'] as $newcatid) {
mysql_query("INSERT INTO eventcat ( event_id, cat_id ) VALUES ( '" .$eventid. "', '".$newcatid."' )") or die("Couldn't execute $query query. <br> mysql error: ".mysql_error());

Dal
07-27-2008, 12:03 AM
Sorry, whats courtesy of thetestingsite? I dont see any reply post other than you and me. Is that response another question, Im confussed, wheres the problem/question at?

? :eek:

thetestingsite
07-27-2008, 12:11 AM
Sorry for any confusion, but I have been helping this user in my spare time and this was one of those issues that I was able to take care of last night.

kuau
07-27-2008, 12:13 AM
Oh, I was just giving the solution so other people can learn from it. Isn't that what I'm supposed to do? I don't really know that much about the netiquette of forums, except I just found out that I'm not supposed to thank everyone so much as it screws up the statistics, or something. I appreciate everyone's efforts to help no matter what. :)

Dal
07-27-2008, 12:42 AM
Oh, I was just giving the solution so other people can learn from it. Isn't that what I'm supposed to do? I don't really know that much about the netiquette of forums, except I just found out that I'm not supposed to thank everyone so much as it screws up the statistics, or something. I appreciate everyone's efforts to help no matter what. :)

WHAT? Explain this please someone!

Who told you that being friendly and good mannored would screw up someones stats??? Only Satain would whisper such things in the ears of man :)

Seriously though, Im working on my thanks score and I have 2 so far out of around 45 posts (I had a few questions myself) No wonder everyone is so bad mannored if it screws up the stats.

kuau
07-27-2008, 01:16 AM
I don't understand it myself unless they use the thanks as an indication of how valuable an answer is, or that it was the one and only greatest solution, and you shouldn't be thanked unless you really earned it. I was just being polite and grateful, so maybe you're supposed to just say thanks in the text. I'm not sure what the criteria would be for giving someone an official "Thanks" -- I would hate to offend someone. Who am I to judge the value of someone's answer? Perhaps the moderators should assign a value to the contributions, seeing as they have the requisite knowledge to be able to judge objectively, and either remove the ability for the users to click on Thanks, or change its name so we know how to use it. THANKS! :)

Dal
07-27-2008, 01:21 AM
So long as "Powered by vBulletin® Version 3.7.1" the forum works the same. Thanks is used to cut out poeple who just want to respond to a post to say just that. Whatever youve been told about it effecting stats is rubbish. Since no MOD has stepped forward to supply an argument just keep thanking people by clicking the big red link "Thank user who made this post" You will see why Im on edge by reading the post "Soap Box" in the lounge area of this forum. Oh which also got a response by a MOD who shares the same greif.

:D

thetestingsite
07-27-2008, 01:58 AM
You know, there have been many discussions amongst the "High Council" about the "Thanks" functionality and there really isn't a criteria as to how much a user should thank others because; as you said:


Thanks is used to cut out poeple who just want to respond to a post to say just that.

I know that in the past we had issues with certain users only thanking posts made by one person, and there were other times where the Thanks system was so screwed up (basically, a bot posing as a user went through and thanked every single post on the entire board) and they had to be reset back to 0. In any case, I think users should just use this rule of thumb: "Use your best judgment". Basically, if the post was helpful to you, thank that user's post; but if someone posts a one word answer that was just to say "No Problem", "You Got it", "Blah", etc then don't thank that post. This helps to keep the stats "more accurate" (for a lack of better words).

Hope this helps.