Това ми е едно скриптче...
Проблева е че този код трябва да се направи с WHILE :
аз пробвах нещо ама нестана... моля за помощ...
Код:
<?php
include "currency.php";
$hedlines=$_GET['hedlines'];
// Include the news class (needed to display news)
include "Classes/news.class.php";
$Template = (isset($_GET['Template']) ? $_GET['Template'] : 'Default');
// This example includes news display with readmore functions
$Dir = NULL;
function GetTemplateS($whattemp,$Template,$abpath,$catlist=NULL,$catlist1=NULL)
{
// Start Sub Function
$thetemp = "";
// Check if the template exists
// Grab the template specified
if (!is_dir($abpath . "Templates/" . $Template))
{
//starting directory
$startDir = $abpath . "Templates";
//open directory
// Silently to error Trap - TSL
if ($openDir = @opendir($startDir))
{
while($path = readdir($openDir))
{
//gets the base name of file i.e instead of /home/canivour/html/index.html its index.html
$file = basename($path);
//makes sure we dont we read the . and .. direcotry (current directory and parent directory)
if($file!="." && $file!="..")
{
//if its not a directory print out the stats (can be changed for your needs)
if(is_dir($startDir."/".$file))
{
$fullDir = $startDir."/".$file; //full directory path of file
$statCheck = stat($fullDir); //keeps info on file
$Dir = $file;
}
}
}
}
// End search for new template set
echo "<Br><font color=red><b>Error,</b> Could Not Find: \"<i>Templates/" . $Template . "/" . $whattemp . "\"</i>.<br>";
$Template = $Dir;
echo "Using: \"<i>Templates/" . $Template . "/" . $whattemp . "\"</i> Instead.</font><br>";
}
$file = @fopen($abpath . "Templates/" . $Template . "/" . $whattemp, "r")
or die("<Br><font color=red><b>Error,</b> Failed to Open: \"<i>Templates/" . $Template . "/" . $whattemp . "\"</i>.<br>");
$thetemp .= @fread($file, 200000);
@fclose($file);
$CatList = $catlist;
$thetemp = addslashes($thetemp);
eval("\$thetemp = \"$thetemp\";");
$thetemp = stripslashes($thetemp);
// Send back the template
return $thetemp;
// End Sub Function
}
include "Config/mysql.php";
$dbl = @mysql_connect($hn, $un, $pw);
mysql_select_db($db); $chars="SET CHARACTER SET cp1251";mysql_query($chars);
// -----------------------------------------------------------------
$catlist = NULL;
$sqles2 = mysql_query("SELECT * FROM " . $tprefix . "news WHERE category ='55'");
if ($sqles2)
{
while($row = mysql_fetch_array($sqles2))
{
$price=$row[price];
$oldprice=$row[oldprice];
$currency2=$row[currency];
$query="SELECT `leva` FROM " . $tprefix . "finansi WHERE id ='2'";
$result=mysql_query($query);
$euro=mysql_result($result,0,"leva");
$query="SELECT `leva` FROM " . $tprefix . "finansi WHERE id ='1'";
$result=mysql_query($query);
$usd=mysql_result($result,0,"leva");
$currency=$_POST[currency];
$rest=$_POST[B2];
if ($rest=="Reset"){$currency="";
$currency1=$currency2;}
if ($currency==""){$price2=$price;
$currency1=$currency2;}
else{
if($currency=="EUR"){
if($currency2=="USD"){
$price2=round($price*$euro/$usd,2);
$oldprice=round($oldprice*$euro/$usd,2);
}
if($currency2=="LEV"){
$price2=round($price/$euro,2);
$oldprice=round($oldprice/$euro, 2);
}if($currency2=="EUR"){
$price2=round($price,2);
$oldprice=round($oldprice, 2);
}$currency1=$currency;}
if($currency=="USD"){
if($currency2=="USD"){
$price2=round($price,2);
$oldprice=round($oldprice,2);
}
if($currency2=="LEV"){
$price2=round($price/$usd,2);
$oldprice=round($oldprice/$usd, 2);
}
if($currency2=="EUR"){
$price2=round($price*$usd/$euro,2);
$oldprice=round($oldprice*$usd/$euro, 2);
}$currency1=$currency;}
if($currency=="LEV"){
if($currency2=="USD"){
$price2=round($price*$usd,2);
$oldprice=round($oldprice*$usd,2);
}
if($currency2=="LEV"){
$price2=round($price,2);
$oldprice=round($oldprice, 2);
}
if($currency2=="EUR"){
$price2=round($price*$euro,2);
$oldprice=round($oldprice*$euro, 2);
}$currency1=$currency;}
}
$price2=round($price2,2);
$catlist .= "<option value=\"" . $price2 . "\">" . $row['news'] . "</option>\n";
}
}
$sqles2 = mysql_query("SELECT * FROM " . $tprefix . "news WHERE category='56'");
if ($sqles2)
{
while($row = mysql_fetch_array($sqles2))
{
$price=$row[price];
$oldprice=$row[oldprice];
$currency2=$row[currency];
$query="SELECT `leva` FROM " . $tprefix . "finansi WHERE id ='2'";
$result=mysql_query($query);
$euro=mysql_result($result,0,"leva");
$query="SELECT `leva` FROM " . $tprefix . "finansi WHERE id ='1'";
$result=mysql_query($query);
$usd=mysql_result($result,0,"leva");
$currency=$_POST[currency];
$rest=$_POST[B2];
if ($rest=="Reset"){$currency="";
$currency1=$currency2;}
if ($currency==""){$price2=$price;
$currency1=$currency2;}
else{
if($currency=="EUR"){
if($currency2=="USD"){
$price2=round($price*$euro/$usd,2);
$oldprice=round($oldprice*$euro/$usd,2);
}
if($currency2=="LEV"){
$price2=round($price/$euro,2);
$oldprice=round($oldprice/$euro, 2);
}if($currency2=="EUR"){
$price2=round($price,2);
$oldprice=round($oldprice, 2);
}$currency1=$currency;}
if($currency=="USD"){
if($currency2=="USD"){
$price2=round($price,2);
$oldprice=round($oldprice,2);
}
if($currency2=="LEV"){
$price2=round($price/$usd,2);
$oldprice=round($oldprice/$usd, 2);
}
if($currency2=="EUR"){
$price2=round($price*$usd/$euro,2);
$oldprice=round($oldprice*$usd/$euro, 2);
}$currency1=$currency;}
if($currency=="LEV"){
if($currency2=="USD"){
$price2=round($price*$usd,2);
$oldprice=round($oldprice*$usd,2);
}
if($currency2=="LEV"){
$price2=round($price,2);
$oldprice=round($oldprice, 2);
}
if($currency2=="EUR"){
$price2=round($price*$euro,2);
$oldprice=round($oldprice*$euro, 2);
}$currency1=$currency;}
}
$price2=round($price2,2);
$catlist1 .= "<option value=\"" . $price2 . "\">" . $row['news'] . "</option>\n";
}
}
echo GetTemplateS("configurator.tpl",$Template,$abpath,$catlist,$catlist1);
?>
Проблева е че този код трябва да се направи с WHILE :
Код:
$sqles2 = mysql_query("SELECT * FROM " . $tprefix . "news WHERE category ='55'");
if ($sqles2)
{
while($row = mysql_fetch_array($sqles2))
{
$price=$row[price];
$oldprice=$row[oldprice];
$currency2=$row[currency];
$query="SELECT `leva` FROM " . $tprefix . "finansi WHERE id ='2'";
$result=mysql_query($query);
$euro=mysql_result($result,0,"leva");
$query="SELECT `leva` FROM " . $tprefix . "finansi WHERE id ='1'";
$result=mysql_query($query);
$usd=mysql_result($result,0,"leva");
$currency=$_POST[currency];
$rest=$_POST[B2];
if ($rest=="Reset"){$currency="";
$currency1=$currency2;}
if ($currency==""){$price2=$price;
$currency1=$currency2;}
else{
if($currency=="EUR"){
if($currency2=="USD"){
$price2=round($price*$euro/$usd,2);
$oldprice=round($oldprice*$euro/$usd,2);
}
if($currency2=="LEV"){
$price2=round($price/$euro,2);
$oldprice=round($oldprice/$euro, 2);
}if($currency2=="EUR"){
$price2=round($price,2);
$oldprice=round($oldprice, 2);
}$currency1=$currency;}
if($currency=="USD"){
if($currency2=="USD"){
$price2=round($price,2);
$oldprice=round($oldprice,2);
}
if($currency2=="LEV"){
$price2=round($price/$usd,2);
$oldprice=round($oldprice/$usd, 2);
}
if($currency2=="EUR"){
$price2=round($price*$usd/$euro,2);
$oldprice=round($oldprice*$usd/$euro, 2);
}$currency1=$currency;}
if($currency=="LEV"){
if($currency2=="USD"){
$price2=round($price*$usd,2);
$oldprice=round($oldprice*$usd,2);
}
if($currency2=="LEV"){
$price2=round($price,2);
$oldprice=round($oldprice, 2);
}
if($currency2=="EUR"){
$price2=round($price*$euro,2);
$oldprice=round($oldprice*$euro, 2);
}$currency1=$currency;}
}
$price2=round($price2,2);
$catlist .= "<option value=\"" . $price2 . "\">" . $row['news'] . "</option>\n";
}
}
аз пробвах нещо ама нестана... моля за помощ...
Код:
$i=0;
while($i<60)
{$sqles2 = mysql_query("SELECT * FROM " . $tprefix . "news WHERE category ='$i'");
if ($sqles2)
{
while($row = mysql_fetch_array($sqles2))
{
$price=$row[price];
$oldprice=$row[oldprice];
$currency2=$row[currency];
$query="SELECT `leva` FROM " . $tprefix . "finansi WHERE id ='2'";
$result=mysql_query($query);
$euro=mysql_result($result,0,"leva");
$query="SELECT `leva` FROM " . $tprefix . "finansi WHERE id ='1'";
$result=mysql_query($query);
$usd=mysql_result($result,0,"leva");
$currency=$_POST[currency];
$rest=$_POST[B2];
if ($rest=="Reset"){$currency="";
$currency1=$currency2;}
if ($currency==""){$price2=$price;
$currency1=$currency2;}
else{
if($currency=="EUR"){
if($currency2=="USD"){
$price2=round($price*$euro/$usd,2);
$oldprice=round($oldprice*$euro/$usd,2);
}
if($currency2=="LEV"){
$price2=round($price/$euro,2);
$oldprice=round($oldprice/$euro, 2);
}if($currency2=="EUR"){
$price2=round($price,2);
$oldprice=round($oldprice, 2);
}$currency1=$currency;}
if($currency=="USD"){
if($currency2=="USD"){
$price2=round($price,2);
$oldprice=round($oldprice,2);
}
if($currency2=="LEV"){
$price2=round($price/$usd,2);
$oldprice=round($oldprice/$usd, 2);
}
if($currency2=="EUR"){
$price2=round($price*$usd/$euro,2);
$oldprice=round($oldprice*$usd/$euro, 2);
}$currency1=$currency;}
if($currency=="LEV"){
if($currency2=="USD"){
$price2=round($price*$usd,2);
$oldprice=round($oldprice*$usd,2);
}
if($currency2=="LEV"){
$price2=round($price,2);
$oldprice=round($oldprice, 2);
}
if($currency2=="EUR"){
$price2=round($price*$euro,2);
$oldprice=round($oldprice*$euro, 2);
}$currency1=$currency;}
}
$price2=round($price2,2);
$catlist[$i] .= "<option value=\"" . $price2 . "\">" . $row['news'] . "</option>\n";
}
}
echo $catlist[$i];
$i++;
}