Jump to content

love_bug

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

Posts posted by love_bug

  1. Hi, yea similar to : http://stackoverflow.com/questions/842956/php-foreach-loop-through-multidimensional-array

     

    but the solution he provided doesn't apply to my problem i guess.., only thing I want to do is get array of "m_name[] and m_name[]" and insert them in db with loop.

     

    here's array output :

     

    Array
    (
        [0] => someone
        [1] => Array
            (
                [email] => someone@gmail.com
            )
    
        [2] => sometwo
        [3] => Array
            (
                [email] => sometwo@gmail.com
            )
    
        [4] => somethree
        [5] => Array
            (
                [email] => somethree@gmail.com
            )
    
    )

     

     

  2. hi thanks for reply.. yea i thought about that too,  but i want to put those values together in db..

     

    while (each $val1, $val2) {
    $sql = "INSERT INTO table name (name,email)($val1,$val2);
    }
    

    It will be great if i could combine 2 array like below so i can put them in sql db with while loop.. just tell me it cant be done in php lol  :(.. thankx

     

    Array
    (
        [0] => $val1, $val2
        [1] => $val1, $val2
        [2] => $val1, $val2
    )

     

  3. Hi again  :-[,

    I am stuck with simplest problem of array .. i searched all forums and couldn't find similar problem..

    Iam collecting array post data "data m_name[]" from a form, but I don't know how to get 2 array variables at the same time, here's what I tried :

     

    <form action="" method="post" name="myForm">
    <div>
          <input type="text" name="m_name[]" />
          <input type="text" name="m_name[][email]" />
    </div>
    <div>
          <input type="text" name="m_name[]" />
          <input type="text" name="m_name[][email]" />
    </div>
    <div>
          <input type="text" name="m_name[]" />
          <input type="text" name="m_name[][email]" />
    </div>
            <input type="submit" name="button" id="button" value="Submit" />
    </form>

     

    other page where I want to receive above array

     

    <?php
    if($_POST)
    {
    
    print_r($_POST['m_name']); // Output is : Array ( [0] => someone [1] => Array ( [email] => 3 ) [2] => someone two [3] => Array ( [email] => 4 ) [4] => someone three [5] => Array ( [email] => 5 ) )
    
    
    while (list ($key,$val) = @each ( $_POST['m_name'])) { 
    echo $val.val2 ???"<br/>"; // here I want to get both value $_POST['m_name'] and  $_POST['m_name'] ['email'] since I am putting them in db << 
    }
    }
    ?>

     

    I want to get both values of $_POST['m_name'], I don't know how to do it or is there another way to do it?

    thankx in advance!! phpfreaks have been very helpful ..

  4. i meant .. removing the Slash ( / ) at the end.. if you are receiving "No such file or directory" error.. that only comes up when path is wrong. I faced same problem while ago, removing slash at the end worked great for me ;)

  5. Hi guys, I am creating a quiz system for my personal site, I am done with all the quiz questions creating part, but I am stuck with something like... user taking a random sql generated quiz and submitting it..

     

    Here's randomly generated sql quiz, even the answers are in random order:

     

    <form method="post">
    <b>1. What is color or sky</b>
    <ol>
    <li><input name="question_3_answer" type="radio" value="6" /> sky</li>
    <li><input name="question_3_answer" type="radio" value="8" />blue</li>  <-- true
    <li><input name="question_3_answer" type="radio" value="3" />red</li>
    </ol>
    
    <b>2. What is name of my cat</b>
    <ol>
    <li><input name="question_6_answer" type="radio" value="9" />brat</li>  <--true
    <li><input name="question_6_answer" type="radio" value="7" />rat</li>
    </ol>
    
    <b>3. What is name of my pet</b>
    <ol>
    <li><input name="question_18_answer" type="radio" value="9" />cat</li>  <--true
    <li><input name="question_18_answer" type="radio" value="7" />dog</li>
    </ol>
    </form>

     

    Now this is tricky part for me is.. receiving these data in another page.. since it's randomly generated questions, how do I know which question it is?

    here's example I've tried :

     

    $list_all_quiz_questions = $db->get_row("SELECT question_id, its_true_ans_id FROM question_table WHERE quiz_group = 'ef23fsdfers3e' ");
    
    $i = 1;
    foreach ($list_all_quiz_questions as $myquestion)
         {
    $answer.$i == $_POST["question_".$myquestion->question_id."_answer"]; //?????????? not working lol ;((
        $i++
    }

  6. Hi,

    This is an unusual problem I have..

     

    I have a field named "recipient_userids" where I store ids of users in a comma separated form,

    sucha as "3323,5543,53,3235,23"

     

    Now I want to select records from db, which matches a particular userid in "recipient_userids".

    such as.. If I want to retrieve a record that has 53 in "recipient_userids" how do I do it?

    I tried LIKE, IN syntax, but not doing the job.

     

    OR is there a way to do it please share.

     

     

     

  7. Thanks.. wish i could write the code..

    the code seem to be working.. but it can not find image tags with different values..

    can you show me how can i use it with perg_replace?

     

    <?php
    $URLSearchString = "a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'";
    $str  = preg_replace("(\<img src=([$URLSearchString]*)\](.+?)\</a>)", '$2', $str );
    ?>
    

×
×
  • 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.