Jump to content

iScript

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Posts posted by iScript

  1. Yes, there is a different:

    $string1 = "Hi";
    echo "The string1 var is $string1"; // output: the string1 var is Hi
    // Its not recommended to so that, the best way is to put a dot to seperate strings and vars
    echo 'The string1 var is $string1'; // output: the string1 var is $string1
    
    // Good way:
    echo "The string1 var is " . $string1; // output: the string1 var is Hi
    echo 'The string1 var is ' . $string1; // output: the string1 var is Hi
    

     

    Another good thing to have this two is this:

     

    echo "<span style="color:red">spanInnerHTML</span>"; // ERROR: double quotes within double quotes...
    
    // Solution:
    echo "<span style=\"color:red\">spanInnerHTML</span>"; // output: <span style="color:red">spanInnerHTML</span>
    echo "<span style='color:red'>spanInnerHTML</span>"; // output: <span style='color:red'>spanInnerHTML</span>
    

  2. First, use a regular while loop.  Not do_while, because you need to define the $row array before the actual loop statments.

     

    And to your question, its pretty simply, you can use a code like this:

     

    $query = mysql_query("SELECT * FROM `tableName` ORDER BY `columnName`");
    $i = 0;
    echo "<table>";
    echo "<tr>";
    echo "<td><ul>";
    while($row = mysql_fetch_assoc($query)){
    $i++;
    if($i >= (mysql_num_rows($query) - $i))
    break;
    echo "<li>" . $row['columnName'] . "</li>";
    }
    $query2 = mysql_query("SELECT * FROM `tableName` ORDER BY `columnName` LIMIT " . $i . ", " . mysql_num_rows($query) - $i);
    echo "</ul></td><td><ul>";
    while($row2 = mysql_fetch_assoc($query2)){
    echo "<li>" . $row2['columnName'] . "</li>";
    }
    echo "</ul></td>";
    echo "</tr>";
    echo "</table>";
    

     

    I didn't test that, but it might work.

  3. Store the user's sorting expression in a session

    $_SESSION['sortOrder'] = $_GET['sortOrder'];
    /* the URL shoul'd be similar to "page.php?sortOrder=name" */
    

    Or in a cookie:

    setcookie("sortOrder",$_GET['sortOrder']);
    

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