Jump to content
Sign in to follow this  
erlan1980

Как задать стиль в php переменные

Recommended Posts

Добрый день коллеги,

Второй день борюсь с этим.

Вобщем есть  php файл в нем содержатся переменные. и файл css.

при выдаче echo $resultstring как сделать чтобы стили css привязать к переменным.

Надо сделать чтобы $res['cat_name'] был class ="desc" а в переменных $res['price'] и $name задать class="headings"

 

а то получается все в один ряд друг за другом выдаются

 

Вот файл файл PHP

 

<p id="style">

<?php
if(file_exists("../../../../kernel/wbs.xml")) { $xmlfile_wbs = '../../../../kernel/wbs.xml'; $xmlcontent_wbs = simplexml_load_file($xmlfile_wbs); $dbkey = $xmlcontent_wbs->FRONTEND['dbkey']; $host = $xmlcontent_wbs->SQLSERVERS[0]->SQLSERVER['HOST']; } else {exit("ERROR: Could not connect to the database. No wbs FILE");} if(file_exists("../../../../dblist/".$dbkey.".xml") &&$dbkey) { $xmlfile = '../../../../dblist/'.$dbkey.'.xml'; $xmlcontent = simplexml_load_file($xmlfile); if(!$host) {$host = $xmlcontent->DBSETTINGS['SQLSERVER'];} $name = $xmlcontent->DBSETTINGS['DB_USER']; $pass = $xmlcontent->DBSETTINGS['DB_PASSWORD']; $dbase = $xmlcontent->DBSETTINGS['DB_NAME']; } else {exit("ERROR: Could not connect to the database. No dbkey FILE");} $resultstring = ''; $dbconfig = mysql_connect($host,$name,$pass); mysql_select_db($dbase,$dbconfig); if(!$dbconfig) { $resultstring = 'ERROR: Could not connect to the database'; } else { if(isset($_POST['queryString'])) { $queryString = $_POST['queryString']; if(strlen($queryString) >0) { $queryString = iconv("utf-8","windows-1251",$queryString); mysql_query("SET NAMES 'cp1251'"); $sql = "SELECT prod.categoryID AS p_cat_id, prod.name_ru AS name, product_code, prod.description_ru AS description, cat.name_ru AS cat_name, prod.productID AS prodid, prod.Price AS price, prod.slug AS slug FROM SC_products AS prod INNER JOIN SC_categories AS cat ON (prod.categoryID = cat.categoryID) WHERE prod.categoryID != 1 AND prod.name_ru LIKE '%".$queryString."%' OR product_code LIKE '%".$queryString."%' ORDER BY prod.categoryID LIMIT 20"; if($r = mysql_query($sql)) { if(mysql_num_rows($r) >0) { $catid = 0; while($res = mysql_fetch_assoc($r)) { if($res['p_cat_id'] != $catid)

{ $resultstring .= ''.$res['cat_name'].''; $catid = $res['p_cat_id']; } $resultstring .= '';



$prodimg = mysql_fetch_assoc(mysql_query("SELECT thumbnail FROM SC_product_pictures WHERE productID = '".$res['prodid']."' AND priority = 0 LIMIT 1")); if($prodimg['thumbnail']) { $resultstring .= ''; } $name = $res['name']; if(strlen($name) >100) { $name = substr($name,0,35)."..."; } $resultstring .= ''.$name.' '.$res['price'].' '.iconv("utf-8","windows-1251","тенге").' '; } } else {$resultstring .= ''.iconv("utf-8","windows-1251","Ничего не найдено").'
';} } else {$resultstring = 'ERROR: There was a problem with the query.';} } } else {$resultstring = 'There should be no direct access to this script!';} $resultstring = iconv("windows-1251","utf-8",$resultstring); $resultstring = '
'.$resultstring.'

'; } echo $resultstring; ;

?>
<p>

 

Заранее благодарю

Share this post


Link to post
Share on other sites

вы уверены, что обратились по адресу?

У вас точно openCart?

Share this post


Link to post
Share on other sites

вы уверены, что обратились по адресу?

У вас точно openCart?

это часть скрипта интернет магазина

Share this post


Link to post
Share on other sites

Я вижу, что не блога, но не все интернет магазины работают на opencart, а у вас, судя по коду, какая-то версия, возможно webasyst или shopscript

Share this post


Link to post
Share on other sites

Я вижу, что не блога, но не все интернет магазины работают на opencart, а у вас, судя по коду, какая-то версия, возможно webasyst или shopscript

да вы правы это вебасист

Share this post


Link to post
Share on other sites

сделать чтобы $res['cat_name'] был class ="desc" а в переменных $res['price'] и $name задать class="headings"

$res['cat_name']="class ='desc'";

$res['price']="class='headings'";$name="class='headings'"

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.