Jump to content

GamerGun

Members
  • Posts

    151
  • Joined

  • Last visited

Posts posted by GamerGun

  1. Fixed it. In the first script, which scrapes the data, i had:

     

    preg_match_all('=<p>(.*)</p>=siU', $result, $match, PREG_PATTERN_ORDER);
    $match = $match[1];
    foreach($match as $matches){
      $second = "<p>$matches</p>";
    echo $second;
    fwrite($fp, $second);
    }

     

    Which i changed to;

     

    preg_match_all('=<p>(.*)</p>=siU', $result, $match, PREG_PATTERN_ORDER);
    $match = $match[1];
    foreach($match as $matches){
      $second = "<p>$matches</p>\n";
    echo $second;
    fwrite($fp, $second);
    }

     

    (see the \n at $second)

     

    Now the text file looks like this;

     

    <h2>
    	Hooikoortssituatie gunstig 
        </h2><p><strong>Zeist - 11 juni 2010 - Het is vandaag bewolkt en buiig. Pollen die eventueel in de lucht komen worden er in het algemeen weer uitgespoeld. Na vandaag wordt de situatie een stuk minder gunstig.</strong></p>
    <p><strong>Vandaag</strong> is het overwegend bewolkt en vanmiddag ontstaan er enkele regen- en onweersbuien. Er komen niet veel pollen in de lucht en de lucht wordt af en toe schoon gespoeld.<br />
    <br />
    <strong>Morgen</strong> zijn er nog veel wolken en kan er lokaal nog een buitje vallen. Al met al komen er wel meer pollen in de lucht dan vandaag.</p>
    <p>Daarna is het overwegend droog en komt de zon er goed bij. Het aantal pollen in de lucht neemt toe.</p>
    <p> </p>
    <p><strong>Meer informatie vindt u op de </strong><a href="http://www.weeronline.nl/Europa/Hooikoorts-Nederland/135"><strong>hooikoortspagina </strong></a><strong>van WeerOnline.</strong><br />
    <br />
    <strong><br />
    </strong></p>
    <p><strong><img height="405" width="420" src="http://data.weeronline.nl/html/images/weernieuws/image/grassen.jpg" alt="" /><br />
    </strong> </p>
    <p> </p>
    

     

    Which allows me to delete the last 8 rows, without losing other text.

     

    Thanks!

  2. Well, i guess i got it. The output of the script i use is;

     

    <h2>
    	Hooikoortssituatie gunstig 
        </h2><p><strong>Zeist - 11 juni 2010 - Het is vandaag bewolkt en buiig. Pollen die eventueel in de lucht komen worden er in het algemeen weer uitgespoeld. Na vandaag wordt de situatie een stuk minder gunstig.</strong></p><p><strong>Vandaag</strong> is het overwegend bewolkt en vanmiddag ontstaan er enkele regen- en onweersbuien. Er komen niet veel pollen in de lucht en de lucht wordt af en toe schoon gespoeld.<br />
    <br />
    <strong>Morgen</strong> zijn er nog veel wolken en kan er lokaal nog een buitje vallen. Al met al komen er wel meer pollen in de lucht dan vandaag.</p><p>Daarna is het overwegend droog en komt de zon er goed bij. Het aantal pollen in de lucht neemt toe.</p><p> </p><p><strong>Meer informatie vindt u op de </strong><a href="http://www.weeronline.nl/Europa/Hooikoorts-Nederland/135"><strong>hooikoortspagina </strong></a><strong>van WeerOnline.</strong><br />
    <br />
    <strong><br />
    </strong></p><p><strong><img height="405" width="420" src="http://data.weeronline.nl/html/images/weernieuws/image/grassen.jpg" alt="" /><br />
    </strong> </p><p> </p>

     

    As you can see, the last 'blank lines' are because of the <p> constructions. So i have the str_replace these first, then i can go ahead with the rest...

     

    Also, the line with the link to their website is on the same line as the one i want to keep.

  3. It's missing another row.

     

    See; http://www.weeronline.nl/Go/GenericPages/WeatherSynopsis?synopsisCategory=WeatherForecastHayfeverExpectations

     

    I get the information from there.

     

    What i just don't want is (last 3 lines);

     

    The blank line

    The line with the image

    The line with the link to their site ("Meer informatie vindt u op de hooikoortspagina van WeerOnline.")

     

    But now with -2 its also deleting the line after "Morgen..."

     

    I'm clueless...

     

    (please note that this page changes every day, sometimes there is no blank line, sometimes there is, but the image and link to their site is always there).

  4. Hello y'all.

     

    I like to remove the last 2 lines from a flat file via PHP:

     

    <?php
    
    // Read the file into an array
    $lines = file('/home/mqxfaokl/domains/informatiehooikoorts.nl/public_html/hooikoortsverwachting.txt');
    
    // Pop the last item from the array
    array_pop($lines);
    
    // Join the array back into a string
    $file = join('', $lines);
    
    // Write the string back into the file 
    $file_handle = fopen('/home/mqxfaokl/domains/informatiehooikoorts.nl/public_html/hooikoortsverwachting.txt', 'w');
    fputs($file_handle, $file);
    fclose($file_handle);
    
    ?>

     

    This removes only the last line.

     

    Now i thought this would work;

     

    <?php
    
    // Read the file into an array
    $lines = file('/home/mqxfaokl/domains/informatiehooikoorts.nl/public_html/hooikoortsverwachting.txt');
    
    // Pop the last item from the array
    array_slice($lines, 0, -2);
    
    // Join the array back into a string
    $file = join('', $lines);
    
    // Write the string back into the file 
    $file_handle = fopen('/home/mqxfaokl/domains/informatiehooikoorts.nl/public_html/hooikoortsverwachting.txt', 'w');
    fputs($file_handle, $file);
    fclose($file_handle);
    
    ?>

     

    But it doesn't do a thing? Any idea?

     

    Thanks!

  5. Got it!

     

    <?php
    
    $userAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)";
    
    $curl_handle=curl_init();
    curl_setopt($curl_handle, CURLOPT_URL,'http://www.weeronline.nl/Go/GenericPages/WeatherSynopsis?synopsisCategory=WeatherForecastHayfeverExpectations');
    curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT,2);
    curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($curl_handle, CURLOPT_USERAGENT, $userAgent);
    curl_setopt($curl_handle, CURLOPT_FAILONERROR, true);
    curl_setopt($curl_handle, CURLOPT_AUTOREFERER, true);
    curl_setopt($curl_handle, CURLOPT_TIMEOUT, 10);
    $result = curl_exec($curl_handle);
    curl_close($curl_handle);
    
    preg_match_all('=<h1[^>]*>(.*)</h1>=siU', $result, $match, PREG_PATTERN_ORDER);
    $match = $match[1];
    foreach($match as $matches){
      echo "<h2>$matches</h2>";
    }
    
    preg_match_all('%<p>(.*?)</p>%', $result, $match, PREG_PATTERN_ORDER);
    $match = $match[1];
    foreach($match as $matches){
      echo "$matches<br /><br />";
    }
    
    ?>

     

    Thanks!

  6. Thanks, it works so far

     

    <?php
    
    $userAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)";
    
    $curl_handle=curl_init();
    curl_setopt($curl_handle, CURLOPT_URL,'http://www.weeronline.nl/Go/GenericPages/WeatherSynopsis?synopsisCategory=WeatherForecastHayfeverExpectations');
    curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT,2);
    curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($curl_handle, CURLOPT_USERAGENT, $userAgent);
    curl_setopt($curl_handle, CURLOPT_FAILONERROR, true);
    curl_setopt($curl_handle, CURLOPT_AUTOREFERER, true);
    curl_setopt($curl_handle, CURLOPT_TIMEOUT, 10);
    $result = curl_exec($curl_handle);
    curl_close($curl_handle);
    
    preg_match_all('%<p>(.*?)</p>%', $result, $match, PREG_PATTERN_ORDER);
    $match = $match[1];
    foreach($match as $matches){
      echo "$matches<br /><br />";
    }
    
    ?>

     

    I just don't get it to work with the h1 tags, when i replace <p> with <h1> and </p> with </h1> it outputs nothing...

     

    Any idea? Thx

  7. Dear,

     

    Currently i'm having the following code:

     

    <?php
    
    $userAgent = ‘Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)’;
    
    $curl_handle=curl_init();
    curl_setopt($curl_handle,CURLOPT_URL,'http://www.weeronline.nl/Go/GenericPages/WeatherSynopsis?synopsisCategory=WeatherForecastHayfeverExpectations');
    curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
    curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($curl_handle,CURLOPT_USERAGENT, $userAgent);
    curl_setopt($curl_handle, CURLOPT_FAILONERROR, true);
    curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($curl_handle, CURLOPT_AUTOREFERER, true);
    curl_setopt($curl_handle, CURLOPT_TIMEOUT, 10);
    $buffer = curl_exec($curl_handle);
    curl_close($curl_handle);
    
        print $buffer;
    ?>

     

    This does show the content from http://www.weeronline.nl/Go/GenericPages/WeatherSynopsis?synopsisCategory=WeatherForecastHayfeverExpectations

     

    Though, the only part i want is from:

     

    <h1>

    In het westen redelijk veel pollen

        </h1>

     

    'till

     

    <p class="author">

    Auteur: Marie-Jette Wierbos - 17 mei 2010 - 02:00

     

    </p>

     

    This, and everything in between, does change every day. So basically i want the text (no images and such) from the <h1> 'till the </p>

     

    Any idea how? Thanks!

  8. Hey all,

     

    I have created the following script:

     

    mailer.php

    <?php include '../header.php'; ?>
    
    <div id="content">
    <div id="contentleft">
    
    <h2>Nieuwsbrieven versturen</h2>
    
    <?php
    
        $inum1 = rand(0,255);
        $inum2 = rand(0,255);
        $inum3 = rand(0,255);
        $inum4 = rand(0,255);
        $ip = $inum1.'.'.$inum2.'.'.$inum3.'.'.$inum4;
    
    $sql = mysql_query('SELECT * FROM `nieuwsbrief` WHERE `bevestigd` = 1') or die(mysql_error());
    $num_rows = mysql_num_rows($sql)or die(mysql_error());
    
    while ($row = mysql_fetch_array($sql)) {
    
    $slp = $_POST["speed"];
    sleep($slp);
    $beste = $row["naam"];
    $to = $row["email"];
    
    $week = date('W');
    
    $subject = "Nieuwsbrief www.watmijoverkwam.nl week $week";
    $sender = "admin@watmijoverkwam.nl";
    
    $headers .= "From: $sender\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=utf-8\r\n";  
    $headers .= "Reply-To: $sender";
    
    $dezepagina = "<a href=\"http://watmijoverkwam.nl/afmelden.html\">afmeldpagina</a>.";
    $url = "<a href=\"http://watmijoverkwam.nl/\">http://watmijoverkwam.nl/</a>";
    
    $msg = $_POST["message"];
    
    $var1 = "Beste $beste,<br /><br />Hierbij sturen we je de nieuwste verhalen van afgelopen week.<br /><br />";
    $var2 = $msg;
    $var3 = "Je ontvangt deze nieuwsbrief omdat je bent aangemeld op $url.<br />Wil je deze nieuwsbrief niet meer ontvangen?<br />Meldt je dan af op de $dezepagina";
    $var4 = "<br /><br />Met vriendelijke groeten,<br />$url";
    
    $fullmsg = $var1.$var2.$var3.$var4;
    
    mail($to,$subject,$fullmsg,$headers);
    echo "Nieuwsbrief verzonden aan: " . $row["naam"] . " - " . $row["email"] . "<br />\n";
    }
    
    ?>
    
    <br />
    </div><!-- Closing contentleft -->
    
    <?php include '../menu.php'; ?>
    
    <?php include '../footer.php'; ?>
    
    </div>
    
    </body>
    </html>

     

    send.php

    <?php
    
    $corkey1 = "X";
    $corkey2 = "Y";
    
    $control1 = $_GET["key1"];
    $control2 = $_GET["key2"];
    
    if ( $control1 == $corkey1 && $control2 == $corkey2 ) {
    echo "";
    } else {
    echo "Ga weg!";
    die;
    }
    
    ?>
    
    <?php include '../header.php'; ?>
    
    <div id="content">
    <div id="contentleft">
    
    <h2>Nieuwsbrief opstellen</h2>
    
    <form id="mform" name="mform" method="post" action="mailer.php">
    Speed<br>
    <select name="speed">
      <option value="1">Insane</option>
      <option value="4">Fast</option>
      <option value="8" selected="selected">Normal</option>
      <option value="12">Slow</option>
    </select>
    <br>
    Message:<br>
    <textarea name="message" rows="25" cols="75" wrap="off">
    
    <?php
    
    $result = mysql_query("SELECT * FROM berichten WHERE TO_DAYS(NOW())-TO_DAYS(datum) <=7 ORDER BY id DESC") or die(mysql_error());
    
    function neat_trim($str, $n, $delim='...') { 
       $len = strlen($str); 
       if ($len > $n) { 
           preg_match('/(.{' . $n . '}.*?)\b/', $str, $matches); 
           return rtrim($matches[1]) . $delim; 
       } 
       else { 
           return $str; 
       } 
    }
    
    while($row = mysql_fetch_array($result)){ 
    
    $id = $row['id'];
    $message = $row['bericht'];
    $onderwerp = $row['onderwerp'];
        
    $titel = $row['titel'];
    $titel2 = eregi_replace(' ', '-', $titel);
    $titel2 = strtolower($titel2);
    
    $titellink = "<a href=\"http://watmijoverkwam.nl/$titel2-$id.html\">$titel</a>";
    $verderlezen = "<a href=\"http://watmijoverkwam.nl/$titel2-$id.html\">Lees verder</a>";
    
    echo $titellink;
    echo  " (";
    echo  $onderwerp;
    echo  ")";
    echo  "\n<br />";
    echo  neat_trim($message, 120);
    echo  "\n<br />";
    echo  $verderlezen;
    echo  "\n\n<br /><br />";
    
    }
    
    ?>
    
    </textarea>
    <br>
    <input type="submit" name="start sending" value="Start Sending" >
    </form>
    
    <br />
    </div><!-- Closing contentleft -->
    
    <?php include '../menu.php'; ?>
    
    <?php include '../footer.php'; ?>
    
    </div>
    
    <script language="JavaScript">document.mform.submit();</script>
    
    </body>
    </html>

     

    Send.php contains a form and such, from which the mail will send (default values from the form, the rest will get via the mailer.php).

     

    As you can see i did set 2 keys in send.php, which need to be filled in (like send.php?key1=X&key2=Y) in order for the script to work.

     

    This works all fine. As for the cronjob i enter:

     

    /usr/local/bin/php -q /home/mqxfaokl/domains/watmijoverkwam.nl/public_html/mail/send.php?key1=X&key2=Y

     

    Though, via the cronjob it does not work. Perhaps because the script needs some time to process the e-mails. How can i make sure that the cronjob does not 'kill' the script right along but waits 'till it is done loading the mailer.php file?

     

    Thanks in advance.

  9. You mean PREG_SPLIT_DELIM_CAPTURE  right?

     

    So i changed this line;

     

    $word_array = preg_split('/[\s?:;,.]+/', $keywords, -1, PREG_SPLIT_NO_EMPTY);

     

    Into this;

     

    $word_array = preg_split('/[\s?:;,.]+/', $keywords, -1, PREG_SPLIT_DELIM_CAPTURE);

     

    But the output is still the same?

     

    Thanks

  10. Dear,

     

    I'm having the following code:

     

    $result = mysql_query("SELECT bericht FROM berichten WHERE id = '$postid'") 
    or die(mysql_error());
    
    while($row = mysql_fetch_array( $result )) {
    
        $keywords = $row['bericht'];
    
    function longenough($s)
    {
    if ( strlen($s) < 5 ) { return false; }
    return true;
    }
    
    $arr = explode(" ", $keywords);
    $keywords = implode(" ", array_filter($arr, "longenough"));
    
    function first_words($keywords, $num, $tail='')
    {
            $words = str_word_count($keywords, 2);
            $firstwords = array_slice( $words, 0, $num);
            return implode(' ', $firstwords).$tail;
    }
    
    $keywords = first_words($keywords, 20);
    
    $bad_symbols = array(",", ".", "'", ";", ":", "?", "!", "_");
    $keywords = str_replace($bad_symbols, "", $keywords);
    
    $word_array = preg_split('/[\s?:;,.]+/', $keywords, -1, PREG_SPLIT_NO_EMPTY);
    $unique_word_array = array_unique($word_array);
    $keywords = implode(',',$unique_word_array);
    
    $keywords = strtolower($keywords);
    

     

    The idea is that this changes something like this (some Dutch story):

     

    Vanmorgen was ik op weg naar mijn werk. Om er te komen neem ik altijd de autoweg (100 km/u). Nu kwam ik een 45-km-wagentje tegen, welke helaas op zulke wegen mogen rijden. Het is nogal schrikken en gevaarlijk als je ineens zeer snel zo'n wagentje nadert. Gelukkig kon ik diegene nog ontwijken, maar het zal me niks verbazen als iemand die niet op zit te letten er achterop rijdt.

     

    Into this (keywords for Google and such):

     

    vanmorgen,werk,komen,altijd,autoweg,km,u,-km-wagentje,tegen,welke,helaas,zulke,wegen,mogen,rijden,nogal,schrikken,gevaarlijk,ineens,wagentje

     

    Most of the code works fine. As you can see it splits the string and only leaves the words which are 5 or more chars long.

     

    Then it takes the first 20 words, without any duplicates.

     

    So far okay, but why does it do this;

     

    (100 km/u) becomes km,u

    This should be 100 kmu or 100kmu

     

    45-km-wagentje becomes -km-wagentje

    This should be 45-km-wagentje

     

    And another word which is not in this part of text, but also is not correct;

     

    's ochtends becomes ochtends

    This should be sochtends

     

    Hope anyone can help me with this...

     

    Thanks in advance!

  11. I changed the entire code. Made use of: http://www.phpeasystep.com/phptu/29.html

     

    Here it is if anyone is interested:

     

    <?php $valid_ips = array('194.171.252.101','130.138.227.10','88.159.185.149');
    if (!in_array($_SERVER['REMOTE_ADDR'],$valid_ips)) {
        echo "<b>Binnenkort online!</b>";
        exit();
    }  ?>
    
    <?php include 'header.php'; ?>
    
    <div id="content">
    <div id="contentleft">
    
    <?php
    
    $tbl_name="berichten";
    
    $adjacents = 3;
    
    $targetpage = "index.php";
    $limit = 2;
    $page = $_GET['page'];
    
    if($page)
    $start = ($page - 1) * $limit;
    else
    $start = 0;
    
    $find = mysql_real_escape_string($_GET['find']);
    $search = mysql_real_escape_string($_GET['search']);
    
    $pieces = explode(" ", $find);
    
    if(!empty($search))
    {
        $result = mysql_query("SELECT * FROM berichten WHERE onderwerp LIKE '$search' ORDER BY id DESC LIMIT $start, $limit") 
        or die(mysql_error());
    
    $query = mysql_query("SELECT COUNT(*) as num FROM $tbl_name WHERE onderwerp LIKE '$search'")
        	or die(mysql_error());
    $total_pages = mysql_fetch_array($query);
    $total_pages = $total_pages[num];
    
    }
    elseif(!empty($pieces[0]) && !empty($pieces[1]))
    {
        $result = mysql_query("SELECT * FROM berichten WHERE bericht LIKE '%$pieces[0]%' OR bericht LIKE '%$pieces[1]%' ORDER BY id DESC LIMIT $start, $limit")
        or die(mysql_error());
    
    $query = mysql_query("SELECT COUNT(*) as num FROM $tbl_name WHERE onderwerp LIKE '%$pieces[0]%' OR bericht LIKE '%$pieces[1]%'")
        	or die(mysql_error());
    $total_pages = mysql_fetch_array($query);
    $total_pages = $total_pages[num];
    }
    elseif(!empty($pieces[0]) && empty($pieces[1]))
    {
        $result = mysql_query("SELECT * FROM berichten WHERE bericht LIKE '%$pieces[0]%' ORDER BY id DESC LIMIT $start, $limit")
        or die(mysql_error());
    
    $query = mysql_query("SELECT COUNT(*) as num FROM $tbl_name WHERE bericht LIKE '%$pieces[0]%'")
        	or die(mysql_error());
    $total_pages = mysql_fetch_array($query);
    $total_pages = $total_pages[num];
    
    }
    else
    {
        $result = mysql_query("SELECT * FROM berichten ORDER BY id DESC LIMIT $start, $limit")
        or die(mysql_error());
    
    $query = mysql_query("SELECT COUNT(*) as num FROM $tbl_name")
        	or die(mysql_error());
    $total_pages = mysql_fetch_array($query);
    $total_pages = $total_pages[num];
    
    }
    
    if ($page == 0) $page = 1;
    $prev = $page - 1;
    $next = $page + 1;
    $lastpage = ceil($total_pages/$limit);
    $lpm1 = $lastpage - 1;
    
    echo "<br /><a href=\"plaats.html\"><img src=\"images/melden_knop.jpg\" border=\"0\" alt=\"Plaats een verhaal\" /></a><br /><br />";
    
    ?>
    
    <?php
    
    if(!empty($search))
    {
       $keuze = "onderwerp-$search-pagina";
    }
    elseif(!empty($pieces[0]))
    {
       $keuze = "zoeken-$find-pagina";
    }
    else
    {
       $keuze = "pagina";
    }
    
    $pagination = "";
    if($lastpage > 1)
    {	
    	$pagination .= "<div class=\"pagination\">";
    	if ($page > 1) 
    		$pagination.= "<a href=\"$keuze-$prev.html\">« vorige</a>";
    	else
    		$pagination.= "<span class=\"disabled\">« vorige</span>";	
    
    	if ($lastpage < 7 + ($adjacents * 2))
    	{	
    		for ($counter = 1; $counter <= $lastpage; $counter++)
    		{
    			if ($counter == $page)
    				$pagination.= "<span class=\"current\">$counter</span>";
    			else
    				$pagination.= "<a href=\"$keuze-$counter.html\">$counter</a>";					
    		}
    	}
    	elseif($lastpage > 5 + ($adjacents * 2))
    	{
    		if($page < 1 + ($adjacents * 2))		
    		{
    			for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
    			{
    				if ($counter == $page)
    					$pagination.= "<span class=\"current\">$counter</span>";
    				else
    					$pagination.= "<a href=\"$keuze-$counter.html\">$counter</a>";					
    			}
    			$pagination.= "...";
    			$pagination.= "<a href=\"$keuze-$lpm1.html\">$lpm1</a>";
    			$pagination.= "<a href=\"$keuze-$lastpage.html\">$lastpage</a>";		
    		}
    		elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
    		{
    			$pagination.= "<a href=\"$keuze-1.html\">1</a>";
    			$pagination.= "<a href=\"$keuze-2.html\">2</a>";
    			$pagination.= "...";
    			for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
    			{
    				if ($counter == $page)
    					$pagination.= "<span class=\"current\">$counter</span>";
    				else
    					$pagination.= "<a href=\"$keuze-$counter.html\">$counter</a>";					
    			}
    			$pagination.= "...";
    			$pagination.= "<a href=\"$keuze-$lpm1.html\">$lpm1</a>";
    			$pagination.= "<a href=\"$keuze-$lastpage.html\">$lastpage</a>";		
    		}
    		else
    		{
    			$pagination.= "<a href=\"$keuze-1.html\">1</a>";
    			$pagination.= "<a href=\"$keuze-2.html\">2</a>";
    			$pagination.= "...";
    			for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
    			{
    				if ($counter == $page)
    					$pagination.= "<span class=\"current\">$counter</span>";
    				else
    					$pagination.= "<a href=\"$keuze-$counter.html\">$counter</a>";				
    			}
    		}
    	}
    
    	if ($page < $counter - 1) 
    		$pagination.= "<a href=\"$keuze-$next.html\">volgende »</a>";
    	else
    		$pagination.= "<span class=\"disabled\">volgende »</span>";
    	$pagination.= "</div>\n";		
    }
    
    ?>
    
    <?php
    
        include("includes/rating_functions.php");
    
        $numofrows = @mysql_num_rows($result);
        for($i = 0; $i < $numofrows; $i++)
        {
        $row = mysql_fetch_array( $result );
    
        $id = $row['id'];
        $message = $row['bericht'];
        $onderwerp = $row['onderwerp'];
        $titel = $row['titel'];
    
        $date_entered = date("d/m/Y", strtotime($row[datum]));
    
    $titel2 = eregi_replace(' ', '-', $titel);
    $titel2 = strtolower($titel2);
    
    	$onderwerp2 = strtolower($onderwerp);
    
    $opvragen = "SELECT COUNT(*) AS aantal FROM antwoorden WHERE postid = $id";
    $aantal2 = (mysql_query($opvragen));
    $getal = mysql_result($aantal2, 'aantal');
    
               if($i % 2)
                       {
                       $color = "brown";
               $hexcolor = "#e8d6b6";
                       }
               else
                       {
                       $color = "gray";
               $hexcolor = "#f4f4f4";
                       }
    
           echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"578\">";
           echo "<tr class=\"contentbox_top_".$color."\">";
           echo "<td height=\"54\"><strong><a href=\"../".$titel2."-".$id.".html\">$titel</a></strong> door Anoniem".$id." in <a href=\"../onderwerp-".$onderwerp2.".html\">".$onderwerp."</a> op ".$date_entered."</td>";
           echo "</tr>";
           echo "<tr bgcolor=\"".$hexcolor."\">";
           echo "<td>";
    echo $message;
           echo "<br /><br />";
           echo "<a href=\"vertel-$id.html\" target=\"arbitrade\" onclick=\"return !window.open(this.href, this.target, 'scrollbars,resizable,width=415,height=510');\">Vertel een vriend(in) hierover</a> - ";
           echo "<a href=\"../".$titel2."-".$id.".html\">Geef commentaar ($getal)</a><br /><br />";
           echo pullRating($id,true,true,true,NULL);
           echo "</td>";
           echo "</tr>";
           echo "<tr class=\"contentbox_bottom_".$color."\">";
           echo "<td height=\"17\"></td>";
           echo "</tr>";
           echo "</table>";
    
        }
    
        echo "<script type=\"text/javascript\">";
        echo "function popup(id){";
        echo "window.open('tell_a_friend.php?nummer=' + id +'','tellafriend_script','scrollbars=1,statusbar=1,resizable=1,width=400,height=510');}";
        echo "</script>";
    
    ?>
    
    <?=$pagination?>
    
    <br />
    
    </div><!-- Closing contentleft -->
    
    <?php include 'menu.php'; ?>
    
    <?php include 'footer.php'; ?>
    
    </div>
    
    </body>
    </html>

  12. Fixed it, changed the way of working but oh well:

     

    send.php

    <?php include '../header.php'; ?>
    
    <div id="content">
    <div id="contentleft">
    
    <h2>Nieuwsbrief opstellen</h2>
    <form method="post" action="mailer.php">
    Speed<br>
    <select name="speed">
      <option value="1">Insane</option>
      <option value="4">Fast</option>
      <option value="8" selected="selected">Normal</option>
      <option value="12">Slow</option>
    </select>
    <br>
    Message:<br>
    <textarea name="message" rows="25" cols="75" wrap="off">
    
    <?php
    
    $result = mysql_query("SELECT * FROM berichten WHERE TO_DAYS(NOW())-TO_DAYS(datum) <=14 ORDER BY id DESC") or die(mysql_error());
    
    function neat_trim($str, $n, $delim='...') { 
       $len = strlen($str); 
       if ($len > $n) { 
           preg_match('/(.{' . $n . '}.*?)\b/', $str, $matches); 
           return rtrim($matches[1]) . $delim; 
       } 
       else { 
           return $str; 
       } 
    }
    
    while($row = mysql_fetch_array($result)){ 
    
    $id = $row['id'];
    $message = $row['bericht'];
    $onderwerp = $row['onderwerp'];
        
    $titel = $row['titel'];
    $titel2 = eregi_replace(' ', '-', $titel);
    $titel2 = strtolower($titel2);
    
    $titellink = "<a href=\"http://domain/$titel2-$id.html\">$titel</a>";
    $verderlezen = "<a href=\"http://domain/$titel2-$id.html\">Lees verder</a>";
    
    echo $titellink;
    echo  " (";
    echo  $onderwerp;
    echo  ")";
    echo  "\n<br />";
    echo  neat_trim($message, 120);
    echo  "\n<br />";
    echo  $verderlezen;
    echo  "\n\n<br /><br />";
    
    }
    
    ?>
    
    </textarea>
    <br>
    <input type="submit" name="start sending" value="Start Sending" >
    </form>
    
    <br />
    </div><!-- Closing contentleft -->
    
    <?php include '../menu.php'; ?>
    
    <?php include '../footer.php'; ?>
    
    </div>
    
    </body>
    </html>
    

     

    mailer.php

    <?php include '../header.php'; ?>
    
    <div id="content">
    <div id="contentleft">
    
    <h2>Nieuwsbrieven versturen</h2>
    
    <?php
    
        $inum1 = rand(0,255);
        $inum2 = rand(0,255);
        $inum3 = rand(0,255);
        $inum4 = rand(0,255);
        $ip = $inum1.'.'.$inum2.'.'.$inum3.'.'.$inum4;
    
    $sql = mysql_query('SELECT * FROM `nieuwsbrief` WHERE `bevestigd` = 1') or die(mysql_error());
    $num_rows = mysql_num_rows($sql)or die(mysql_error());
    
    while ($row = mysql_fetch_array($sql)) {
    
    $slp = $_POST["speed"];
    sleep($slp);
    $beste = $row["naam"];
    $to = $row["email"];
    
    $week = date('W');
    
    $subject = "Nieuwsbrief www.domain week $week";
    $sender = "admin@domain";
    
    $headers = "From: $sender\r\n";
    $headers = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=utf-8\r\n";  
    $headers .= "Reply-To: $sender";
    
    $dezepagina = "<a href=\"http://domain/afmelden.html\">afmeldpagina</a>.";
    $url = "<a href=\"http://domain\">http://domain/</a>";
    
    $msg = $_POST["message"];
    
    $var1 = "Beste $beste,<br /><br />Hierbij sturen we je de nieuwste verhalen van afgelopen week.<br /><br />";
    $var2 = $msg;
    $var3 = "Je ontvangt deze nieuwsbrief omdat je bent aangemeld op $url.<br />Wil je deze nieuwsbrief niet meer ontvangen?<br />Meldt je dan af op de $dezepagina";
    $var4 = "<br /><br />Met vriendelijke groeten,<br />$url";
    
    $fullmsg = $var1.$var2.$var3.$var4;
    
    mail($to,$subject,$fullmsg,$headers);
    echo "Nieuwsbrief verzonden aan: " . $row["naam"] . " - " . $row["email"] . "<br />\n";
    }
    
    ?>
    
    <br />
    </div><!-- Closing contentleft -->
    
    <?php include '../menu.php'; ?>
    
    <?php include '../footer.php'; ?>
    
    </div>
    
    </body>
    </html>

  13. Well, i changed the code into this:

     

    <?php
    
    include 'config/connect.php';
    
    $sendmail = mysql_real_escape_string($_GET['sendmail']);
    
    if ($sendmail=="yes")
      {
    
    $from="admin@watmijoverkwam.nl";
    $table="nieuwsbrief";
    $table_email="email";
    $table_naam="naam";
    
    $resultquery = mysql_db_query($database, "select * from $table where bevestigd='1'");
    $result = mysql_query("SELECT * FROM berichten WHERE TO_DAYS(NOW())-TO_DAYS(datum) <=7 ORDER BY id DESC") or die(mysql_error());
    
    function neat_trim($str, $n, $delim='...') { 
       $len = strlen($str); 
       if ($len > $n) { 
           preg_match('/(.{' . $n . '}.*?)\b/', $str, $matches); 
           return rtrim($matches[1]) . $delim; 
       } 
       else { 
           return $str; 
       } 
    }
    
        while ($query = mysql_fetch_array($resultquery))
        {
    
        	$beste=$query[$table_naam];
    
    while($row = mysql_fetch_array($result)){
    
        	$headers  = "Van: $from\r\n";
        	$headers = "MIME-Version: 1.0\r\n";
        	$headers .= "Content-type: text/html; charset=utf-8\r\n"; 
    
    $subject = "Nieuwsbrief www.watmijoverkwam.nl";
    
    $body .= "Beste $beste,";
    $body .= "<br /><br />";
    $body .= "Hierbij sturen we je de nieuwste verhalen van afgelopen week.";
    $body .= "<br /><br />";
    
        	$id = $row['id'];
        	$message = $row['bericht'];
        	$onderwerp = $row['onderwerp'];
        	$titel = $row['titel'];
    
    $titel2 = eregi_replace(' ', '-', $titel);
    $titel2 = strtolower($titel2);
    
    $titellink = "<a href=\"http://watmijoverkwam.nl/$titel2-$id.html\">$titel</a>";
    $verderlezen = "<a href=\"http://watmijoverkwam.nl/$titel2-$id.html\">Lees verder</a>";
    $dezepagina = "<a href=\"http://watmijoverkwam.nl/afmelden.html\">afmeldpagina</a>";
    $url = "<a href=\"http://watmijoverkwam.nl/\">http://watmijoverkwam.nl/</a>";
    
    $body .= $titellink;
    $body .= " (";
    $body .= $onderwerp;
    $body .= ")";
    $body .= "<br />";
    $body .= neat_trim($message, 120);
    $body .= "<br />";
    $body .= $verderlezen;
    $body .= "<br /><br />";
    
    $body .= "Je ontvangt deze nieuwsbrief omdat je bent aangemeld op $url.";
    $body .= "<br />";
    $body .= "Wil je deze nieuwsbrief niet meer ontvangen?";
    $body .= "<br />";
    $body .= "Meldt je dan af op de ";
    $body .= $dezepagina;
    $body .= ".";
    
    $body .= "<br /><br />";
    $body .= "Met vriendelijke groeten,";
    $body .= "<br />";
    $body .= "$url";
    
    }
    
        	$mailto=$query[$table_email];
         	mail($mailto, $subject, $body, $headers);
    	echo 'Mail sent to '.$beste.' '.$mailto.'<br>';
            sleep($seconds);
        }
        echo 'Mails sent.';
      }
      else
      {
        echo 'Error.';
      }
      ?>

     

    The database contains:

     

    Name: A

    Email: A@A.com

     

    Name: B

    Email: B@B.com

     

    Name: C

    Email: C@C.com

     

    (All confirmed)

     

    When running the script, it says:

     

    Mail sent to A A@A.com

    Mail sent to B B@B.com

    Mail sent to C C@C.com

    Mails sent.

     

    So that is correct, but all the users (A, B and C) get an e-mail which says: Beste (Dear) A.

     

    So something goes wrong with the loop and the

     

    	$body .= "Beste $beste,";

     

    Any idea why?

     

    Thanks in advance.

  14. Dear,

     

    The following code is meant to send the same single 'letter' to all recipients (with an confirmed email address) within the database.

     

    This works, but unfortunately it screws up the 'sorting' of addresses and names, so that person X gets the name from person Y.

     

    The DB column is set up like this:

     

    ID - naam (name) - email - code - bevestigd (confirmed)

     

    Any idea on how to fix this? For the record; running this script outputs "Mail verzonden!" 3 times, which matches with the 3 valid email address within the database.

     

    Thanks in advance.

     

    Best regards,

     

    Tommy

     

    <?php 
    
    include 'config/connect.php';
    
    $sendmail = mysql_real_escape_string($_GET['sendmail']);
    
    if ($sendmail=="yes") {
    
        $result = mysql_query("SELECT * FROM berichten WHERE TO_DAYS(NOW())-TO_DAYS(datum) <=7 ORDER BY id DESC")
        or die(mysql_error());
    
    function neat_trim($str, $n, $delim='...') { 
       $len = strlen($str); 
       if ($len > $n) { 
           preg_match('/(.{' . $n . '}.*?)\b/', $str, $matches); 
           return rtrim($matches[1]) . $delim; 
       } 
       else { 
           return $str; 
       } 
    }
    
    $sql = "SELECT * FROM nieuwsbrief WHERE bevestigd = '1'";
    $query = mysql_query($sql);
    $num_rows = mysql_num_rows($query);
    if ($num_rows == 0){
    echo "Het databeest is boos...";
    }
    else 
    {
       while ($row = mysql_fetch_array($query))
       {
          $naam = $row['naam'];
          $email = $row['email'];
    
    $to = "$email";
    
    $from = "admin@watmijoverkwam.nl";
    
        $headers  = "Van: $from\r\n";
        $headers = "MIME-Version: 1.0\r\n";
        $headers .= "Content-type: text/html; charset=utf-8\r\n"; 
    
    $subject = "Nieuwsbrief www.watmijoverkwam.nl";
    
    $body .= "Beste $naam,";
    $body .= "<br /><br />";
    $body .= "Hierbij sturen we je de nieuwste verhalen van afgelopen week.";
    $body .= "<br /><br />";
    
    while($row = mysql_fetch_array($result)){
    
        $id = $row['id'];
        $message = $row['bericht'];
        $onderwerp = $row['onderwerp'];
        $titel = $row['titel'];
    
    $titel2 = eregi_replace(' ', '-', $titel);
    $titel2 = strtolower($titel2);
    
    $titellink = "<a href=\"http://watmijoverkwam.nl/$titel2-$id.html\">$titel</a>";
    $verderlezen = "<a href=\"http://watmijoverkwam.nl/$titel2-$id.html\">Lees verder</a>";
    $dezepagina = "<a href=\"http://watmijoverkwam.nl/afmelden.html\">afmeldpagina</a>";
    $url = "<a href=\"http://watmijoverkwam.nl/\">http://watmijoverkwam.nl/</a>";
    
    $body .= $titellink;
    $body .= " (";
    $body .= $onderwerp;
    $body .= ")";
    $body .= "<br />";
    $body .= neat_trim($message, 120);
    $body .= "<br />";
    $body .= $verderlezen;
    $body .= "<br /><br />";
    
    }
    
    $body .= "Je ontvangt deze nieuwsbrief omdat je bent aangemeld op $url.";
    $body .= "<br />";
    $body .= "Wil je deze nieuwsbrief niet meer ontvangen?";
    $body .= "<br />";
    $body .= "Meldt je dan af op de ";
    $body .= $dezepagina;
    $body .= ".";
    
    $body .= "<br /><br />";
    $body .= "Met vriendelijke groeten,";
    $body .= "<br />";
    $body .= "$url";
    
    mail($to, $subject, $body, $headers);
    
      echo "Mail verzonden!";
    
    }
       }
    
    } else {
    
      echo "We versturen niks!";
    
    }
    
    ?>

  15. Can anyone help please? I made the code a bit more neat, just don't know how to do the trick when there are many pages (see some posts higher).

     

    <?php include 'config/connect.php';
    
    $ITEMS_PER_PAGE = "2";
    
    $start = (isset($_GET['start']) && is_numeric($_GET['start'])) ? $_GET['start'] : 0;
    
    $find = mysql_real_escape_string($_GET['find']);
    $search = mysql_real_escape_string($_GET['search']);
    
    $pieces = explode(" ", $find);
    
    if(!empty($search))
    {
        $totaal = mysql_query("SELECT * FROM berichten WHERE onderwerp LIKE '$search' ORDER BY id DESC") 
        or die(mysql_error());
        $result = mysql_query("SELECT * FROM berichten WHERE onderwerp LIKE '$search' ORDER BY id DESC LIMIT $start,$ITEMS_PER_PAGE")
        or die(mysql_error());
        $totaalrecords = mysql_num_rows($totaal);
    }
    elseif(!empty($pieces[0]) && !empty($pieces[1]))
    {
        $totaal = mysql_query("SELECT * FROM berichten WHERE bericht LIKE '%$pieces[0]%' OR bericht LIKE '%$pieces[1]%' ORDER BY id DESC")
        or die(mysql_error());
        $result = mysql_query("SELECT * FROM berichten WHERE bericht LIKE '%$pieces[0]%' OR bericht LIKE '%$pieces[1]%' ORDER BY id DESC LIMIT $start,$ITEMS_PER_PAGE")
        or die(mysql_error());
        $totaalrecords = mysql_num_rows($totaal);
    }
    elseif(!empty($pieces[0]) && empty($pieces[1]))
    {
        $totaal = mysql_query("SELECT * FROM berichten WHERE bericht LIKE '%$pieces[0]%' ORDER BY id DESC")
        or die(mysql_error());
        $result = mysql_query("SELECT * FROM berichten WHERE bericht LIKE '%$pieces[0]%' ORDER BY id DESC LIMIT $start,$ITEMS_PER_PAGE")
        or die(mysql_error());
        $totaalrecords = mysql_num_rows($totaal);
    }
    else
    {
        $result = mysql_query("SELECT * FROM berichten ORDER BY id DESC LIMIT $start,$ITEMS_PER_PAGE")
        or die(mysql_error());
        $result2 = mysql_query("SELECT * FROM berichten ORDER BY id DESC")
        or die(mysql_error());
        $totaalrecords = mysql_num_rows($result2);
    }
    
    echo "<br /><a href=\"plaats.html\"><img src=\"images/melden_knop.jpg\" border=\"0\" alt=\"Plaats een verhaal\" /></a><br /><br />";
    
    $link = $start + $ITEMS_PER_PAGE;
    
    if(!empty($search))
    {
       $keuze = "onderwerp-$search-pagina";
    }
    elseif(!empty($pieces[0]))
    {
       $keuze = "zoeken-$find-pagina";
    }
    else
    {
       $keuze = "pagina";
    }
    
        include("includes/rating_functions.php");
    
        $numofrows = @mysql_num_rows($result);
        for($i = 0; $i < $numofrows; $i++)
        {
        $row = mysql_fetch_array( $result );
    
        $id = $row['id'];
        $message = $row['bericht'];
        $onderwerp = $row['onderwerp'];
        $titel = $row['titel'];
    
        $date_entered = date("d/m/Y", strtotime($row[datum]));
    
    $titel2 = eregi_replace(' ', '-', $titel);
    $titel2 = strtolower($titel2);
    
    	$onderwerp2 = strtolower($onderwerp);
    
    $opvragen = "SELECT COUNT(*) AS aantal FROM antwoorden WHERE postid = $id";
    $aantal2 = (mysql_query($opvragen));
    $getal = mysql_result($aantal2, 'aantal');
    
               if($i % 2)
                       {
                       $color = "brown";
               $hexcolor = "#e8d6b6";
                       }
               else
                       {
                       $color = "gray";
               $hexcolor = "#f4f4f4";
                       }
    
           echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"578\">";
           echo "<tr class=\"contentbox_top_".$color."\">";
           echo "<td height=\"54\"><strong><a href=\"../".$titel2."-".$id.".html\">$titel</a></strong> door Anoniem".$id." in <a href=\"../onderwerp-".$onderwerp2.".html\">".$onderwerp."</a> op ".$date_entered."</td>";
           echo "</tr>";
           echo "<tr bgcolor=\"".$hexcolor."\">";
           echo "<td>";
    echo $message;
           echo "<br /><br />";
           echo "<a href=\"javascript:popup('$id')\">Vertel een vriend(in) hierover</a> - ";
           echo "<a href=\"../".$titel2."-".$id.".html\">Geef commentaar ($getal)</a><br /><br />";
           echo pullRating($id,true,true,true,NULL);
           echo "</td>";
           echo "</tr>";
           echo "<tr class=\"contentbox_bottom_".$color."\">";
           echo "<td height=\"17\"></td>";
           echo "</tr>";
           echo "</table>";
    
        }
    
        echo "<script type=\"text/javascript\">";
        echo "function popup(id){";
        echo "window.open('tell_a_friend.php?nummer=' + id +'','tellafriend_script','scrollbars=1,statusbar=1,resizable=1,width=400,height=510');}";
        echo "</script>";
    
    if ( $start+$ITEMS_PER_PAGE<$totaalrecords ) {
    echo "<a href=\"$keuze-$link.html\">Volgende pagina »</a>";
    }
    
    echo "<br />";
    
    $nummer = "1";
    for ( $counter = 0; $counter < $totaalrecords; $counter += $ITEMS_PER_PAGE ) {
    echo "<a href=\"$keuze-$counter.html\">$nummer</a> ";
    $nummer = $nummer +1;
    }
    
        ?>

  16. Can't edit my message?

     

    Here is my current code, made some changes:

     

     <?php include 'config/connect.php';
    
    $ITEMS_PER_PAGE = "2";
    
    $start = (isset($_GET['start']) && is_numeric($_GET['start'])) ? $_GET['start'] : 0;
    
    $find = mysql_real_escape_string($_GET['find']);
    $search = mysql_real_escape_string($_GET['search']);
    
    $pieces = explode(" ", $find);
    
    if(!empty($search))
    {
        $totaal = mysql_query("SELECT * FROM berichten WHERE onderwerp LIKE '$search' ORDER BY id DESC") 
        or die(mysql_error());
        $result = mysql_query("SELECT * FROM berichten WHERE onderwerp LIKE '$search' ORDER BY id DESC LIMIT $start,$ITEMS_PER_PAGE")
        or die(mysql_error());
        $totaalrecords = mysql_num_rows($totaal);
    }
    elseif(!empty($pieces[0]) && !empty($pieces[1]))
    {
        $totaal = mysql_query("SELECT * FROM berichten WHERE bericht LIKE '%$pieces[0]%' OR bericht LIKE '%$pieces[1]%' ORDER BY id DESC")
        or die(mysql_error());
        $result = mysql_query("SELECT * FROM berichten WHERE bericht LIKE '%$pieces[0]%' OR bericht LIKE '%$pieces[1]%' ORDER BY id DESC LIMIT $start,$ITEMS_PER_PAGE")
        or die(mysql_error());
        $totaalrecords = mysql_num_rows($totaal);
    }
    elseif(!empty($pieces[0]) && empty($pieces[1]))
    {
        $totaal = mysql_query("SELECT * FROM berichten WHERE bericht LIKE '%$pieces[0]%' ORDER BY id DESC")
        or die(mysql_error());
        $result = mysql_query("SELECT * FROM berichten WHERE bericht LIKE '%$pieces[0]%' ORDER BY id DESC LIMIT $start,$ITEMS_PER_PAGE")
        or die(mysql_error());
        $totaalrecords = mysql_num_rows($totaal);
    }
    else
    {
        $result = mysql_query("SELECT * FROM berichten ORDER BY id DESC LIMIT $start,$ITEMS_PER_PAGE")
        or die(mysql_error());
        $result2 = mysql_query("SELECT * FROM berichten ORDER BY id DESC")
        or die(mysql_error());
        $totaalrecords = mysql_num_rows($result2);
    }
    
    echo "<br><a href=\"plaats.html\"><img src=\"images/melden_knop.jpg\" border=\"0\" /></a><br><br>";
    
    $link = $start + $ITEMS_PER_PAGE;
    
    if(!empty($search))
    {
       $keuze = "onderwerp-$search-pagina";
    }
    elseif(!empty($pieces[0]))
    {
       $keuze = "zoeken-$find-pagina";
    }
    else
    {
       $keuze = "pagina";
    }
    
    if ( $start+$ITEMS_PER_PAGE<$totaalrecords ) {
    echo "<a href=\"$keuze-$link.html\">next $ITEMS_PER_PAGE »</a>";
    }
    
    echo "<br>";
    
    $nummer = "1";
    for ( $counter = 0; $counter < $totaalrecords; $counter += $ITEMS_PER_PAGE ) {
    echo "<a href=\"$keuze-$counter.html\">pagina $nummer</a> ";
    $nummer = $nummer +1;
    }
    
        include("includes/rating_functions.php");
    
        $numofrows = @mysql_num_rows($result);
        for($i = 0; $i < $numofrows; $i++)
        {
        $row = mysql_fetch_array( $result );
    
        $id = $row['id'];
        $message = $row['bericht'];
        $onderwerp = $row['onderwerp'];
        $titel = $row['titel'];
    
    $titel2 = eregi_replace(' ', '-', $titel);
    $titel2 = strtolower($titel2);
    
    	$onderwerp2 = strtolower($onderwerp);
    
    $opvragen = "SELECT COUNT(*) AS aantal FROM antwoorden WHERE postid = $id";
    $aantal2 = (mysql_query($opvragen));
    $getal = mysql_result($aantal2, 'aantal');
    
               if($i % 2)
                       {
                       $color = "brown";
               $hexcolor = "#e8d6b6";
                       }
               else
                       {
                       $color = "gray";
               $hexcolor = "#f4f4f4";
                       }
           echo "<table border=\"0\" bordercolor=\"#FF0000\" cellpadding=\"0\" cellspacing=\"0\" width=\"578\">";
           echo "<tr class=\"contentbox_top_".$color."\">";
           echo "<td height=\"54\"><b><a href=\"../".$titel2."-".$id.".html\">$titel</a></b> door Anoniem".$id." in <a href=\"../onderwerp-".$onderwerp2.".html\">".$onderwerp."</a> op ".$row['datum']."</td>";
           echo "</tr>";
           echo "<tr BGCOLOR=\"".$hexcolor."\">";
           echo "<td>";
    echo $message;
           echo "<br><br>";
           echo "<a href=\"javascript:popup('$id')\">Vertel een vriend(in) hierover</a> - ";
           echo "<a href=\"../".$titel2."-".$id.".html\">Geef commentaar ($getal)</a><br><br>";
           echo pullRating($id,true,true,true,NULL);
           echo "</td>";
           echo "</tr>";
           echo "<tr class=\"contentbox_bottom_".$color."\">";
           echo "<td height=\"17\"></td>";
           echo "</tr>";
           echo "</table>";
    
        }
    
        echo "<script type=\"text/javascript\">";
        echo "function popup(id){";
        echo "window.open('tell_a_friend.php?nummer=' + id +'','tellafriend_script','scrollbars=1,statusbar=1,resizable=1,width=400,height=510');}";
        echo "</script>";
    
    
        ?> 

  17. Apart from that, thanks to a friend i got it working (via a different way though).

     

        $result2 = mysql_query("SELECT * FROM berichten ORDER BY id DESC")
        or die(mysql_error());
        $totaalrecords = mysql_num_rows($result2);
    
    $ITEMS_PER_PAGE = "3";
    
    $start = (isset($_GET['start']) && is_numeric($_GET['start'])) ? $_GET['start'] : 0;
    
    if ( $start+$ITEMS_PER_PAGE<$totaalrecords ) {
    echo "<a href=\"index.php?start=$link\">next 3 »</a>";
    }
    
    $nummer = "1";
    for ( $counter = 0; $counter <= $totaalrecords; $counter += $ITEMS_PER_PAGE ) {
    echo "<a href=\"index.php?start=$counter\">pagina $nummer</a> ";
    $nummer = $nummer +1;
    } 

     

    This outputs (i have 7 records at the moment)

     

    index.php?start=0

    next 3 »

    page 1 page 2 page 3

     

    index.php?start=3

    next 3 »

    page 1 page 2 page 3

     

    index.php?start=6

    page 1 page 2 page 3

     

    So that's fine. Only thing i want is, instead of page 1 till 1500 (in the far future), something like this;

     

    1 - 2 - 3 ... 120 - 121 - 122

     

    When you are on page 15, it will show 12 - 13 - 14 ... 120 - 121 - 122.

     

    Can anyone help me with that?

     

    Thanks!

  18. BTW, i was thinking about what you said concerning validating all query results, but i'm not kinda sure how to do that.

     

    Let's say i have this code;

     

        $result = mysql_query("SELECT * FROM berichten ORDER BY id DESC")
        or die(mysql_error());
    
        $numofrows = @mysql_num_rows($result);
        for($i = 0; $i < $numofrows; $i++)
        {
        $row = mysql_fetch_array( $result );
    
        $id = $row['id'];
        $message = $row['bericht'];
        $onderwerp = $row['onderwerp'];
        $titel = $row['titel'];
    
        }
    

     

    How would i add the if statement then to check it?

     

    Like this?

     

        $result = mysql_query("SELECT * FROM berichten ORDER BY id DESC") or die(mysql_error());
    if ($row = mysql_query($result)) {
      if (mysql_num_rows($row)) {
    
        $id = $row['id'];
        $message = $row['bericht'];
        $onderwerp = $row['onderwerp'];
        $titel = $row['titel'];
    
      } else {
        // no results where found
      }
    } else {
      // an error occurred, handle it.
    }
    

     

    Thanks

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