Jump to content

kevin_007

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Posts posted by kevin_007

  1. Hello, can any1 show me how to insert the following in db

    
    <?php
    include('dbconnect.php');
    include('simple_html_dom.php');
    $html = file_get_dom('test3.php');
    foreach($html->find('h2') as $heading)
    		{
    			//echo $heading;
    			foreach ($heading->find('a') as $link)
    			{
                                           $item_title = md5($link);
    				echo $link."<br/>";
    				$sql = "INSERT INTO articles(article_id, article_link) VALUES($item_title, $link)";
    				$result = mysql_query($sql);
    			}
    		}
    ?>
    
    

    what i want to do is insert every link in the db, but this is not working. The output is ok but the insert doesnt work. Any help please??

  2. I would personally suggest trying to do most of this using jQuery or simular. You could do:

     

    $.(document).ready(function(){
        $.each("h2").html("Title 1", function(){
            $(this).html("Replaced Text");
        });
    });
    

     

    However, I'm not overly good with jQuery so you may want to edit that to make it work properly. :)

     

    Hope this helps.

     

    DarkMantis

     

    I don't want to use Jquery because the page is an online page which i find it easier to work with simple html dom library and i don't know JQuery too much. Is it possible to check the value of h2 using simple html dom library?

  3. suppose a page has the following tags

    <div class = "news">
    <div class = "article">
    <h2>title 1</h2>
    <div class = "content">
    <p>content 1....</p>
    </div>
    </div>
    <div class = "article">
    <h2>title 2</h2>
    <div class = "content">
    <p>content 2....</p>
    </div>
    </div>
    </div>
    

    is it possible to check, using simple html dom library, whether the value of <h2> is title 1 and then if it is echo it, or store it in a variable?

    what i've been able to do up to now is:

    <?php

    include('simple_html_dom.php');

    foreach($article->find('div[class=news]') as $news)

    {

    foreach ($news->find('div[class=article]') as $content)

    {

    foreach ($content->find('h2') as $heading)

    {

    echo $heading;

     

    }

    }

    }

    ?>

     

    this only echos all the h2

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