Anfänger sucht hilfe!!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Anfänger sucht hilfe!!

    Hallo Leute ich hab da wieder was für euch und zwar wollte ich mal wissen wie ich das machen kann wenn ich 2 Seiten habe die so aussehen


    index.php

    PHP Code:
    <?php 

    $mp3_1
    ="test/song1.mp3"
    $mp3_2="test/song2.mp3"
    ?>

    <html>
    <body>
    <embed src="<? echo  //je nach Link ?>" type="application/x-mplayer2"></embed>
    </body>
    </html>
    liste.php

    PHP Code:

    <?php

    ?>

    <html>
    <body>
    <a href="index.php">song1</a>
    <a href="index.php">song2</a>
    </body>
    </html>

    ich wollte das so haben das wenn ich ein link anklicke das er dann weiss welches lied ich haben möchte und demantsprechend einfügt.
    So das ich bloß eine datei brauche aber mehrere songs hören kann.
    Ich hoffe ihr wisst was ich meine , danke schonmal

    Terrorzwerg

  • #2
    PHP Code:
    <?php 
    $mp3
    =array(
      
    "test/song1.mp3",
      
    "test/song2.mp3"
    );
    $id = isset( $_GET['mp3'] ) ? intval$_GET['mp3'] ) : 0;
    if( !isset( 
    $mp3[$id] ) ) {
      
    $id 0;
    }
    // ...
    <? echo  $mp3[$id]; ?>
    ?>


    <a href="index.php?mp3=0">song1</a>
    <a href="index.php?mp3=1">song2</a>

    Comment


    • #3
      liste.php

      PHP Code:
      <a href="index.php?titel=1">song 1</a>
      <
      a href="index.php?titel=2">song 2</a
      index.php

      PHP Code:
      if(isset($_GET['titel'])){
       echo 
      "<embed src=\"song".$_GET['titel'].".mp3\" type=\"application/x-mplayer2\"></embed>";
      }else{
       echo 
      "Sie haben keine Auswahl getroffen!";

      mit der $_GET variable werden übergebene Daten abgefragt.

      Gruß
      Jan

      Comment


      • #4
        Füge einen Paramenter zur Identifizierung des Songs ein
        PHP Code:
        <html>
        <
        body>
        <
        a href="index.php?song=song1.mp3">song1</a>
        <
        a href="index.php?song=song2.mp3">song2</a>
        </
        body>
        </
        html>

        //index.php
        $songs['song1.mp3'] = 'test/song1.mp3';
        $songs['song2.mp3'] = 'test/song2.mp3';
        if(
        array_key_exists($_GET['song'],$songs)){
            echo 
        '<embed src="'.$songs[$_GET['song']].'" type="application/x-mplayer2"></embed>';

        Irgendwie so z.B.
        Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

        [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
        Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

        Comment


        • #5
          PHP Code:

          <a href="index.php?mp3_0">song1</a>
          <
          a href="index.php?mp3_1">song2</a
          meine seite ist schon so aufgebaut das bei index schon folgendes steht

          index.php?site=music


          wie sieht das da aus?

          danke im vorraus

          Comment


          • #6
            Das ist kein mp3_1 sonder mp3=1 in der Url in meinem Beispiel.
            Bei weiteren Parametern musst du ein & zwischen die Parameter schreiben (für XHTML bitte ein & amp:
            Code:
            index.php?site=music&mp3=1

            Comment


            • #7
              oh sorry, aber dankeschön

              Comment

              Working...
              X