Need a help to show related file to show from mysql DB

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

    Need a help to show related file to show from mysql DB


    i'm working on an autoindex mp3 downloading script, GET_($id) @ Download page shows relevant id information. from $artist variable I need to search my DB_table and view Artists other songs in this page.

    table is like

    table name 'mp3'

    id - songurl - Song Title - Artist - Music - Lyrics - Size - Category - Date


    please help me

    #2
    PHP Code:
    $result mysqli_query($con"SELECT songurl, SongTitle FROM mp3 WHERE Artist='".$artist."'");
    $out 'More songs by same artist: <br/><br/>';
    while(
    $row mysqli_fetch_assoc($result))
    {
    $out .= '<a href="'.$row[0].'">'.$row[1].'</a><br/>';
    }
    echo 
    $out

    Comment


      #3
      it shows blank bro, tried so meny timesand I don't know why?

      But I just copied songurl, SongTitle FROM mp3 WHERE Artist="Gayan" and run on Phpmyadmin sql it is showing results .

      Comment


        #4
        <?php
        include(db_con.php);

        $result = mysqli_query($con, "SELECT `songurl`, `Songtitle`, `artist`, `cover` FROM `mp3` WHERE `artist`='".$artist."'");

        while($row = mysqli_fetch_array($result))
        {
        ?>

        <?php echo $row['cover'];?><br/>
        <?php echo $row['artist'];?><br/>
        <?php echo $row[' SongTitle'];?>

        <?php

        }

        mysqli_close($con);
        ?>
        Last edited by ayesham; 28.10.20, 04:39.

        Comment


          #5
          PHP Code:
          <?php
          include(db_con.php);
          $artist mysqli_real_escape_string($con$_REQUEST['artist']);  //use mysqli_real_escape_string on any user inputs to help avoid mysql injections
          //variable $artist needs to be set to something or collected from url or a form ($_GET or $_POST or for both $_REQUEST)


          $result mysqli_query($con"SELECT `songurl`, `Songtitle`, `artist`, `cover` FROM `mp3` WHERE `artist`='".$artist."'");

          while(
          $row mysqli_fetch_array($result))
          {
          echo 
          $row['cover'].'<br/>'
          .$row['artist'].'<br/>'
          .$row['SongTitle'].'<br/><br/>'//note you had a space in: $row['_SongTitle'];
          //try not to open and close php too much as it will cause your script to slow down, also avoid using too many echo's 
          }
          mysqli_close($con);
          ?>

          Comment


            #6
            to use php parsing in the forums use:
            [php]Your code here[/php]

            =

            PHP Code:
            Your code here 






            or for other codes:
            [code]Your code here[/code]

            =

            Code:
            Your code here

            Comment


              #7
              Hi @ayesham,

              Have you tried to catch any errors from the query? perhaps try:

              PHP Code:
              <?php
              include("db_con.php");

              $result mysqli_query($con"SELECT `songurl`, `Songtitle`, `artist`, `cover` FROM `mp3` WHERE `artist`='".$artist."'");

              // check that a result was found?
              if (!$result) {
              printf("Error: %s\n"mysqli_error($link));
              }

              // perhaps for debugging maybe just dump the result if the above doesn't work?
              // this should give you a peak inside the result variable
              die(var_dump($result));

              while (
              $row mysqli_fetch_array($result)) {
              echo 
              "{$row['cover']}<br/>";
              echo 
              "{$row['artist']}</br>";
              echo 
              "{$row['SongTitle']}";
              }

              mysqli_close($con);
              ?>
              Also I would recommend escaping your parameters like something else suggested, hope this helps

              Comment


                #8
                Slight adjustment of s2k 's code:
                PHP Code:
                // check that a result was found?
                if (!$result) {
                printf("Error: %s\n"mysqli_error($con));

                Comment


                  #9
                  Thanks something else took it from the PHP docs page :P

                  Comment


                    #10
                    tried my best but it shows blank only brothers

                    Comment


                      #11
                      With it as your code:
                      PHP Code:
                      <?php
                      include(db_con.php); //guessing mysqli has been connected here and stored in variable $con

                      $result mysqli_query($con"SELECT * FROM mp3 WHERE artist='".$_REQUEST['artist']."'");

                      while(
                      $row mysqli_fetch_array($result))
                      {
                      ?>

                      <?php echo $row['cover'];?><br/>
                      <?php echo $row['artist'];?><br/>
                      <?php echo $row['SongTitle'];?>

                      <?php

                      }

                      mysqli_close($con);
                      ?>
                      Note: This is unprotected against mysqli injections

                      Comment


                        #12
                        PHP Code:
                        $result mysqli_query($con"SELECT * FROM files WHERE artist='".$row['artist']."'");

                        while(
                        $row mysqli_fetch_array($result))

                        this was working fine thanks genius?

                        Comment

                        Working...
                        X