webForumDet fria alternativet

Önskar endast en visning av resultat

PHP

3 svar · 435 visningar · startad av acke

Medlem sedan juli 20063 inlägg
Frågan#1

Jag vill inte att Recordset3 visas samtidigt som Recordset2 på samma sida.

Tacksam för tips!

Mvh Acke

<?php require_once('../Connections/xxx.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
 
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
 
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
  $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
 
mysql_select_db($database_xxx, $xxx);
$query_Recordset1 = "SELECT namn, kommun FROM boende";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $xxx) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
 
if (isset($_GET['totalRows_Recordset1'])) {
  $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
  $all_Recordset1 = mysql_query($query_Recordset1);
  $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
 
$maxRows_Recordset2 = 10;
$pageNum_Recordset2 = 0;
if (isset($_GET['pageNum_Recordset2'])) {
  $pageNum_Recordset2 = $_GET['pageNum_Recordset2'];
}
$startRow_Recordset2 = $pageNum_Recordset2 * $maxRows_Recordset2;
 
$colname_Recordset2 = "-1";
if (isset($_GET['recordID'])) {
  $colname_Recordset2 = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);
}
mysql_select_db($database_xxx, $xxx);
$query_Recordset2 = sprintf("SELECT DISTINCT namn, kommun FROM boende WHERE kommun = %s ORDER BY kommun ASC", GetSQLValueString($colname_Recordset2, "text"));
$query_limit_Recordset2 = sprintf("%s LIMIT %d, %d", $query_Recordset2, $startRow_Recordset2, $maxRows_Recordset2);
$Recordset2 = mysql_query($query_limit_Recordset2, $xxx) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
 
if (isset($_GET['totalRows_Recordset2'])) {
  $totalRows_Recordset2 = $_GET['totalRows_Recordset2'];
} else {
  $all_Recordset2 = mysql_query($query_Recordset2);
  $totalRows_Recordset2 = mysql_num_rows($all_Recordset2);
}
$totalPages_Recordset2 = ceil($totalRows_Recordset2/$maxRows_Recordset2)-1;
 
$maxRows_Recordset3 = 10;
$pageNum_Recordset3 = 0;
if (isset($_GET['pageNum_Recordset3'])) {
  $pageNum_Recordset3 = $_GET['pageNum_Recordset3'];
}
$startRow_Recordset3 = $pageNum_Recordset3 * $maxRows_Recordset3;
 
mysql_select_db($database_xxx, $xxx);
$query_Recordset3 = "SELECT namn, kategori, kommun FROM boende ORDER BY kommun ASC";
$query_limit_Recordset3 = sprintf("%s LIMIT %d, %d", $query_Recordset3, $startRow_Recordset3, $maxRows_Recordset3);
$Recordset3 = mysql_query($query_limit_Recordset3, $xxx) or die(mysql_error());
$row_Recordset3 = mysql_fetch_assoc($Recordset3);
 
if (isset($_GET['totalRows_Recordset3'])) {
  $totalRows_Recordset3 = $_GET['totalRows_Recordset3'];
} else {
  $all_Recordset3 = mysql_query($query_Recordset3);
  $totalRows_Recordset3 = mysql_num_rows($all_Recordset3);
}
$totalPages_Recordset3 = ceil($totalRows_Recordset3/$maxRows_Recordset3)-1;
?>

:q

Medlem sedan aug. 2004903 inlägg
#2

i if-satsen som innehåller recordset3, om den blir "sann" skicka då vidare till en annan sida med location header..skicka också med nödvändiga variablar
*EDIT
Läste lite fel, trodde du ville skicka record3 till annan sida

Medlem sedan juli 20063 inlägg
#3

Tack för svar!
Går det att få alla visningar på samma sida?
När Recorset 2 (orter i en kommun) visas ska inte Recordset 3 (alla orter i ett län) visas. Det borde vara en if-sats - vet inte bara hur jag ska skriva den. Jag har kört fast - tacksam om någon vill göra en insats.

Jag har byggt allt i Dreamweaver8, men hur man stoppar en visning har jag inte löst.

Mvh Acke :OO

PS. Jag skickar över lite tydligare (Dreamweaver8 kod) kod:

// Recordset 1 (visas hela tiden, där finns länkarna)
 
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
  $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
 
mysql_select_db($database_xxx, $xxx);
$query_Recordset1 = "SELECT namn, kommun FROM boende";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $xxx) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
 
if (isset($_GET['totalRows_Recordset1'])) {
  $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
  $all_Recordset1 = mysql_query($query_Recordset1);
  $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
 
 
// Recordset 2 (endast denna ska visas)
 
$maxRows_Recordset2 = 10;
$pageNum_Recordset2 = 0;
if (isset($_GET['pageNum_Recordset2'])) {
  $pageNum_Recordset2 = $_GET['pageNum_Recordset2'];
}
$startRow_Recordset2 = $pageNum_Recordset2 * $maxRows_Recordset2;
 
$colname_Recordset2 = "-1";
if (isset($_GET['recordID'])) {
  $colname_Recordset2 = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);
}
mysql_select_db($database_xxx, $xxx);
$query_Recordset2 = sprintf("SELECT namn, kommun FROM boende WHERE kommun = %s ORDER BY kommun ASC", GetSQLValueString($colname_Recordset2, "text"));
$query_limit_Recordset2 = sprintf("%s LIMIT %d, %d", $query_Recordset2, $startRow_Recordset2, $maxRows_Recordset2);
$Recordset2 = mysql_query($query_limit_Recordset2, $xxx) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
 
 
// Kan jag lägga in en till if-sats här och hur kan det se ut??
 
if ( vad skriver jag här = vad skriver jag här ) {
  
och här

} else {

och här 

} 
 
 
 
if (isset($_GET['totalRows_Recordset2'])) {
  $totalRows_Recordset2 = $_GET['totalRows_Recordset2'];
} else {
  $all_Recordset2 = mysql_query($query_Recordset2);
  $totalRows_Recordset2 = mysql_num_rows($all_Recordset2);
}
$totalPages_Recordset2 = ceil($totalRows_Recordset2/$maxRows_Recordset2)-1;
 
 
// Recordset 3 (ska inte visas när 2:an visas)
 
 
$maxRows_Recordset3 = 10;
$pageNum_Recordset3 = 0;
if (isset($_GET['pageNum_Recordset3'])) {
  $pageNum_Recordset3 = $_GET['pageNum_Recordset3'];
}
$startRow_Recordset3 = $pageNum_Recordset3 * $maxRows_Recordset3;
 
mysql_select_db($database_xxx, $xxx);
$query_Recordset3 = "SELECT namn, kategori, kommun FROM boende ORDER BY kommun ASC";
$query_limit_Recordset3 = sprintf("%s LIMIT %d, %d", $query_Recordset3, $startRow_Recordset3, $maxRows_Recordset3);
$Recordset3 = mysql_query($query_limit_Recordset3, $xxx) or die(mysql_error());
$row_Recordset3 = mysql_fetch_assoc($Recordset3);
 
if (isset($_GET['totalRows_Recordset3'])) {
  $totalRows_Recordset3 = $_GET['totalRows_Recordset3'];
} else {
  $all_Recordset3 = mysql_query($query_Recordset3);
  $totalRows_Recordset3 = mysql_num_rows($all_Recordset3);
}
$totalPages_Recordset3 = ceil($totalRows_Recordset3/$maxRows_Recordset3)-1;
?>
Medlem sedan juli 20063 inlägg
#4

Jag glömde sista kodbiten, ursäkta!

<?php do { ?>
          <h3>
  <?php echo $row_Recordset2['namn']; ?>
		  <span class="style6"><?php echo $row_Recordset2['kommun']; ?>
		  </span></h3>
          <?php } while ($row_Recordset2 = mysql_fetch_assoc($Recordset2)); ?>
		  		  	  
          <p>&nbsp;</p>
          		  
		  <?php do { ?>
            <table width="384" border="0">
              <tr>
                <td width="120"><?php echo $row_Recordset3['namn']; ?></td>
                <td width="117"><?php echo $row_Recordset3['kommun']; ?></td>
                <td width="125"><?php echo $row_Recordset3['kategori']; ?></td>
              </tr>
                          </table>
            <?php } while ($row_Recordset3 = mysql_fetch_assoc($Recordset3)); ?><p>&nbsp;</p>
264 ms totalt · 4 externa anrop · v20260731065814-full.a51de22e
123 ms — deklarationer (db)
0 ms — hämta statistik (cache)
135 ms — hämta tråd, inlägg och bilagor (db)
126 ms — ändringar (db)