Две колонки

niksdevil

Registered
Здравейте, как мога да разделя в 2 колонки по 10 потребителя , в едната маже в другата жени ето кода с който разполагам

Код:
<?php 
$page=$_GET['page'];
$limit = 16;
$limit1 = $page * $limit;
$num = (($page * 16) + 1);
$i = 1;
$q = "SELECT * FROM `users` ORDER by `points` DESC LIMIT $limit1, $limit";
$result = $database->query($q);
$num_rows = mysql_numrows($result);
if(!$result || ($num_rows < 0)){
   echo "Error displaying info";
}
else if($num_rows > 0){
   for($i=0; $i<$num_rows; $i++){
      $uname = mysql_result($result,$i,"username");
      $pic = mysql_result($result,$i,"pic");
      $sex = mysql_result($result,$i,"sex");
      $points = mysql_result($result,$i,"points");
      if($sex=='m') {
	  ?>
<td valign="top" id="pos"><?php echo $num; ?></td><td><a href="userinfo.php?user=<?php echo $uname; ?>"><img src="<?php echo $pic;?>" width="130" height="158" style="border:2px solid #13B1E1;"></a><br><center>
<font color="#13b1e1" size="2"><?php echo $uname; ?></font>
<font color="#777777"> (<?php echo $points; ?> гласа)</font></center></td>
<?php } else { ?>
<td  valign="top" id="pos"><?php echo $num; ?></td><td><a href="userinfo.php?user=<?php echo $uname; ?>"><img src="<?php echo $pic;?>" width="130" height="158" style="border:2px solid #E22BAB;"></a><br><center>
<font color="#E22BAB" size="2"><?php echo $uname; ?></font>
<font color="#777777"> (<?php echo $points; ?> гласа)</font></center></td>
<?php } if($i==3 or $i==7 or $i==11) { echo "</tr><tr>"; }
$num = $num + 1;
   }
}
?>
 
Просто си правиш 2 таблици - в едната WHERE sex="male" а в другата WHERE sex="famale"

Мисля, че няма друг начин да се получи :)
 
<?php
$page=$_GET['page'];
$limit = 16;
$limit1 = $page * $limit;
$num = (($page * 16) + 1);
$i = 1;
$qm = "SELECT * FROM `users` WHERE `sex='m' ORDER by `points` DESC LIMIT $limit1, $limit";
$qf = "SELECT * FROM `users` WHERE `sex='f' ORDER by `points` DESC LIMIT $limit1, $limit";
$resultm = $database->query($qm);
$resultf = $database->query($qf);
$num_rowsm = mysql_numrows($resultm);
$num_rowsf = mysql_numrows($resultf);
if(!$resultm || ($num_rowsm < 0) || ($num_rowsf < 0)){
echo "Error displaying info";
}
else if(($num_rowsm > 0) || ($num_rowsf > 0)){
for($i=0; $i<$num_rowsm; $i<$num_rowsf; $i++){
$unamem = mysql_result($resultm,$i,"username");
$picm = mysql_result($resultm,$i,"pic");
$pointsm = mysql_result($resultm,$i,"points");
$unamef = mysql_result($resultf,$i,"username");
$picf = mysql_result($resultf,$i,"pic");
$pointsf = mysql_result($resultf,$i,"points");
?>
<td valign="top" id="pos"><?php echo $num; ?></td><td><a href="userinfo.php?user=<?php echo $unamem; ?>"><img src="<?php echo $picm;?>" width="130" height="158" style="border:2px solid #13B1E1;"></a><br><center>
<font color="#13b1e1" size="2"><?php echo $unamem; ?></font>
<font color="#777777"> (<?php echo $pointsm; ?> гласа)</font></center></td>
<td valign="top" id="pos"><?php echo $num; ?></td><td><a href="userinfo.php?user=<?php echo $unamef; ?>"><img src="<?php echo $picf;?>" width="130" height="158" style="border:2px solid #13B1E1;"></a><br><center>
<font color="#13b1e1" size="2"><?php echo $unamef; ?></font>
<font color="#777777"> (<?php echo $pointsf; ?> гласа)</font></center></td>
<?php } if($i==3 or $i==7 or $i==11) { echo "</tr><tr>"; }
$num = $num + 1;
}
?>

Не съм сигурен дали ще работи идеално или ще даде грешка защото не съм го тествал. Ако даде грешка ми кажи каква :)
 
Код:
<?php
include("sesiq.php");
include("lang/bg.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
	<meta name="author" content="http://waisys.net/">
	<title>Заглавие</title>
	<link rel="shortcut icon" href="i/icon.gif">
	<link href="facefiles/facebox.css" media="screen" rel="stylesheet" type="text/css">
	<script src="facefiles/jquery-1.2.2.pack.js" type="text/javascript"></script>
	<script src="facefiles/facebox.js" type="text/javascript"></script>
	<script type="text/javascript" src="js/comment.js"></script>
	<script type="text/javascript" src="js/over.js"></script>
	<script type="text/javascript" src="js/func.js"></script>
	<script type="text/javascript" src="js/prototype.js"></script>
	<link href="i/main.css" rel="stylesheet" type="text/css">
	<?php require_once('include/function.php'); ?>
</head>
<body>
<div id="container">
<?php include('include/header.php'); ?>
<div style="padding-left:0px;">
<div id="content" style="padding-top:70px;" align="center">
<div class="top">
<table cellpadding="10" cellspacing="0" border="0">
<tr>
<?php 
$page=$_GET['page'];
$limit = 16;
$limit1 = $page * $limit;
$num = (($page * 16) + 1);
$i = 1;
$q = "SELECT * FROM `users` ORDER by `points` DESC LIMIT $limit1, $limit";
$result = $database->query($q);
$num_rows = mysql_numrows($result);
if(!$result || ($num_rows < 0)){
   echo "Error displaying info";
}
else if($num_rows > 0){
   for($i=0; $i<$num_rows; $i++){
      $uname = mysql_result($result,$i,"username");
      $pic = mysql_result($result,$i,"pic");
      $sex = mysql_result($result,$i,"sex");
      $points = mysql_result($result,$i,"points");
      if($sex=='m') {
	  ?>
<td valign="top" id="pos"><?php echo $num; ?></td><td><a href="userinfo.php?user=<?php echo $uname; ?>"><img src="<?php echo $pic;?>" width="130" height="158" style="border:2px solid #13B1E1;"></a><br><center>
<font color="#13b1e1" size="2"><?php echo $uname; ?></font>
<font color="#777777"> (<?php echo $points; ?> гласа)</font></center></td>
<?php } else { ?>
<td  valign="top" id="pos"><?php echo $num; ?></td><td><a href="userinfo.php?user=<?php echo $uname; ?>"><img src="<?php echo $pic;?>" width="130" height="158" style="border:2px solid #E22BAB;"></a><br><center>
<font color="#E22BAB" size="2"><?php echo $uname; ?></font>
<font color="#777777"> (<?php echo $points; ?> гласа)</font></center></td>
<?php } if($i==3 or $i==7 or $i==11) { echo "</tr><tr>"; }
$num = $num + 1;
   }
}
?>

</tr>
</table>

<?php
$sql = mysql_query("SELECT COUNT(*) AS 'number' FROM `users` LIMIT 100");
$a = mysql_fetch_array($sql);
$broistr = round(($a['number'] / $limit) + 0.4);
$newpage = $page + 1;
$back = $page - 1;
$j =$broistr + 1;
$next = $broistr - 1;
$last = $broistr - 1;
echo "<div style=\"background-color:#FFF; width:535px; height:26px;\" align=\"center\">
<table border=0 cellpadding=0 cellspacing=0><tr>";

	if($page > 3) {
		echo "<td id=fstr><center><a href='?'>1</a></center></td><td><b>...</b></td>";
	}
for($i=1;$i<$j;++$i) {
$link = $i - 1;
	if($newpage == $i) {
		echo "<td id=cstr>$i</td>";
	}
	else {
		if($i == $newpage+1 or $i == $newpage+2 or $i==$newpage+3 or $i==$newpage-1 or $i==$newpage-2 or $i==$newpage-3) {
		echo "<td id=str> <a href='?page=$link'>$i</a> </td>"; }
	}

}
	if($broistr > $page + 4) {
		echo "<td><b>...</b></td><td id=fstr><center><a href='?page=$last'>$broistr</a></div></td>";
	}
echo "</tr></table></center>";	
?>

</div>
</div>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>	
<?php include('include/footer.php'); ?>
</div></div>
</body>
</html>
 
<?php
include("sesiq.php");
include("lang/bg.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<meta name="author" content="http://waisys.net/">
<title>Заглавие</title>
<link rel="shortcut icon" href="i/icon.gif">
<link href="facefiles/facebox.css" media="screen" rel="stylesheet" type="text/css">
<script src="facefiles/jquery-1.2.2.pack.js" type="text/javascript"></script>
<script src="facefiles/facebox.js" type="text/javascript"></script>
<script type="text/javascript" src="js/comment.js"></script>
<script type="text/javascript" src="js/over.js"></script>
<script type="text/javascript" src="js/func.js"></script>
<script type="text/javascript" src="js/prototype.js"></script>
<link href="i/main.css" rel="stylesheet" type="text/css">
<?php require_once('include/function.php'); ?>
</head>
<body>
<div id="container">
<?php include('include/header.php'); ?>
<div style="padding-left:0px;">
<div id="content" style="padding-top:70px;" align="center">
<div class="top">
<table cellpadding="10" cellspacing="0" border="0">
<tr>
<?php
$page=$_GET['page'];
$limit = 16;
$limit1 = $page * $limit;
$num = (($page * 16) + 1);
$i = 1;
$qm = "SELECT * FROM `users` WHERE `sex='m' ORDER by `points` DESC LIMIT $limit1, $limit";
$qf = "SELECT * FROM `users` WHERE `sex='f' ORDER by `points` DESC LIMIT $limit1, $limit";
$resultm = $database->query($qm);
$resultf = $database->query($qf);
$num_rowsm = mysql_numrows($resultm);
$num_rowsf = mysql_numrows($resultf);
if(!$resultm || ($num_rowsm < 0) || ($num_rowsf < 0)){
echo "Error displaying info";
}
else if(($num_rowsm > 0) || ($num_rowsf > 0)){
for($i=0; $i<$num_rowsm; $i<$num_rowsf; $i++){
$unamem = mysql_result($resultm,$i,"username");
$picm = mysql_result($resultm,$i,"pic");
$pointsm = mysql_result($resultm,$i,"points");
$unamef = mysql_result($resultf,$i,"username");
$picf = mysql_result($resultf,$i,"pic");
$pointsf = mysql_result($resultf,$i,"points");
?>
<td valign="top" id="pos"><?php echo $num; ?></td><td><a href="userinfo.php?user=<?php echo $unamem; ?>"><img src="<?php echo $picm;?>" width="130" height="158" style="border:2px solid #13B1E1;"></a><br><center>
<font color="#13b1e1" size="2"><?php echo $unamem; ?></font>
<font color="#777777"> (<?php echo $pointsm; ?> гласа)</font></center></td>
<td valign="top" id="pos"><?php echo $num; ?></td><td><a href="userinfo.php?user=<?php echo $unamef; ?>"><img src="<?php echo $picf;?>" width="130" height="158" style="border:2px solid #13B1E1;"></a><br><center>
<font color="#13b1e1" size="2"><?php echo $unamef; ?></font>
<font color="#777777"> (<?php echo $pointsf; ?> гласа)</font></center></td>
<?php } if($i==3 or $i==7 or $i==11) { echo "</tr><tr>"; }
$num = $num + 1;
}
?></tr>
</table>

<?php
$sql = mysql_query("SELECT COUNT(*) AS 'number' FROM `users` LIMIT 100");
$a = mysql_fetch_array($sql);
$broistr = round(($a['number'] / $limit) + 0.4);
$newpage = $page + 1;
$back = $page - 1;
$j =$broistr + 1;
$next = $broistr - 1;
$last = $broistr - 1;
echo "<div style=\"background-color:#FFF; width:535px; height:26px;\" align=\"center\">
<table border=0 cellpadding=0 cellspacing=0><tr>";

if($page > 3) {
echo "<td id=fstr><center><a href='?'>1</a></center></td><td><b>...</b></td>";
}
for($i=1;$i<$j;++$i) {
$link = $i - 1;
if($newpage == $i) {
echo "<td id=cstr>$i</td>";
}
else {
if($i == $newpage+1 or $i == $newpage+2 or $i==$newpage+3 or $i==$newpage-1 or $i==$newpage-2 or $i==$newpage-3) {
echo "<td id=str> <a href='?page=$link'>$i</a> </td>"; }
}

}
if($broistr > $page + 4) {
echo "<td><b>...</b></td><td id=fstr><center><a href='?page=$last'>$broistr</a></div></td>";
}
echo "</tr></table></center>";
?>

</div>
</div>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<?php include('include/footer.php'); ?>
</div></div>
</body>
</html>

Вкарах ти кода, който "сътворих :D "
Пробвай сега :)
 
Пробвай така:
<?php
include("sesiq.php");
include("lang/bg.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<meta name="author" content="http://waisys.net/">
<title>Заглавие</title>
<link rel="shortcut icon" href="i/icon.gif">
<link href="facefiles/facebox.css" media="screen" rel="stylesheet" type="text/css">
<script src="facefiles/jquery-1.2.2.pack.js" type="text/javascript"></script>
<script src="facefiles/facebox.js" type="text/javascript"></script>
<script type="text/javascript" src="js/comment.js"></script>
<script type="text/javascript" src="js/over.js"></script>
<script type="text/javascript" src="js/func.js"></script>
<script type="text/javascript" src="js/prototype.js"></script>
<link href="i/main.css" rel="stylesheet" type="text/css">
<?php require_once('include/function.php'); ?>
</head>
<body>
<div id="container">
<?php include('include/header.php'); ?>
<div style="padding-left:0px;">
<div id="content" style="padding-top:70px;" align="center">
<div class="top">
<table cellpadding="10" cellspacing="0" border="0">
<tr>
<?php
$page=$_GET['page'];
$limit = 16;
$limit1 = $page * $limit;
$num = (($page * 16) + 1);
$i = 1;
$qm = "SELECT * FROM `users` WHERE `sex='m' ORDER by `points` DESC LIMIT $limit1, $limit";
$qf = "SELECT * FROM `users` WHERE `sex='f' ORDER by `points` DESC LIMIT $limit1, $limit";
$resultm = $database->query($qm);
$resultf = $database->query($qf);
$num_rowsm = mysql_numrows($resultm);
$num_rowsf = mysql_numrows($resultf);
if(!$resultm || ($num_rowsm < 0) || ($num_rowsf < 0)){
echo "Error displaying info";
}
else if($num_rowsm > 0 || $num_rowsf > 0){
for($i=0; $i<$num_rowsm; $i<$num_rowsf; $i++){
$unamem = mysql_result($resultm,$i,"username");
$picm = mysql_result($resultm,$i,"pic");
$pointsm = mysql_result($resultm,$i,"points");
$unamef = mysql_result($resultf,$i,"username");
$picf = mysql_result($resultf,$i,"pic");
$pointsf = mysql_result($resultf,$i,"points");
?>
<td valign="top" id="pos"><?php echo $num; ?></td><td><a href="userinfo.php?user=<?php echo $unamem; ?>"><img src="<?php echo $picm;?>" width="130" height="158" style="border:2px solid #13B1E1;"></a><br><center>
<font color="#13b1e1" size="2"><?php echo $unamem; ?></font>
<font color="#777777"> (<?php echo $pointsm; ?> гласа)</font></center></td>
<td valign="top" id="pos"><?php echo $num; ?></td><td><a href="userinfo.php?user=<?php echo $unamef; ?>"><img src="<?php echo $picf;?>" width="130" height="158" style="border:2px solid #13B1E1;"></a><br><center>
<font color="#13b1e1" size="2"><?php echo $unamef; ?></font>
<font color="#777777"> (<?php echo $pointsf; ?> гласа)</font></center></td>
<?php } if($i==3 or $i==7 or $i==11) { echo "</tr><tr>"; }
$num = $num + 1;
}
?></tr>
</table>

<?php
$sql = mysql_query("SELECT COUNT(*) AS 'number' FROM `users` LIMIT 100");
$a = mysql_fetch_array($sql);
$broistr = round(($a['number'] / $limit) + 0.4);
$newpage = $page + 1;
$back = $page - 1;
$j =$broistr + 1;
$next = $broistr - 1;
$last = $broistr - 1;
echo "<div style=\"background-color:#FFF; width:535px; height:26px;\" align=\"center\">
<table border=0 cellpadding=0 cellspacing=0><tr>";

if($page > 3) {
echo "<td id=fstr><center><a href='?'>1</a></center></td><td><b>...</b></td>";
}
for($i=1;$i<$j;++$i) {
$link = $i - 1;
if($newpage == $i) {
echo "<td id=cstr>$i</td>";
}
else {
if($i == $newpage+1 or $i == $newpage+2 or $i==$newpage+3 or $i==$newpage-1 or $i==$newpage-2 or $i==$newpage-3) {
echo "<td id=str> <a href='?page=$link'>$i</a> </td>"; }
}

}
if($broistr > $page + 4) {
echo "<td><b>...</b></td><td id=fstr><center><a href='?page=$last'>$broistr</a></div></td>";
}
echo "</tr></table></center>";
?>

</div>
</div>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<?php include('include/footer.php'); ?>
</div></div>
</body>
</html>
 
ArchangelS каза:
Какво се мъчиш с фор 1 Джойн заявка и това е .
Как ще стане това понеже с for не съм се занимавал... и не мога да помогна... ?
 

Back
Горе