Kien me puede ayudar con este bucle for!!
Intento ke me salga algo como esto:
link0=LOqusea&url0=http%3A%2F%2Fwww.loquesea.com&link1=Otracosa&url1=http%3A%2F%2Fwww.otracosa.com& ...
Las peticiones son tipo :
../links.php?tipo=0&lang=es
include("sql.class.php");
$res = new sql();
$res->con();
if($tipo == "deejay")
{
if ($lang == "es")
{
$res->dqy("select eslink, url from links where tipo='".$tipo."' order by fecha desc limit 5");
if ($res->rw!=0)
{
for ($i=0; $i<$res->rw; $i++)
{
echo "link".$i."=".urlencode(utf8_encode(stripslashes($res->get($i,"eslink"))))."&";
echo "url".$i."=".urlencode(utf8_encode(stripslashes($res->get($i,"url"))))."&";
}
}
}
if ($lang == "en")
{
$res->dqy("select enlink, url from links where tipo='".$tipo."' order by fecha desc limit 5");
if ($res->rw!=0)
{
for ($i=0; $i<$res->rw; $i++)
{
echo "link".$i."=".urlencode(utf8_encode(stripslashes($res->get($i,"enlink"))))."&";
echo "url".$i."=".urlencode(utf8_encode(stripslashes($res->get($i,"url"))))."&";
}
}
}
}
no me salen las cinco registros sino ke saka asta la registro numero 4 y vuelve a sakarme el 1º y el segundo registro.
Por favor ke alguien me diga el fallo
El archivo .class es:
<?
class sql {
var $Qy;
var $result;
var $CON;
var $rw;
function con() {
$this->CON=mysql_connect ("llda410.servidoresdns.net", "qs327", "1781");
mysql_select_db("qs327");
}
function use_db($cual) {
@mysql_select_db($cual);
}
function get ($indice, $campo) {
return @mysql_result($this->result,$indice,$campo);
}
function query() {
$this->result=@mysql_query("$this->qy",$this->CON);
$this->rw=@mysql_num_rows($this->result);
/*
if (mysql_error()) {
$fp=@fopen ("includes/err_log","a");
if ($fp) {
global $REQUEST_URI,$HTTP_REFERER;
$s=mysql_error()."nn$REQUEST_URInn$HTTP_REFERERnn".$this->qy."nn";
fwrite($fp,$s,strlen($s));
fclose($fp);
}
}
*/
}
function dqy($query) {
$this->qy=$query;
$this->query();
}
function insert() {
$this->result=@mysql_query("$this->qy",$this->CON);
}
function qy_add ($que) {
$this->qy=$this->qy.$que;
}
function rows() {
return $this->rw;
}
function lastid() {
return mysql_insert_id($this->CON);
}
function free() {
@mysql_free_result($this->result);
$this->rw=0;
}
}
?>
link0=LOqusea&url0=http%3A%2F%2Fwww.loquesea.com&link1=Otracosa&url1=http%3A%2F%2Fwww.otracosa.com& ...
Las peticiones son tipo :
../links.php?tipo=0&lang=es
include("sql.class.php");
$res = new sql();
$res->con();
if($tipo == "deejay")
{
if ($lang == "es")
{
$res->dqy("select eslink, url from links where tipo='".$tipo."' order by fecha desc limit 5");
if ($res->rw!=0)
{
for ($i=0; $i<$res->rw; $i++)
{
echo "link".$i."=".urlencode(utf8_encode(stripslashes($res->get($i,"eslink"))))."&";
echo "url".$i."=".urlencode(utf8_encode(stripslashes($res->get($i,"url"))))."&";
}
}
}
if ($lang == "en")
{
$res->dqy("select enlink, url from links where tipo='".$tipo."' order by fecha desc limit 5");
if ($res->rw!=0)
{
for ($i=0; $i<$res->rw; $i++)
{
echo "link".$i."=".urlencode(utf8_encode(stripslashes($res->get($i,"enlink"))))."&";
echo "url".$i."=".urlencode(utf8_encode(stripslashes($res->get($i,"url"))))."&";
}
}
}
}
no me salen las cinco registros sino ke saka asta la registro numero 4 y vuelve a sakarme el 1º y el segundo registro.
Por favor ke alguien me diga el fallo
El archivo .class es:
<?
class sql {
var $Qy;
var $result;
var $CON;
var $rw;
function con() {
$this->CON=mysql_connect ("llda410.servidoresdns.net", "qs327", "1781");
mysql_select_db("qs327");
}
function use_db($cual) {
@mysql_select_db($cual);
}
function get ($indice, $campo) {
return @mysql_result($this->result,$indice,$campo);
}
function query() {
$this->result=@mysql_query("$this->qy",$this->CON);
$this->rw=@mysql_num_rows($this->result);
/*
if (mysql_error()) {
$fp=@fopen ("includes/err_log","a");
if ($fp) {
global $REQUEST_URI,$HTTP_REFERER;
$s=mysql_error()."nn$REQUEST_URInn$HTTP_REFERERnn".$this->qy."nn";
fwrite($fp,$s,strlen($s));
fclose($fp);
}
}
*/
}
function dqy($query) {
$this->qy=$query;
$this->query();
}
function insert() {
$this->result=@mysql_query("$this->qy",$this->CON);
}
function qy_add ($que) {
$this->qy=$this->qy.$que;
}
function rows() {
return $this->rw;
}
function lastid() {
return mysql_insert_id($this->CON);
}
function free() {
@mysql_free_result($this->result);
$this->rw=0;
}
}
?>
