SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    May 2010
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    <? if column is empty insert this content ?> How?

    we have web directory script have 30000 links and some links haven't its keywords or details

    1- this is links table structure

    Code:
    CREATE TABLE IF NOT EXISTS `dn_links` (
    `id` int(10) unsigned NOT NULL auto_increment,
    `url` varchar(255) NOT NULL default '',
    `recip` varchar(255) NOT NULL default '',
    `title` varchar(255) NOT NULL default '',
    `description` varchar(255) NOT NULL default '',
    `detail` text NOT NULL,
    `keywords` text NOT NULL,
    Please add to us code that help us to do this

    <? if keyword filed is empty
    get_meta_tags($in[url]) and insert it to field
    ?>


    i hope you understand us

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,500
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Welcome to SP
    And no, I don't understand you very well.
    But it seems to me that you'd have to study a little bit. Try googling for 'php mysql tutorial', or read a bit around in the manuals:
    http://www.php.net/manual/en/
    http://dev.mysql.com/doc/refman/5.1/en/

  3. #3
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I thinks would be enough:
    PHP Code:
    $result mysql_query("SELECT id,url,keywords FROM dn_links") or die(mysql_error());
    if(
    mysql_num_rows($result) >= 1){
        while(
    $item mysql_fetch_object($result)){
            if(empty(
    $item->keywords)){
                
    $tags get_meta_tags($item->url);
                
    mysql_query("UPDATE dn_links SET keywords='" $tags['keywords'] . "' WHERE id=" $item->id) or die(mysql_error());
            }
        }

    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  4. #4
    SitePoint Member
    Join Date
    May 2010
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guido2004,
    My dear rajug
    thanks for code and it work very good but we faced small problem,

    A-data inserted like this ???? ????????? ? ????????
    database cp1256_general_ci and sites charset is windows-1256

    B-because our web directory have 30000 links
    1-this operation take too much time
    2-we get " Fatal error: Maximum execution time of 30 second exceeded "



    there is any fix to this ?

  5. #5
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For A:
    It seems you have some unicode characters in the table. Search in google for proper character set for your unicode characters.
    For B:
    This is obvious in such case. So better split the loop or use this script from cron job.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  6. #6
    SitePoint Member
    Join Date
    May 2010
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks rajug,
    it's work now but we have request please

    1-we have spider that import links from google but its import url, title and description, we want it import also keywords


    this is code
    Code:
    function spider_link($url,$title,$description,$keywords) {
    global $s;
    $s[x]++;
    echo '<tr>
    <td align="left" colspan="2"><span class="text13"><input class="bbb" type="checkbox" name="import_it[]" value="'.$s[x].'" checked> <a target="nove" href="'.$url.'">'.$title.'</a><br />'.$description.'<br /></td>
    </tr>
    <tr>
    <td align="left"><span class="text13">URL: </td>
    <td align="left"><input class="field10" name="url['.$s[x].']" style="width:550px" maxlength=255 value="'.$url.'"></td>
    </tr>
    <tr>
    <td align="left"><span class="text13">Title: </td>
    <td align="left"><input class="field10" name="title['.$s[x].']" style="width:550px" maxlength=255 value="'.$title.'"></td>
    </tr>
    <tr>
    <td align="left"><span class="text13">Description: </td>
    <td align="left"><input class="field10" name="description['.$s[x].']" style="width:550px" maxlength=255 value="'.replace_once_text($description).'"></td>
    </tr>
    <tr>
    <td align="left"><span class="text13">Keywords: </td>
    <td align="left"><input class="field10" name="keywords['.$s[x].']" style="width:550px" value="'.$keyword.'"></td>
    </tr>';
    }
    we tried to use this

    Code:
    function spider_link($url,$title,$description,$keywords) {
    global $s;
    $tags = get_meta_tags('.$url.');
    $s[x]++;
    echo '<tr>
    <td align="left" colspan="2"><span class="text13"><input class="bbb" type="checkbox" name="import_it[]" value="'.$s[x].'" checked> <a target="nove" href="'.$url.'">'.$title.'</a><br />'.$description.'<br /></td>
    </tr>
    <tr>
    <td align="left"><span class="text13">URL: </td>
    <td align="left"><input class="field10" name="url['.$s[x].']" style="width:550px" maxlength=255 value="'.$url.'"></td>
    </tr>
    <tr>
    <td align="left"><span class="text13">Title: </td>
    <td align="left"><input class="field10" name="title['.$s[x].']" style="width:550px" maxlength=255 value="'.$title.'"></td>
    </tr>
    <tr>
    <td align="left"><span class="text13">Description: </td>
    <td align="left"><input class="field10" name="description['.$s[x].']" style="width:550px" maxlength=255 value="'.replace_once_text($description).'"></td>
    </tr>
    <tr>
    <td align="left"><span class="text13">Keywords: </td>
    <td align="left"><input class="field10" name="keywords['.$s[x].']" style="width:550px" value="'.$tags.'"></td>
    </tr>';
    }
    to import keywords also but it's faild


    2-if this code like this to get new items in its template

    Code:
    { $table = $s[item_types_tables][$what];
      $data[$what][new_items] = create_in_files_get_new_items($what);
      $q = dq("select * from $s[pr]cats where use_for = '$what' AND visible = '1' AND level = '1' order by name",1);
    
    }
    
    if ($mark=='new_items') 
                     { //foreach ($item_array as $k5=>$v5) echo "$k5 - $v5<br>";
                if ($what=='links') $new_items[$what][$st][] = php_rebuild_parse_part('new_links_template.html',$st,$item_array);
    }
    how get new item in category number #72 ??
    we tried this but not work !!
    [CODE]

    Code:
    { $table = $s[item_types_tables][$what];
      $data[$what][new_cat_items] = create_in_files_get_new_items($what);
      $q = dq("select * from $s[pr]cats where use_for = '$what' AND visible = '1' AND level = '1'  AND id='72' order by name",1);
    
    }
    
    if ($mark=='new_cat_items') 
                     { //foreach ($item_array as $k5=>$v5) echo "$k5 - $v5<br>";
                if ($what=='links') $new_cat_items[$what][$st][] = php_rebuild_parse_part('new_links_cat_72_template.html',$st,$item_array);
    }

    can you help

  7. #7
    SitePoint Member
    Join Date
    May 2010
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now we tried and we solve keyword importer
    and now still one problem
    if this code like this to get new links or articles in its template

    Code:
    { $table = $s[item_types_tables][$what];
      $data[$what][new_items] = create_in_files_get_new_items($what);
      $q = dq("select * from $s[pr]cats where use_for = '$what' AND visible = '1' AND level = '1' order by name",1);
    
    }
    
    if ($mark=='new_items') 
                     { //foreach ($item_array as $k5=>$v5) echo "$k5 - $v5<br>";
                if ($what=='links') $new_items[$what][$st][] = php_rebuild_parse_part('new_links_template.html',$st,$item_array);
    }
    How get new links or article in category number #72 ??


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •