Autor Zpráva
KOM
Profil *
pokouším se zde natěsnat svůj původní statický html web do php a mysl databáze.
pomocí dreamweaveru jsem rozběhal načítání fotek z DB, po kliknutí na náhled, otevrení detailu fotky. Ale potreboval bych jeste u toho detailu fotky, listovaní na dalsí fotky v kategorii/databazi.
Nasla by se tu dobra duse, ktera by mi s tim pomohla. Pro zacatek bych rad zprovoznil jen to posouvaní pres menu nad fotkou, ale pozdeji bych chtel, aby se fotky posouvaly dopredu i po kliknuti na fotku, pripadne po stisku sipek na klavesnici ;-)

kod, ktery mam na tech 2 strankach:
náhledy
<?php require_once('Connections/pripojeni_MySQL.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $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;
}
}

mysql_select_db($database_pripojeni_MySQL, $pripojeni_MySQL);
$query_vse_v_jednom = "SELECT * FROM fotografie ORDER BY datum_vlozeni DESC";
$vse_v_jednom = mysql_query($query_vse_v_jednom, $pripojeni_MySQL) or die(mysql_error());
$row_vse_v_jednom = mysql_fetch_assoc($vse_v_jednom);
$totalRows_vse_v_jednom = mysql_num_rows($vse_v_jednom);
?>
<!doctype html>
<html>
<head>
<meta name="Description" content="Litvínovský fotograf Jiří Komůrka Vám představuje své převážně krajinářské fotografie." />
<meta name="Author" content="Komůrka Jiří" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link rel="stylesheet" href="css/css_kom72.css" type="text/css" />
<link rel="shortcut icon" href="favicon.ico" >
<title>Galerie</title>
</head>

<body>

<div id="stranka">

<div id="hlavicka">
<strong>Jiří Komůrka</strong><br>
krajinářský fotograf
</div><!-- ukoncujici ID: hlavicka -->

<div id="obsah">
<h1>Vše v jednom</h1>

<?php do { ?>
<a href="detail_fotografie.php?fotografie_id=<?php echo $row_vse_v_jednom['fotografie_id']; ?>">
        <img class="fotogalerie" src="fotky/<?php echo $row_vse_v_jednom['kategorie']; ?>/<?php echo $row_vse_v_jednom['fotka']; ?>_nahled.jpg" alt="">
</a>
<?php } while ($row_vse_v_jednom = mysql_fetch_assoc($vse_v_jednom)); ?>

<div class="clear"></div>
</div><!-- ukoncujici ID: obsah -->

      
</div><!-- ukoncujici ID: stranka -->

</body>
</html>
<?php
mysql_free_result($vse_v_jednom);
?>

detail fotky
<?php require_once('Connections/pripojeni_MySQL.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $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;
}
}

$colname_detail = "-1";
if (isset($_GET['fotografie_id'])) {
  $colname_detail = $_GET['fotografie_id'];
}
mysql_select_db($database_pripojeni_MySQL, $pripojeni_MySQL);
$query_detail = sprintf("SELECT * FROM fotografie WHERE fotografie_id = %s", GetSQLValueString($colname_detail, "int"));
$detail = mysql_query($query_detail, $pripojeni_MySQL) or die(mysql_error());
$row_detail = mysql_fetch_assoc($detail);
$totalRows_detail = mysql_num_rows($detail);
?>
<!doctype html>
<html>
<head>
<meta name="Description" content="Litvínovský fotograf Jiří Komůrka Vám představuje své převážně krajinářské fotografie." />
<meta name="Author" content="Komůrka Jiří" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link rel="stylesheet" href="css/css_kom72.css" type="text/css" />
<link rel="shortcut icon" href="favicon.ico" >
<title>Fotogalerie</title>
</head>

<body>

<div id="stranka">

<div id="hlavicka">
<strong>Jiří Komůrka</strong><br>
krajinářský fotograf
</div><!-- ukoncujici ID: hlavicka -->

<div id="obsah">
<h1>Fotogalerie detail</h1>
<div class="fotografie_navigace">
<span class="text_maly"><<</span> předchozí
<span class="zpet">zpět</span>
následující <span class="text_maly">>></span>
</div>

<img src="fotky/<?php echo $row_detail['kategorie']; ?>/<?php echo $row_detail['fotka']; ?>.jpg" alt="">

<div class="clear"></div>
</div><!-- ukoncujici ID: obsah -->

      
</div><!-- ukoncujici ID: stranka -->

</body>
</html>
<?php
mysql_free_result($detail);
?>

děkuji za váš čas....
leorond
Profil
A proč nezkusíš třeba Lightbox na zobrazení fotek a na stránkování například něco takovéhleho?

<?php
$num        =    15;
$page        =    $_GET['stranka'];
$result00    =    mssql_query("SELECT COUNT(*) FROM Character WHERE CtlCode = '0'");
$temp        =    mssql_fetch_array($result00);
$posts        =    $temp[0];
if    ($posts    ==    0) $posts    =    1;
$total        =    (($posts - 1) / $num) + 1;
$total        =     intval($total);
$page        =    intval($page);
if    (empty($page)    or    $page < 0)    $page    =    1;
if    ($page    >    $total)    $page    =    $total;
$start    =    $num * ($page - 1);
$result    =    mssql_query("SELECT TOP $num * FROM Character WHERE CtlCode = '0' AND Name NOT IN (SELECT TOP $start Name FROM Character ORDER BY gr_res DESC, Resets DESC, cLevel DESC) ORDER BY gr_res DESC, Resets DESC, cLevel DESC");
if    (mssql_num_rows($result)    >    0)
{
    $myrow    =    mssql_fetch_array($result);
    $id        =    15 * ($page - 1);
    do
    {
        $id++;
        $result3    = mssql_query("SELECT * from GuildMember where Name = '".$myrow["Name"]."'");
        $myrow3        = mssql_fetch_array($result3);
        if($myrow["gr_res"] == NULL) {
            $myrow["gr_res"]    = 0;
        }
        printf ("<tr>
                    <td>".$id.".</td>
                    <td class='topka_1'><a class='a_ukaz' href='index.php?strana=strana/info_char&amp;name=".$myrow["Name"]."'>".$myrow["Name"]."</a></td>
                    <td class='topka'>".char_class($myrow["Class"])."</td>
                    <td class='topka_1'><a class='a_ukaz' href='index.php?strana=strana/ukaz_g&amp;name=".$myrow3["G_Name"]."'>".$myrow3["G_Name"]."</a></td>
                    <td class='topka'>".$myrow["cLevel"]."</td>
                    <td>( ".$myrow["Resets"]." / ".$myrow["gr_res"]." )</td>
                </tr>");
    }
    while    ($myrow    =    mssql_fetch_array($result));
}
?></table><?php
if    ($page    !=    1)        $pervpage        =    '<a id="strankovani" href="?strana=strana/top_c&stranka=1"><<</a><a id="strankovani" href="?strana=strana/top_c&stranka='.($page - 1).'"><</a>';
if    ($page    !=    $total)    $nextpage        =    '<a id="strankovani" href="?strana=strana/top_c&stranka='.($page + 1).'">></a><a id="strankovani" href="?strana=strana/top_c&stranka='.$total.'">>></a>';
if    ($total    >    1)
{
    Error_Reporting(E_ALL & ~E_NOTICE);
    echo    "<center><div class=\"pstrnav\">";
    echo    $pervpage.$nextpage;
    echo    "</div></center>";
}
?>

Je to jednoduché stránkování s použitím MSSQL ale překopat do MySQL je snad hračka ne?


Dle mého názoru by ti to ten kód trošku zjednodušilo pokud tedy používáš databázi


Snad ti ten script alespoň trochu pomůže :)

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0