SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Aug 2009
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation while and fopen problem

    Hi everyone,

    I am trying to make static html page from dynamic b2b cms for SEO, I wrote the following script for create Html files of products list of each user:

    Code:
    // Start Company Name
    $result=mysql_query("SELECT es_company_name FROM db_profile where es_uid=$userid",$db);
    $company_name="$row['es_company_name'];"
    $directory=$company_name;
    // END Company Name
    
    // Start Product List 
    <?php $result=mysql_query("SELECT es_title, es_price,es_uid, es_id FROM db_offers where es_uid=$userid",$db);
    $productphps = array();
    for ($x=0; $x < mysql_num_rows($result); $x++)
    {
    $row= mysql_fetch_assoc($result);
    $producttitle=$row['es_title'];
    $productprice=$row['es_price'];
    $es_offer_id=$row['es_id'];
    
    $result_image=mysql_query("SELECT es_img_url, es_id FROM 
    db_offers_images where es_offer_id=$es_offer_id",$db);
    $images=$row['es_img_url'];
    
    // Category Name
    $result_category=mysql_query("SELECT es_category, es_id FROM 
    db_category where es_offer_id=$es_offer_id",$db);
    $category_name=$row['category'];
    // End Category Name
    
    // Start Child Category Name
    $result_category_id=mysql_query("SELECT es_id FROM 
    db_category where es_offer_id=$es_category",$db);
    $child_cat_id=$row['es_id'];
    $result_child_category=mysql_query("SELECT es_category FROM 
    db_category where es_offer_id=$child_cat_id",$db);
    $child_cat_name=$row['es_category'];
    
    // End Child Category Name
    
    // Srart Image of Product
    $result=mysql_query("SELECT es_title, es_price,es_uid, es_id FROM 
    db_offers_images where es_offer_id=$es_offer_id",$db);
    $images=$row['es_img_url'];
    // END Image of Product
    
    $productphps[] ="<table border=1px width='200px'><tr><td>
    <table border=0px width='100%'>
    <tr><td class='o'><font color='blue'>$images - $producttitle</font></td></tr>
    <tr><td color='green'><font color='green'>$productprice</font></td></tr>
    </table></td></tr></table>";
    }
     $finish = implode('<br>',$productphps);  
    // End Products List
    
    
    $productpage = fopen("$directory/$category_name/$child_cat_name/$productuid.html", "w");
    fputs($productpage, "
    <html>
    <body>
    <div>$finish</div>
    </body>
    </html>
    ");
    }?>
    :?: Ok, But problems are:

    1- $companyname : company names have some spaces between words so result of $companyname have error for use it to create a folder with name as $companyname , how can i remove the spaces from the $companyname?.

    2- $image and $category_name and $child_cat_name not working (i think its because of no use while).

    3- i tried to change output design (following code):

    Code:
    <table border=1px width='200px'><tr><td>
    <table border=0px width='100%'>
    <tr><td class='o'><font color='blue'>$images - $producttitle</font></td></tr>
    <tr><td color='green'><font color='green'>$productprice</font></td></tr>
    </table></td></tr></table>
    to same as products list page of alibaba web site but always i found error in result. could you let me know how can i make 3 columns and several rows by "FOR" when i must write it in $finish string?

    please let me have your kind helps.

    thank you very much for your kind attention.

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Why not just keep the page dynamic and use a .htaccess mod_rewrite to go to this page?

    By the way, completely changing a site for SEO is pointless - the gain is minimal and weighting differences for file names are minischule. There are alot of SEO rumours going around, most of which are complete nonsense.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Member
    Join Date
    Aug 2009
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for your message, this is my client's order. please help me in solve the problem of the script.

    Wait for your kind helps

  4. #4
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    A better solution is to have a .htaccess with the following:
    Code:
    RewriteEngine On
    RewriteRule ^/Products/([^/]+).html$ /showProducts.php?company=$1
    Then have the showProducts.php output based on the company name.

    this would mean that yoursite.com/Products/SomeCompany.html would redirect to showProducts.php?company=SomeCompany. This is to your client's wishes, as the URL will be as you choose. Search engines can't tell the difference.

    This means all data is up-to-date immediately, whereas file writes mean time delays and killing the server when you want to write all the files.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  5. #5
    SitePoint Member
    Join Date
    Aug 2009
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arkinstall View Post
    A better solution is to have a .htaccess with the following:
    Code:
    RewriteEngine On
    RewriteRule ^/Products/([^/]+).html$ /showProducts.php?company=$1
    Thank you for your help, but i don't undrestand the mean of it exactlly. does mean of it is all .php pages will change to .html pages dynamically?
    the addresses in the web site is:

    mydomain.com/business/view_details.php?browse=sell&id=xxx
    mydomain.com/business/view_details.php?browse=profile&id=xxx
    mydomain.com/business/view_details.php?browse=buy&id=xxx
    mydomain.com/business/view_details.php?browse=product&id=xxx
    mydomain.com/business/view_profile.php?id=xx

    also the web site have other application too. what is your solution offer? with your code could change all pages to .html?

    Wait for your kind help.

    Thank you for your kind attention.


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
  •