• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

GET-Problem

Status
Für weitere Antworten geschlossen.
kannst du mir mal nen etwas größeren Code. Kannste ja so machen. Ind der MYSQL sind folgende Daten
ID Name URL
1 Ich hi.de
2 Du du.de
Jetzt mach bitte mal nen Code der Bei index.php?id=1
Ich
Meine homepage: hi.de
und bei index.php?id=2
Du
Meine hompage du.de

ausgibt.
 
Werbung:
Hier ist der Code:
HTML:
<!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=iso-8859-1" />
<title>Flasche Play on GandC.de Games and Cheats</title>
</head>
<body>
<h4 align="center"
<?php
include "../../../ad/showbanner.php";
?>
</h4>
<h3 align="center">Mario Kaos: Sammel m&ouml;glichst viele Flasche ein ohne dich von der Polizei erwischen zu   lassen. </h3>
<p>
<h2 align="center"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="500" height="340" hspace="95" align="bottom" title="El Emigrante">
    <param name="movie" value="flasche.swf" />
    <param name="quality" value="high" />
    <embed src="flasche.swf" width="500" height="340" hspace="95" align="bottom" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>
  </object></h2>
</p>
<p><? 
include "box.php";
?>
<script type="text/javascript"> document.meinung.input_name.focus();</script>
&nbsp; </p>
<p align="center">(c) by <a href="../el/www.gandc.de">gandc.de </a></p>
</body>
</html>
Der Code der box.php
PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>Meinungsbox</title>
 </head>
<body>
<? 
// 1. Variablen anpassen
      $tablewidth = 380;   //Breite der Tabelle
      $showcomments = 7;   //Anzahl der anzuzeigenden Kommentare
      $file = "meinung.txt";   //Name der Meinungsdatei
// 2. Dateien im ASCII Modus auf den Server kopieren.
// 3. CHMOD der "box.php"-Datei auf 777 setzen!!
  echo "
<form action='box.php?show=$show' method='post' name='meinung'>
 <table width='$tablewidth' border='0' align=center bgcolor='#999999'>
  <tr bgcolor='#DCE8F1'>
   <td>Name</td>
   <td><input type='text' value='' name='input_name' size='27' maxlength='20'></td>
   <td rowspan=2><input type='submit' value='Go!'></td>
  </tr>
  <tr bgcolor='#F3F7FA'>
   <td width=10%>Kommentar</td>
   <td><input type='text' value='' name='input_comment' size='45' maxlength='150'></td>
  </tr>
  <tr>
   <td colspan='2'>
    <br>
  ";
  if($show == "all") echo "» <a href='box.php'>Neue Meinungen zeigen</a><br><br>";
  else echo "» <a href='box.php?show=all'>Alle Meinungen zeigen</a><br><br>";
  if($input_name != "Name" && $input_name != "" && $input_comment != "Kommentar" && $input_comment != ""){
    $tmp = fopen($file, "a");
    fputs($tmp,"$input_name|$input_comment\n");
    fclose($tmp);
  }
  $names = array();
  $comments = array();
  $tmp = fopen($file,"r");
  while(!feof($tmp)){
    $row = fgets($tmp,999999);
    list($name,$comment) = split("\|",$row);
    if($name != ""){
      array_push($names,$name);
      array_push($comments,$comment);
    }
  }
  fclose($tmp);
  $names = array_reverse($names);
  $comments = array_reverse($comments);
  if($show == "all")
    $max = count($names);
  else
    $max = $showcomments;
  for($i=0; $i<$max; $i++)
    echo "<b>$names[$i]:</b> $comments[$i]<br><br>\n";
  echo "
   </td>
  </tr>
 </table>
</form>
  ";
?>
<script type="text/javascript"> document.meinung.input_name.focus();</script>
</body>
</html>
Die box.php muss noch auf MYSQL umgestellt werden.
 
Werbung:
Werde morgen alles auf MySQL umbauen und coden wie du es wolltest doch ich geh erst mal schlafen.
 
Ich bin fertig mit der Gamesache also mit ID. Doch ich habe auch selbst Probleme mit den Kommentaren denn nicht jeder Kommentar soll bei jedem game angezeigt werden sondern nur die die zu dem jeweiligen Game abgeben wurden. Kann mit da jemand helfen ?
 
Werbung:
Habe es etwas anders aber es geht auch :)

functions.php
Code:
<?

 function template($template,$type="html") 
                  {
                  $folder = "templates";
                  return str_replace("\"","\\\"",implode("",file($folder."/".$template.".".$type)));                    
                  }
             
?>

mysql.php
Code:
<?

    $host = "localhost";
    $user = "dein USEr";
    $pass = "dein PW";
    $database = "deine Bank";

    mysql_connect("$host","$user","$pass") or die ("Keine Verbindung möglich");
    mysql_select_db("$database") or die ("Die Datenbank existiert nicht");
         
?>

index.php
Code:
<?
   include('mysql.php');
   include('functions.php');
      
   $site_title = "on GandC.de Games and Cheats";
   $site_footer = "(c) by gandc.de";
      
   $id = $_REQUEST['id'];  
           
   $sql_game ="SELECT title, description, file, quality, width, height FROM game WHERE id='".$id."'";                  
      $result_game = mysql_query($sql_game) OR die(mysql_error());
        
       while($row = mysql_fetch_assoc($result_game)) 
        {
        $id=$row['id'];
        $game_title=$row['title'];
        $game_description=$row['description'];
        $game_file=$row['file'];
        $game_quality=$row['quality'];
        $game_width=$row['width'];
        $game_height=$row['height'];                   
        }
 
   
   
   $sql_comments ="SELECT gameID, id, name, text FROM game_comments WHERE id='".$id."'";                  
      $result_comments = mysql_query($sql_comments) OR die(mysql_error());
      
      while($row = mysql_fetch_assoc($result_comments)) 
        {
        $gameID=$row['gameID'];
        $commentID=$row['id'];
        $comment_name=$row['name'];
        $comment_text=$row['text'];         
                   
                   
        }
   
   eval ("\$index = \"".template("index")."\";");
   echo $index;   
?>

Der Kommentar teil geht noch nicht, aber kommt noch

templates/index.html

Code:
<html> 
    <head> 
        <link href="index.css" rel="stylesheet" type="text/css">
        <title>$game_title $site_title</title> 
    </head> 
<body>      
    <table width="100%">
        <tr>
            <td class="title1" align="center">$game_title: $game_description</td>
        </tr>    
      <tr>
          <td><h2 align="center">
             <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="500" height="340" hspace="95" align="bottom" title="El Emigrante">  
             <param name="movie" value="$game_file"/>  
             <param name="quality" value="$game_quality"/>  
           <embed src="$game_file" width="$game_width" height="$game_height" hspace="95" align="bottom" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed> </object></h2></td>
      </tr> 
      <tr>
          <form action="index.php" method="post">
      <table width="366" border="0" align="center" bgcolor="#999999">
         <tr bgcolor='#DCE8F1'>
            <td>Name:</td>
            <td><input type="text" name="input_name" size="27" maxlength="20"></td>
            <td rowspan="2"><input type="submit" value="Go!" name="save"></td>           
          </tr>
         <tr bgcolor='#F3F7FA'>
            <td width=10%>Kommentar</td>
            <td><input type="text" name="input_comment" size="45" maxlength="150"></td>
                  </tr>
              </table>    
             </form>
             </tr>    
             <tr>
                 <td>Name: $comment_name</td>
                 <td>Kommentar: $comment_text</td>
             </tr>             
    </table> 
</body> 
</html>
ICh hoffe so ist es okay:)
 
danke ich probier es gleich aus. Funkzioniert das mit den kommentaren jetzt schon oder muss ich das noch versuchen ob ich es schaff.
Wie sieht bis jetzt die mysql-datenbank aus?
 
Werbung:
Der Kommentar Code werde ich dir geben sobald ich es fertig habe. achso ja du musst also eine Tabelle

Code:
CREATE TABLE `game` (
  `id` int(11) NOT NULL auto_increment,
  `title` varchar(100) collate latin1_general_ci NOT NULL,
  `description` varchar(255) collate latin1_general_ci NOT NULL,
  `file` varchar(100) collate latin1_general_ci NOT NULL,
  `quality` varchar(10) collate latin1_general_ci NOT NULL,
  `width` varchar(10) collate latin1_general_ci NOT NULL,
  `height` varchar(10) collate latin1_general_ci NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=3 ;

Der ganze Code zum Importieren:

Code:
-- phpMyAdmin SQL Dump
-- version 2.8.1
-- http://www.phpmyadmin.net
-- 
-- Host: localhost
-- Erstellungszeit: 07. Juli 2006 um 18:03
-- Server Version: 5.0.21
-- PHP-Version: 5.1.4
-- 
-- Datenbank: `test`
-- 

-- --------------------------------------------------------

-- 
-- Tabellenstruktur für Tabelle `game`
-- 

CREATE TABLE `game` (
  `id` int(11) NOT NULL auto_increment,
  `title` varchar(100) collate latin1_general_ci NOT NULL,
  `description` varchar(255) collate latin1_general_ci NOT NULL,
  `file` varchar(100) collate latin1_general_ci NOT NULL,
  `quality` varchar(10) collate latin1_general_ci NOT NULL,
  `width` varchar(10) collate latin1_general_ci NOT NULL,
  `height` varchar(10) collate latin1_general_ci NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=3 ;

-- 
-- Daten für Tabelle `game`
-- 

INSERT INTO `game` VALUES (1, 'Test Game', 'Test Beschreibung', 'testfile.swf', 'high', '500', '500');
INSERT INTO `game` VALUES (2, 'Mario Kart', 'Punkte sammlen und Gewinnen', 'kart-swf', 'high', '350', '350');
 
ich werde es ausprobieren. Kannst du mir vielleicht noch so einen ganz kleinen Counter reinbauen der ganz unten schreibt.
Das Spiel wird * mal gespielt. Das ganze sollte in der game Datenbank unter plays gespeichert werden. Ist das möglich.

EDIT: Funkzioniert leider nicht wegen den commentaren. Da steht nur:
Table 'gandc.game_comments' doesn't exist
 
Zuletzt bearbeitet:
Das mit dem Counter kannste auch selbst macehn gibt genug beispiele im Internet. Ja du musst den Kommentar teil dann rausmachen.
 
Werbung:
Werbung:
Status
Für weitere Antworten geschlossen.
Zurück
Oben