Jump to content

tomcat_fo

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tomcat_fo's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Im making a thing with my php-website where users can enter MAX 20 items to show. The thing i want to happen when users enter items: 1. Check if users have used their 20 records limit or no   2.1 If they have not reached the 20 records limit the record should be inserted   2.2 If they have reached the 20 record limit, the record is not inserted, but they get a message, telling them they have reached the limit What im worried about is how the querry looks like that checks how many records have been inserted. The IF part would probably look like this: if ($records < 20) { insert the record } else { print("you have reached the limit"); } How will the counting part look like, where the VAR $records comes from ? hope someone can help
  2. Know this is not a script question, but hope someone will answer anyway. What does it exactly mean when someone says on their website, you can use something for non-commercial use ? When is something regarded as commercial ? I own my own website (personaly), users can not buy anything on my website, and it is 100% free to use(no paid services), but people/companys can get their bannar on my website (this costs) Is my website non-commerical or not?
  3. mayday.. sos - can someone help me, with that ? :)
  4. Can someone how a single frame in HTML looks like, and how i get my other stuf in my index.php file in the frame ?
  5. Thanks so much ! Have been trying to get that thing to work for several days now, but with no luck.
  6. Now i have adjusted the code that i use in TOP-10 LINKS But i still have a very small problem i think..... THe code looks like this: [code]<?php include 'www/samband/kikarin/samband.php'; $placering = 1; // conect to database $date1 = date('Y-m-d'); $date2 = date('Y-m-d', time()-604800); $sql="SELECT * , SUM(hits) as total_hits, navn , url FROM toplinks, links WHERE (links_id = id) AND (date BETWEEN '$date2' AND '$date1') GROUP BY links_id ORDER BY total_hits DESC LIMIT 10"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { $nummar=$placering++; echo '<a href="javascript:void(0);" onclick="window.open(\''         . 'kikarin/redirect.php?link=' . $row['id']         . '\', \'linkname\', \'height=600,width=780,resizable=1,scrollbars=1\');">'         . $nummar         . $row['navn']         . '</a> <br>'; } ?>[/code] I have links in diferent groups and i don't want to print all groups.... in the table [b]toplinks [/b]there is an atribut [b]bolka_id[/b] (gruop id) and i only want to print/echo links where bolka_id is under 30 ([b]bolka_id <30[/b]) ... but i get an error message if i do that. Have tryed to insert this in your script (sql guerry): [b]AND (bolka_id < 30)[/b] it will not work.... hope you can place something like that in the right place for me so it works.
  7. You can see my website at www.kikarin.com The top-list is down to right of the website frontpage..... your is the one with frames  - i have other top-lists there, and they look like i want to, but don't work like i want to (they have dublicates links), but with your script i can now adjust them as well.
  8. Thanks a lot, that seems to work, and i see no dublicates now... The only thing is, that i don't want visible tables arround it, and i only want a number (place) in front of the title (navn) of the link, and that text is suppose to be a link, that opens in a new window of a preset size.... you can probably se what i mean if you look at my orginal script. Thanks a lot, I will try and adjust your code so it works like i want to.... but if you have some spare time - i would be very thankefull ;)
  9. Does anyone know what could cause the error...... and most of all how i make the script work so that it show top-10 links past 7 days.
  10. have some RSS digest, on my website, but when someone clicks a headline, i want the RSS to open in a new window. I have only added targe="blank" to the code. [b][i]The current code looks like this:[/i][/b] <tr><td valign="middle" style="font-size: 16px; color: #aaa;">%DAY%%MONTHSHORT%&nbsp&nbsp;</td><td><b><a href="%URL%" target="blank">%TITLE,70%</a></b><ifdescription><br /><small>%DESCRIPTIONPLAIN,250%</small></ifdescription></td></tr> I need all the things u see in that code, but it can maybe be arrange differently... hope someone can ajust that code for me so link open in a new pre-set size... like 700x650
  11. [quote author=sasa link=topic=106861.msg428190#msg428190 date=1157429984] add ; in line echo "</pre><hr />\n" [/quote] Now i get: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /usr/home/web/web128130/test.php on line 7
  12. [quote author=sasa link=topic=106861.msg428006#msg428006 date=1157402815] 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 [/quote] if i do that i get this message: Parse error: syntax error, unexpected '}', expecting ',' or ';' in /usr/home/web/web128130/test.php on line 11
  13. [quote author=sasa link=topic=106861.msg427969#msg427969 date=1157399048] 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 [/quote] I have now tryed that.... now i get no error message, but i don't get it to print anything... maybe i got some of your notation wrong  ??? Here is how the script looks like now: <?PHP //Server connect ------------------------------------- include 'www/samband/kikarin/samband.php'; $placering=1; $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"; while ($row = mysql_fetch_array ($toplinks)) { $toplinks_id = "".$row["toplinks_id"]; $links_id = "".$row["links_id"]; $date = "".$row["date"]; $hits = "".$row["hits"]; $toplinks1 = mysql_db_query("$datab", "SELECT * FROM links WHERE id='".$links_id."'"); while ($row = mysql_fetch_array ($toplinks1)) { $navn = "".$row["navn"]; $url = "".$row["url"]; $nummar=$placering++; echo '<a href="javascript:void(0);" onclick="window.open(\''         . 'kikarin/redirect.php?link=' . $row['id']         . '\', \'linkname\', \'height=600,width=780,resizable=1,scrollbars=1\');">'         . $nummar . $row['navn']         . '</a> <br>';         } } ?>
  14. [quote author=sasa link=topic=106861.msg427949#msg427949 date=1157397017] $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"; [/quote] [i][b] Are these things attributs ?:[/b][/i] t.links_id t.hits total_hits l.navn l.url t
  15. I have a problem with a scipt that is suppose to show top-10 links with most hits past 7 days...... the problem is, that the same link can apear several times on the list, and i don't want that - hope someone can help me. THis is the script that update/insert the toplinks table: [color=blue]<?php    // Check if link exists   $link = false;   if (isset($_GET['link']) && (int)$_GET['link'] > 0) {         $sql_check = mysql_query('SELECT id, url, bolka_id  FROM links WHERE id = "' . (int)$_GET['link'] . '"') or die('Ikki funni&eth;2');     if (mysql_num_rows($sql_check) > 0) $link = mysql_fetch_array($sql_check);   }     if ($link) {         $cur_date = date('Y-m-d');     // Check link hits for current day     $sql_count = mysql_query('SELECT toplinks_id FROM toplinks WHERE links_id = "' . $link['id'] . '" AND date = "' . $cur_date . '"') or die('Ikki funni&eth;2');     if (mysql_num_rows($sql_count) > 0) {             // Link is already counted for current date       $result = mysql_fetch_row($sql_count);       @mysql_query('UPDATE toplinks SET hits = hits + 1 WHERE toplinks_id = "' . $result[0] . '"');           } else {             // Link is not counted for current date       @mysql_query('INSERT INTO toplinks (links_id, date, hits, bolka_id) VALUES("' . $link['id'] . '", "' . $cur_date . '", "1", "' . $link['bolka_id'] . '")');     }         // Redirect user     header('Location: ' . $link['url']);     exit();       } else {         echo 'Unable to find link - <a href="javascript:window.close();">Close Window</a>';   }   ?> [/color] This is the script where i select the top-10 links past 7 days: [color=red]<?PHP //Server connect ------------------------------------- $placering=1; $toplinks = mysql_db_query("$datab", 'select * FROM toplinks where date BETWEEN "' . date('Y-m-d') . '"" AND "' . date('Y-m-d', time()-604800) . '"'); while ($row = mysql_fetch_array ($toplinks)) { $toplinks_id = "".$row["toplinks_id"]; $links_id = "".$row["links_id"]; $date = "".$row["date"]; $hits = "".$row["hits"]; $toplinks1 = mysql_db_query("$datab", "SELECT * FROM links WHERE id='".$links_id."'"); while ($row = mysql_fetch_array ($toplinks1)) { $navn = "".$row["navn"]; $url = "".$row["url"]; $nummar=$placering++; echo '<a href="javascript:void(0);" onclick="window.open(\''         . 'kikarin/redirect.php?link=' . $row['id']         . '\', \'linkname\', \'height=600,width=780,resizable=1,scrollbars=1\');">'         . $nummar . $row['navn']         . '</a> <br>';         } } ?>[/color] Would be very thankful if someone can get it to work.... BTW as the scipt is now, nothing is showing in my website but an error-message, but even when there was something, on the list, links where dublicated.
×
×
  • 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.