smarty テンプレートファイルで mysql クエリを実行したい.......
ファイル拡張子は .html
すべてが正常に実行されているだけで、smarty変数なしで不完全なクエリを実行したいだけです
たとえば、$q1 = mysql_query("select *from class_users where id={$v.user_id}"); 動作していません
{$v.user_id} を php 変数に格納したい例: $var="{$v.user_id}";
<?php
$connect = mysql_connect("localhost","***","****") or die('error connecting: ' . mysql_error());
mysql_select_db("****") or die('error selecting db: ' . mysql_error()); //select database
?>
<div class="classified{if $v.highlited && $ads_settings.enable_highlited} highlited{/if} {if $v.featured && $ads_settings.enable_featured} featured{/if}" {if $v.highlited && $ads_settings.enable_highlited}style='background: {$ads_settings.highlited_color};'{/if}>
{if $v.featured && $ads_settings.enable_featured}<div class="featured-icon"></div>{/if}
{capture name=some_content assign=details_url}
{if $seo_settings.enable_mod_rewrite}{seo->makeDetailsLink p1=`$v.id` p2=`$v.title`}{else}{$live_site}/details.php?id={$v.id}{/if}
{/capture}
<div style="margin-left: {$ads_settings.thmb_width+10}px;">
<div>
<div class="classified_photo" style="width: {$ads_settings.thmb_width+10}px; margin-left: -{$ads_settings.thmb_width+10}px;">
<a href="{$details_url}" name="listing{$v.id}">
<img src="{$live_site}/{$v.image}" class="pic" id="pic{$v.id}" onmouseover="this.className='pic_over'" onmouseout="this.className='pic'" alt="{if $v.image_id}{$v.title|strip_tags:false|substr:0:100}{/if}" />
</a>
{if $v.rented && $ads_settings.enable_rented}<div class="rented" id="rented{$v.id}" style="display: none;"></div>{elseif $v.sold && $ads_settings.enable_sold}<div class="sold" id="sold{$v.id}" style="display: none;"></div>{/if}
</div>
<div class="classified_content">
<h3><a href="{$details_url}" id="title{$v.id}">{$v.title|wordwrap:70:" ":true}</a></h3>
{if $data_set=="cars"}<div class="listing_make">{$v.make} {$v.model}</div>{/if}
{if $ads_settings.enable_price && $v.price>=0}<span class="price">{$v.price_curr} </span>{/if}
{if $v.location_str}<span class="location">{if $v.location_str && $ads_settings.enable_price && $v.price>=0} | {/if}{$v.location_str}</span>{/if}{if $v.location_str || ($ads_settings.enable_price && $v.price>=0)}<br/>{/if}
<div class="small">{if $ads_settings.show_ad_date_for_everybody==1}{$lng.listings.added_on} {$v.date_nice}{else}{$lng.listings.posted}{/if} {$lng.general.to} <u>{$v.category}</u></div>
<p>{$v.description|truncate:200:"...":false|wordwrap:70:" ":true}</p>
<span class="classified_links">
{* if listings_compare *}
{if in_array("listings_compare", $modules_array)}
<a href="javascript:;" class="addcmpwin" id="cmp{$v.id}" {if in_array($v.id, $cmp)}style="display: none;"{/if}>{$lng_compare.add_to_compare}</a>
<a href="javascript:;" class="remcmpwin" id="remcmp{$v.id}" {if !in_array($v.id, $cmp)}style="display: none;"{/if}>{$lng_compare.rem_compare}</a>
{/if}
{* end if listings_compare *}
<a href="javascript:;" class="fshare" id="fshare{$v.id}">{$lng.listings.recommend_this}</a>
<a href="javascript:;" {if $self_noext=="favorites" || in_array($v.id, $fav_array)}style="display: none;"{/if} class="addtofav" id="fav{$v.id}">{$lng.listings.add_to_favourites}</a>
<a href="javascript:;" {if $self_noext!="favorites" && !in_array($v.id, $fav_array)}style="display: none;"{/if} class="remfav" id="remfav{$v.id}">{$lng.listings.remove_favourite}</a>
<a href="{$details_url}">{$lng.listings.details}</a>
{if ($logged_in || !$ads_settings.hide_contact_when_not_logged) && (!$v.sold || !$ads_settings.hide_contact_when_sold) && (!$v.rented || !$ads_settings.hide_contact_when_rented)} <a href="javascript:;" class="fmailto" id="mailto{$v.user_id}_{$v.id}">{$lng.general.contact}</a>{/if}
</span>
{if ($v.priority_name && $ads_settings.enable_priorities) || ($v.video && $v.enable_video && $ads_settings.enable_video)}
<table class="extra" cellpadding="0" cellspacing="0">
<tr>
{if $v.priority_name && $ads_settings.enable_priorities}
<td><div class="buttonwrapper"><div class="priority-left"><div class="priority-right">{$v.priority_name}</div></div></div></td><td> </td>
{/if}
{if $v.video && $v.enable_video && $ads_settings.enable_video}
<td><div class="buttonwrapper"><div class="video-left"><div class="video-right">{$lng.listings.short_video}</div></div></div></td>
{/if}
</tr>
</table>
{/if}
<div>
**<?php
$q1=mysql_query("select * from class_users where id={$v.user_id}");
while ($ev= mysql_fetch_object($q1)){
$did = "$ev->id";
$dname = "$ev->contact_name";
$drating = "$ev->rating";
$rating = round($drating);
$dnorating = "$ev->no_ratings";
$dphoto = "$ev->photo";
$dc = "$ev->company_name";
$store_banner = "$ev->store_banner";
$durl = preg_replace('~[^A-Za-z\d\s-]+~u', '', strtolower($dname));
$durl = str_replace(" ", "-", $durl);
$durls = "http://dealerspk.com/$did-$durl/store.html";
$dname = substr($dname, 0, 25);
$dcompany = substr($dc, 0, 30);
if ($photo){
$pict = "http://tatabata.com/uploads/photo/$photo";
}else{
$pict = "http://dealerspk.com/images/noimage.jpg";
}
}
?>**
</div>
</div><!-- end: classified_content -->
</div>
</div>
</div>