Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by sasa

  1. output of your last post is not from your form code

    are you shure that edit right file

    i insert some coments in your code

    i'm shure you can understund it

    i think that is beter way to choice separeted wit questin

    while( $info = mysql_fetch_array( $sqll ))
    //))
    {
    echo "{$info['Que_ID']} <br />\n"; // i hope that is PK from your table
    echo "<input type='hidden' name=\"Que_ID\" value=\"{$info['Que_ID']}\" /> ";
    // name from this field must be array
    //it's mean that name=\"Que_ID[]\" add [] to name
    echo "{$info['Que_Question']} <br />\n";
    echo "<input type=\"checkbox\" name=\"choice[$counter]\" value=\"{$info['Que_Choice1']}\" /> ";
    //transform name in 2 dimensinal array
    //1st dimension is for which question is answer, and 2nd just for enable multliply answers
    // name=\"choice[{$info['Que_ID']}][]\"
    // if $info['Que_ID'] = 1 in $_POST['choice'][1] is array of all chcked ansvers for question with id=1
    // $_POST['choice'][12] is array of all chcked ansvers for question with id=12 etc.
    //warning! if noting checked for questinh x, $_POST['choice'][x] is not set
    // if notin checked at all $_POST['choice'] is not set
    echo "{$info['Que_Choice1']} <br />\n";
    ...

  2. try

    <?php
    $test = '<TD valign="top"><B>name</B></TD>
    <TD>Administrators</TD>
    </TR>
    <TR>
    <TD valign="top"><B>inUse</B></TD>
    <TD>true</TD>
    </TR>
    <TR>
    <TD valign="top"><B>allow</B></TD>
    
    <TD valign="top"><B>name</B></TD>
    <TD>Users</TD>
    </TR>
    <TR>
    <TD valign="top"><B>inUse</B></TD>
    <TD>true</TD>
    </TR>
    <TR>
    <TD valign="top"><B>allow</B></TD>
    
    <TD valign="top"><B>name</B></TD>
    <TD>Developers</TD>
    </TR>
    <TR>
    <TD valign="top"><B>inUse</B></TD>
    <TD>true</TD>
    </TR>
    <TR>
    <TD valign="top"><B>allow</B></TD>';
    preg_match_all('/<TD valign="top"><B>name<\/B><\/TD>.*?<TD>([^<]+)<\/TD>/is', $test, $out);
    print_r($out[1]);
    ?> 

  3. try[codeg<?php
    function my_link($a = 'i_need_link'){
        static $i = 0, $array = array();
        if($a == 'i_need_link') return $array;
        $i++;
        $array[$i]=  $a[0];
        return "<$i>";
    }
    $test = 'blah blah www.a.com bla bla blaa b.com aaaa
        sss c.org bla';
    $test1 = preg_replace_callback('/\S+\.\S+/', 'my_link', $test);
    $links = my_link();
    echo $test1,"\n<hr />\n";
    print_r($links);
    ?> 

  4. try

    <?php
    $query1 = mysql_query("SELECT DISTINCT quizTitle, userId, SUM(passState) as pass, MAX(userScore) as u_sore, totalScore, DATE_FORMAT(userDate,'%b %e, %Y') AS userDate FROM quiz WHERE managerId = '$managerId' AND userId = '$userId' GROUP BY quizTitle ORDER BY quizTitle, userDate ASC"); 
    
    while ($row = mysql_fetch_array($query1))
    { 
             echo "{$row['quizTitle']} <br />\n";
             echo "{$row['userDate']} <br />\n"; 
             if ($row['pass'] > 1) {echo "<img src=' ../../wood/wood_tool_images/tick2.png' /><br />\n";}
             if ($row['pass'] == 0) {echo "<img src=' ../../wood/wood_tool_images/cross2.png' /><br />\n";} 
             echo $row['u_score'].'/'.$row['totalScore'];
            }
    ?> 

  5. change form to

    <?php
    while( $info = mysql_fetch_array( $sqll )){
        echo "<input type='hidden' name=\"Que_ID[]\" value=\"{$info['Que_ID']}\" /> ";
        echo " $intNum, {$info['Que_Question']} <br />\n<br />\n"; 
        for ($i =1; $i < 5; $i++) {
            echo "<input type=\"checkbox\" name=\"choice[{$info['Que_ID']}][]\" value=\"$i\" />{$info['Que_Choice'.$i]}";  
        }
    }
    ?> 

    and your action page to

    <?PHP
    foreach ($_POST["Que_ID"] as $question) { 
    $_POST["choice"][$question] = $choice;
    echo "Question id: ".$question. implode(', ',$choice")<br />";  

  6. try

    <?php
    class Paginator{
    //...
    function my_p_number($total_pages, $current, $before = 2, $after = 3){
        $out = array(1);
        $out = array_merge($out, range(min($total_pages-$before-$after,max(1, $current - $before)), max($before+$after+1,min($total_pages, $current + $after))));
        $out[] = $total_pages;
        $out = array_unique($out);
        sort($out);
        return $out;
    }
    function paginate(){
        $this->numPages = ceil($this->itemsTotal /  $this->itemsPerPage);
        $p = Paginator::my_p_number($this->numPages, $this->currentPage);
        $t = 0;
        foreach ($p as $i){
            if($i - $t > 1) $this->output .= ' ... ';
            if ($i == $this->currentPage){
                $this->output .= "<span class=\"paginate current\" onclick=\"goPage(this)\" data-page=\"" . $i . "\">" . $i . "</span> ";
            }else{
                $this->output .= "<span class=\"paginate\" onclick=\"goPage(this)\" data-page=\"" . $i . "\">" . $i . "</span> ";
           }
           $t=$i;
       }
    }
    }
    ?> 

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