Am nevoie de putin ajutor !!!

Aici puteţi posta întrebari legate de instalare şi configurare PHP, Apache, IIS, MySQL, PostgreSQL, Oracle, SQL Server sau altele.

Moderator: Moderatori

Stef4n
New Member
Mesaje: 1
Membru din: Mar Noi 18, 2014 8:02 am

Am nevoie de putin ajutor !!!

Mesajde Stef4n » Mar Noi 18, 2014 8:11 am

NU reusec nici cum sa setez o limita "LIMIT". Doresc sa folosesc doar 6 cuvinte cheie de exemplu.

function GetTags($joc_id){
$sql = mysql_query("SELECT `keywords` FROM `jocuri` WHERE `joc_id` = '".$joc_id."' ");
$res = mysql_fetch_assoc($sql);
$joctags = $res['keywords'];
if(substr($joctags , 0 , 1) == ","){
$joctags = substr($joctags , 1 , strlen($joctags));
}
if(substr($joctags , -1) == ","){
$joctags = substr($joctags , 0 , - 1);
}
$tags = explode(',', $joctags);



foreach($tags as $cuvCheie){


$cuvCheieA = str_replace(' ','-',$cuvCheie);
if($cuvCheieA[0] == '-'){
$cuvCheieA = substr($cuvCheieA, -(strlen($cuvCheieA)-1));
}
if($cuvCheieA[strlen($cuvCheieA)-1] == '-') {
$cuvCheieA = substr($cuvCheieA, 0, -1);
}
if($cuvCheie[0] == ' '){
$cuvCheie = substr($cuvCheie, -(strlen($cuvCheie)-1));
}
if($cuvCheie[strlen($cuvCheie)-1] == ' ') {
$cuvCheie = substr($cuvCheie, 0, -1);
}
if(strlen($cuvCheieA ) > 3){
$cuvCheieA = str_replace('', '-' , $cuvCheieA );
echo '<a href="'.CALEFRONTEND.'jocuri/'.strtolower($cuvCheieA).'.html" title="'.$cuvCheie.'">'.strtolower($cuvCheie).'</a>' ;
}

}



}



takedown
Average Member
Mesaje: 153
Membru din: Joi Feb 07, 2013 8:50 pm
Contact:

Re: Am nevoie de putin ajutor !!!

Mesajde takedown » Mar Noi 18, 2014 10:28 am

Pai cum ai cuvintele cheie in tabel? daca le ai separate prin virguala, atunci folosesti un explode si dupa un for.Sa-ti dau un exemplu simplu:

Cod: Selectaţi tot

<?php

$tags = 'need for speed,nfs,car games,racing games,download need for speed,need for speed download,download car games,car games download';

$keywords = explode(",", $tags);

for($x=0;$x<=5;$x++){
   echo $keywords[$x] .'<br>';
}
?>


sau vrei sa setezi un LIMIT general, adica de unde vrei sa inceapa si unde vrei sa se opreasca, gen cel folosit in SQL? de ex, codul de mai sus foloseste LIMIT 0, 5


Înapoi la “Instalare”

Cine este conectat

Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 22 vizitatori