Hello and welcome to our community! Is this your first visit?
Register
Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: php mysql

  1. #1
    Veteran Enthusiast

    Join Date
    Jul 2006
    Location
    106 is fumpin', pumpin' up in this hoe, for sho, my bro
    Posts
    7,112

    php mysql

    I have managed to create a register and login system using cookies etc. (don't worry, the passwords are encrypted), and I have made it so the admin is the only person to be able to get to the admin cp, and members can get to the member cp.
    Is there a way to be able to display all the things in a dir with buttons next to them to delete the file?

    I have this to display everything in the dir if that helps:

    Code:
    function displayImages($pathToImages) 
    {
      $dir = opendir( $pathToImages );
      while (false !== ($name = readdir($dir)))
      {
        if ($name != '.' && $name != '..') 
        {
          echo "
    
    <a href=\"{$pathToImages}{$name}\">{$name}</a></p>";
        }
      }
      closedir( $dir );
    }
    Is it possible to be able to avoid javascript entirely?
    [center:3mdlh4lx]Fuck you. Cunt.[/center:3mdlh4lx]

  2. #2
    Obsessed Veteran Adam's Avatar



    Join Date
    Nov 2004
    Location
    UK / England
    Posts
    17,271

    Re: php mysql

    "Is it possible to be able to avoid javascript entirely?"

    Er what? JavaScript runs clientside not serverside, no idea why you said that.

    Use the unlink function to delete a file;

    http://uk.php.net/unlink

    Just create another funciton / or if statement, i.e deleteFile($file) pass file to unlink and done.

    When your listing a files add another html link called Delete, and make it's location, be a get url to the current script. You can then use an IF to check if del or some other attribute has been set and use a paremeter as the file to remove.

    THIS?&del=true&file=foobar.png

    http://www.w3schools.com/PHP/php_get.asp

    Probably best to use a database, with an id passed to the file paremter, that links to the filename stored on the server, as the browser make put junk in file name which may have strange characters, thus resulting in errors.

  3. #3
    Veteran Enthusiast

    Join Date
    Jul 2006
    Location
    106 is fumpin', pumpin' up in this hoe, for sho, my bro
    Posts
    7,112

    Re: php mysql

    Ok,thanks, and I get what you are saying (apart from using a database, still a complete noob in relation to them).
    And I said about javascript for the buttons, I never thought of doing a link like what you suggested.

    Another question, related sort of.
    It is an image gallery that lets the admin upload images and other people view them (maybe comment on them later on in the project). The gallery will have 2 different sections (for example traditional and digital) What would be the best way to output this?
    Would it be best to have them uploaded to different directories based on what the admin chooses (radio box or whatever) or is it possible to have it sorted on a column in the database?
    Right now I just have it uploading to one directory, and the gallery output I am working on (probably just going to google a viewer script)
    [center:3mdlh4lx]Fuck you. Cunt.[/center:3mdlh4lx]

  4. #4
    Japanologist Wilio's Avatar

    Join Date
    Dec 2005
    Location
    Somewhere in time
    Posts
    5,561

    Re: php mysql

    My idea would be having a column in the table called type(including, filename, date, id, last update date, etc..). In this column, either digital and traditional will be input as a string. On the digital thumbnail, it will seek all images classed as digital and the same for traditional.

    To manage it with ease a management page can be a good idea. Such as updating or deleting an image. That way, you don't need to manually delete/update the file from a FTP Client and manually delete/update its row in the tables, as a management page can do all this automaticly.

    Everything I said can be done easily. I'm sure you have the knowledge for it.

  5. #5
    Obsessed Veteran Adam's Avatar



    Join Date
    Nov 2004
    Location
    UK / England
    Posts
    17,271

    Re: php mysql

    The only way to efficienty achieve what you are asking is to create a database.

  6. #6
    Veteran Enthusiast

    Join Date
    Jul 2006
    Location
    106 is fumpin', pumpin' up in this hoe, for sho, my bro
    Posts
    7,112

    Re: php mysql

    Quote Originally Posted by Will
    My idea would be having a column in the Database called type. In this column, either digital and traditional will be input as a string. On the digital thumbnail, it will seek all images classed as digital and the same for traditional.

    To manage it with ease a management page can be a good idea. Such as updating or deleting an image. That way, you don't need to manually delete/update the file from a FTP Client and manually delete/update its row in the tables, as a management page can do all this automaticly.

    Everything I said can be done easily. I'm sure you have the knowledge for it.
    As I said I am a nub for databases. And I am creating a management page, as I have to do basically all of the coding (school project). That is why I wanted to know about the delete thing.

    I have a database already created for the members names and passwords, do I use the same database for the images and type(traditional, digital)?
    How would making it databased effect my uploader?
    Can databases hold images, or just links to images?
    I suppose when uploading, I would add a bit to the end of the script to create a new row in the database, with the type in it?

    Damn, so many questions, again thanks for the help <3
    [center:3mdlh4lx]Fuck you. Cunt.[/center:3mdlh4lx]

  7. #7
    Obsessed Veteran Adam's Avatar



    Join Date
    Nov 2004
    Location
    UK / England
    Posts
    17,271

    Re: php mysql

    You would create another table, with new fields for whatever your trying to do. A database can store images.. but what's the point when you can just store the filename as a string and refer to it.

    Databases are quite easy once you get going.

  8. #8
    Veteran Enthusiast

    Join Date
    Jul 2006
    Location
    106 is fumpin', pumpin' up in this hoe, for sho, my bro
    Posts
    7,112

    Re: php mysql

    Ok cool. I will get reading some tutorials for these bad boys.
    So yeah, uploading as normal, and then adding a row in the database would be best?
    [center:3mdlh4lx]Fuck you. Cunt.[/center:3mdlh4lx]

  9. #9
    Obsessed Veteran Adam's Avatar



    Join Date
    Nov 2004
    Location
    UK / England
    Posts
    17,271

    Re: php mysql

    Ya, just insert the name of the file, IP of the submitter if you wanted it, date if you wanted it etc.

  10. #10
    Veteran Enthusiast

    Join Date
    Jul 2006
    Location
    106 is fumpin', pumpin' up in this hoe, for sho, my bro
    Posts
    7,112

    Re: php mysql

    Ok, new sort of related question, where is a good (preferable free / cheap ) host that has mysql databases (I only need 1) and allows php. Byethost has stopped working on 2 accounts, the new host (2 different ones) both don't allow me creating and giving people cookies for some fucked up unknown reason.
    Anyone?
    [center:3mdlh4lx]Fuck you. Cunt.[/center:3mdlh4lx]


 
Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •