0

i have a problem with array i have 2 table please check attachment

$sqlQuery=mysql_query("select * from tbl_page_detail where page_name='Home'");
	   $sqlArr=mysql_fetch_array($sqlQuery);
	   $arr = explode(",", $sqlArr['page_cat']);
	   $arrsize=count($arr);
	   $arrsizefloat=ceil($arrsize/2);
       for($i=1;$i<=$arrsizefloat;$i++){?>

            
                    <? for($f=1;$f<=$arrsize;$f++){
					  if($f%2){
					  		echo $val=$f-$i;

	

 $yahoo[]=$val;

						  } else {
							  $yahoon[]=$val;}
						  }
						 $comma_separated = implode(",", $yahoo);
}

i want to fetch category name from tbl_category table, but these category comes from tbl_page_detail in array form,

thanks in advance

4
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by diafol
0

Check this code..
let me know output.

<?
	$sqlQuery=mysql_query("select * from tbl_page_detail where page_name='Home'");
	$sqlArr=mysql_fetch_array($sqlQuery);
	$cat = $sqlArr['page_cat'];
	
	$sql = "select * from tbl_category where cat_id IN ($cat)";
	$res = mysql_query($sql);
	$str = '';
	while($sar = mysql_fetch_assoc($res))
	{
		$str.=','.$sar['cat_name'];
	}
	echo 'Category Names : '.$str;
?>
0

Hi I tried This one
Please Check it out
Code by Web Developer

$res=mysql_query("select page_cat from tbl_page_detail where page_name='Home'");
	$rs=mysql_fetch_array($res);
	$q="select * from tbl_category where cat_id IN (".$rs[0].")";
	$res=mysql_query($q);
	
	$arr=array();
	while($rs=mysql_fetch_array($res))
	{
		array_push($arr,$rs['cat_name']);
	}
	$arr1 = implode(",", $arr);
	echo $arr1;
0

Any chance you can post full code, zip files are a big no-no for me unless I know the source.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.