Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by sasa

  1. i make litle modification of your code try[code]<?php

    //mysql db connections


    $kelime= $_GET['kelime'];

    if(!isset($_GET['page'])){
        $page = 1;
    } else {
        $page = $_GET['page'];
    }

    $max_results = 2;


    $from = (($page * $max_results) - $max_results);

    $query="SELECT * FROM linkler WHERE kelimeler LIKE '%".$kelime."%' LIMIT $from, $max_results";

    $result=mysql_query($query);

    ?>
    <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <table border="0" cellspacing="0" cellpadding="0">
    <tr valign="middle">
    <td align="left"> SEARCH <br>
    <input name="kelime" type="text" class="input">&nbsp;</td>
    <td align="center" valign="bottom"><input type="submit" name="Submit" value="Submit"></td>
    </tr>
    </table>
    </form>
    <?php
    if ($_GET['kelime']){


    while($record=mysql_fetch_assoc($result)){

    echo "<br>";
    echo $record['name'];
    echo "<br>";
    echo $record['url'];
    echo "<br>";
    echo $record['kelimeler'];
    echo '<hr />';
    }



    $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM linkler WHERE kelimeler LIKE '%".$kelime."%'"),0);


    $total_pages = ceil($total_results / $max_results);



    if($page > 1){
        $prev = ($page - 1);
        echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev&kelime=$kelime\">prev </a>";
    }

    for($i = 1; $i <= $total_pages; $i++){
        if(($page) == $i){
            echo "$i ";
            } else {
                echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i&kelime=$kelime\">| $i</a> ";
        }
    }


    if($page < $total_pages){
        $next = ($page + 1);
        echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next&kelime=$kelime\">| next</a>";

    }

    }
    ?>[/code]
  2. lines[code]if($page > 1){
        $prev = ($page - 1);
        echo "<a href=  "" . $_SERVER['PHP_SELF'] . "?page=$prev"><Previous[/url];
     
    for($i = 1; $i <= $total_pages; $i++){
        if(($page) == $i){
        echo "$i ";
        }else {
        echo "<a href= "". $_SERVER['PHP_SELF'] . "?page=$next">Next>>[/url];
        }
    }[/code]change to [code]if($page > 1){
        $prev = ($page - 1);

        echo "<a href=  \"" . $_SERVER['PHP_SELF'] . "?page=$prev><Previous </a>";}
     
    for($i = 1; $i <= $total_pages; $i++){
        if(($page) == $i){
        echo "$i ";
        }else {
        echo "<a href= \"".$_SERVER['PHP_SELF']."?page=$i\">| $i <a>";
        }
    if($page<$total_pages){
        $next = $page + 1;
        echo "<a href= \"". $_SERVER['PHP_SELF'] . "?page=$next\">| Next> <a>;
        }
    }[/code]
  3. [code]
    $sql="SELECT * , SUM(hits) as total_hits, navn , url FROM toplinks, links WHERE (links_id = id) AND (date BETWEEN '$date2' AND '$date1') AND (toplinks.bolka_id < '30') GROUP BY links_id ORDER BY total_hits DESC LIMIT 10";
    [/code}[/code]
  4. at last i setup sam data for testing. it must works
    the output is just table with some data but i believe thet you can adapt it[code]
    <?php
    mysql_connect("localhost", "", "");
    mysql_select_db("test");
    // conect to database
    $date1 = date('Y-m-d');
    $date2 = date('Y-m-d', time()-604800);
    $sql="SELECT t.links_id , SUM(t.hits) as total_hits, l.navn , l.url FROM toplinks t, links l WHERE (t.links_id = l.id) AND (t.date BETWEEN '$date2' AND '$date1') GROUP BY t.links_id ORDER BY total_hits DESC LIMIT 10";
    $result = mysql_query($sql);
    $nummar = 0;
    echo '<table border="3"><tr><td>Numar</td><td>Links ID</td><td>Total hits</td><td>Navn</td><td>URL</td></tr>',"\n";
    while ($row = mysql_fetch_assoc($result)) {
    echo '<tr>';
    echo '<td>',++$nummar,'</td><td>',$row['links_id'],'</td><td>',$row['total_hits'],'</td><td>',$row['navn'],'</td><td>',$row['url'],'</td></tr>';
    echo "</tr>\n";
    }
    echo '</table>';
    ?>
    [/code]
  5. try[code]
    $product_query = "SELECT * FROM `robin_basket` WHERE session_id = '".session_id()."'";
    $product_result = mysql_query($product_query);
    echo '<form action ="some.php" metod="POST">';
    while($product_info = mysql_fetch_assoc($product_result)) {
    echo "<input type='hidden' name='item_name_$i' value='{$product_info['name']}' />
    <input type='hidden' name='amount_$i' value='{$product_info['price']}' />";
    $i++;
    }
    echo '<input type="submit"></form>';
    [/code]
  6. you dont query your database
    try to make test.php[code]
    <?php
    // conect to database
    $date1 = date('Y-m-d');
    $date2 = date('Y-m-d', time()-604800);
    $sql="SELECT links_id , SUM(hits) as total_hits, navn , url FROM toplinks, links WHERE (links_id = id) AND (date BETWEEN '$date1' AND '$date2') GROUP BY link_id ORDER BY total_hits DESC LIMIT 10";
    $result = mysql_query($sql);
    while ($row = mysql_fetch_assoc($result)) {
    echo '<pre>';
    print_r($row);
    echo "</pre><hr />\n"
    }
    ?>
    [/code]and run it
  7. sorry i dont set GROUP BY part
    it must be[code]
    $sql="SELECT t.links_id , SUM(t.hits) as total_hits, l.navn , l.url FROM toplinks t, links l WHERE (t.links_id = l.id) AND (t.date BETWEEN '$date1' AND '$date2') GROUP BY t.link_id ORDER BY total_hits DESC LIMIT 10";[/code]
    t is short name from table toplinks
    t.links_id is field from table toplink named link_id etc.
    total_hits is name for sum of value of t.hits with same links_id
  8. $date1 = date('Y-m-d');
    $date2 = date('Y-m-d', time()-604800);
    $sql="SELECT t.links_id , SUM(t.hits) as total_hits, l.navn , l.url FROM toplinks t, links l WHERE (t.links_id = l.id) AND t.date BETWEEN '$date1' AND '$date2' ORDER BY total_hits DESC LIMIT 10";
  9. pagination[code]
    $query = "SELECT id FROM images";
    $result = mysql_query($query) or die(mysql_error());
    while ($row = mysql_fetch_array($result)) $link[] = $row['id'];
    $curent = array_search($id, $link);
    $prev = $curent - 1;
    $next = $curent + 1;
    if (array_key_exists($prev)) echo "<a href=\"?id=$link[$prev]\"> PREV </a>";
    if (array_key_exists($next)) echo "<a href=\"?id=$link[$next]\"> NEXT </a>";
    [/code]
  10. [quote author=digitalgod link=topic=105519.msg426200#msg426200 date=1157144406]
    gives me the same result as what I did before... unless I'm doing something wrong

    [code=php:0]
    $num_rows = min($max_num_rows,mysql_num_rows($list_result));
    echo "<table class='guestlist'>\n";
    for ($i = 0 ; $i < $max_num_columns; $i++)
    echo "<tr><td width=197><div align='center'><strong>name/nom + #</strong></div></td><td height=17 width=21><img width=17 height=17 src='images/boy.jpg'></td><td height=17 width=21><img width=15 height=17 src='images/girl.jpg'></td></tr>\n";
    echo "</tr>\n";

    for ($r = 0; $r < $max_num_rows; $r++){
    echo "<tr>\n";
    for ($c = 0; $c < $max_num_columns; $c++){
    $x = $c * $num_rows + $r;
    if ($x < $num_records) {
    $y = mysql_result($list_result, $x, 'name');
    $z= "+" . mysql_result($list_result, $x, 'number');
    /*$promo =  mysql_result($list_result, $x, 'promo_code');
    if ($promo != "") {
    $promo = "(".$promo.")";
    }*/
    } else {
    $y = '&nbsp;';
    $z = '&nbsp;';
    //$promo = '&nbsp;';
    }
    echo "<td>$y $z </td>";
    echo "<td>&nbsp;</td>";
    echo "<td>&nbsp;</td>";

    }
    echo "</tr>\n";

    }
    echo "</table>\n";
    for ($i=1;$i <= $total_pages;$i++) {
    if ($i == $page) echo "Page $i "; else echo " <a href=\"?page=$i\">$i</a> ";
    }
    [/code]
    [/quote]move <tr> tag from line 4 to line 2
    look previous post
×
×
  • 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.