balkan7 Posted February 17, 2007 Share Posted February 17, 2007 hi, i have created function for show me result from mysql in 2 columns, so i just get blank page, maybe for function index_soft() ? index.php <?php include_once("conn.php"); include_once("includes.php"); include_once("templates/HeaderTemplate.php"); ?> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <table width=570 valign=top> <tr> <td style="background-image: url('images/center.gif')"><?=$lang_catalog_1?></td> </tr> <tr> <td style="padding-left:10"><?=nl2br($aset[content]);?></td> </table> <table width=570 valign=top> <tr> <td style="background-image: url('images/center.gif')"><?=$lang_catalog_2?></td> </tr> </table> <br> <?php $q1 = "select * from bsoft_catalog AS clog INNER JOIN bsoft_categories AS cgory ON clog.ItemCategory = cgory.CategoryID ORDER BY ItemID DESC limit 2"; $r1 = mysql_query($q1) or die(mysql_error()); if(mysql_num_rows($r1)) { while($a1 = mysql_fetch_array($r1)){ if(empty($a1[itemImage])) { $ItemImage = "<img src=\"no_image.gif\" width=\"145\" alt=\"No Image!\" border=0>"; } else { $size = getimagesize("items_images/$a1[itemImage]"); if($size[0] > 120) { $width = 120; $height = 100; } else { $width = $size[0]; $height = $size[0]; } $ItemImage = "<img src=\"items_images/$a1[itemImage]\" width=\"$width\" height=\"$height\" alt=\"$a1[itemName]\" border=0>"; } index_soft(); } } include_once("templates/FooterTemplate.php"); ?> includes.php <?php function index_soft() { //get the ItemID (soft id) from the table $q1 = "select * from bsoft_catalog AS clog INNER JOIN bsoft_categories AS cgory ON clog.ItemCategory = cgory.CategoryID ORDER BY ItemID DESC limit 4"; $r1 = mysql_query($q1) or die(mysql_error()); while($a1 = mysql_fetch_array($r1)) { $q2 = "select ItemName, ItemImage, ItemCategory,ItemCd,ItemPrice,Datum,ItemDesc from bsoft_catalog where ItemID = '$a1[itemID]' "; $r2 = mysql_query($q2) or die(mysql_error()); $a2 = mysql_fetch_array($r2); $my_id[] = $a1[itemID]; $my_name[] = $a2[itemName]; $my_category[] = $a1[itemCategory]; $my_cd[] = $a2[itemCd]; $my_price[] = $a2[itemPrice]; $my_date[] = $a2[Datum]; $my_desc[] = $a2[itemDesc]; } if(count($my_id) > '0') { $rows .= "<table class='index' cellpadding='2' cellspacing='0' width='30%'>\n"; //we should list the result in 2 columns for($i = '0'; $i < count($my_id); $i+=2) { $one = $i; $two = $i + 1; $rows .= "<tr>\n\t<td><table style='width: 100%' cellpadding='0' class='index7'><tr><td class='index13' style='width: 400px; color: #FF0000; font-size: 12px; text-align: center; font-weight: bold;'>$my_name[$one]</td</tr></table><img src='images/spacer.gif' width='1px' height='3px'></img><table style='width: 100% height: 69px;' cellpadding='0' class='index7'><tr><td class='style1' valign='top'>$ItemImage</td><td class='index11'><table style='width: 100%' class='index5'><tr><td class='index12'><font color='#C0C0C0'>$lang_index_1</font>\t<a href='search.php?CategoryID=$a1[itemCategory]'>$my_category[$one]</a></td></tr><tr><td class='index12'><font color='#C0C0C0'>$lang_index_2</font>\t$my_cd[$one]</td></tr><tr><td class='index12'><font color='#C0C0C0'>$lang_index_4</font>\t$aset[currency_sign]; $my_price[$one];\t$lang_index_8</td></tr><tr><td class='index12'><font color='#C0C0C0'>$lang_index_9</font>\t$my_date[$one]</td></tr><tr><td class='index12'><a href='view_cart.php'><img src='images/pregled.gif' width='118' height='22' alt='$lang_index_5' border='0'></a>\t\t<a href='add.php?ItemID=$my_id[$one]'><img src='images/dodaj.gif' width='118' height='22' alt='$lang_index_6' border='0'></a></td></tr></table></td></tr></table><img src='images/spacer.gif' width='1px' height='3px'></img><table style='width: 100%' cellpadding='0' class='index7'><tr><td class='index12'><font color='#C0C0C0'>$lang_index_3</font>\tnl2br($my_desc[$one]);</td></tr></table></td></tr></table>\n"; if(!empty($my_id[$two])) { $rows .= "<tr>\n\t<td><table style='width: 100%' cellpadding='0' class='index7'><tr><td class='index13' style='width: 400px; color: #FF0000; font-size: 12px; text-align: center; font-weight: bold;'>$my_name[$one]</td</tr></table><img src='images/spacer.gif' width='1px' height='3px'></img><table style='width: 100% height: 69px;' cellpadding='0' class='index7'><tr><td class='style1' valign='top'>$ItemImage</td><td class='index11'><table style='width: 100%' class='index5'><tr><td class='index12'><font color='#C0C0C0'>$lang_index_1</font>\t<a href='search.php?CategoryID=$a1[itemCategory]'>$my_category[$one]</a></td></tr><tr><td class='index12'><font color='#C0C0C0'>$lang_index_2</font>\t$my_cd[$one]</td></tr><tr><td class='index12'><font color='#C0C0C0'>$lang_index_4</font>\t$aset[currency_sign]; $my_price[$one];\t$lang_index_8</td></tr><tr><td class='index12'><font color='#C0C0C0'>$lang_index_9</font>\t$my_date[$one]</td></tr><tr><td class='index12'><a href='view_cart.php'><img src='images/pregled.gif' width='118' height='22' alt='$lang_index_5' border='0'></a>\t\t<a href='add.php?ItemID=$my_id[$one]'><img src='images/dodaj.gif' width='118' height='22' alt='$lang_index_6' border='0'></a></td></tr></table></td></tr></table><img src='images/spacer.gif' width='1px' height='3px'></img><table style='width: 100%' cellpadding='0' class='index7'><tr><td class='index12'><font color='#C0C0C0'>$lang_index_3</font>\tnl2br($my_desc[$one]);</td></tr></table></td></tr></table>\n"; } else { $rows .= "<td></td>\n\n\t"; } $rows .= "</tr><td colspan=4> </td></tr>\n\n"; } $rows .= "</table>"; } return $rows; } ?> Link to comment https://forums.phpfreaks.com/topic/38971-result-in-2-columns/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.