Page 1 of 1

while and fopen problem

Posted: Thu Aug 13, 2009 6:46 am
by persia
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: Select all

 
// 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: Select all

<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 following 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?

Sample design:
http://tianshi.en.alibaba.com/productlist.html
[attn: without check boxes in design]

please let me have your kind helps.

thank you very much for your kind attention.