Announcement

Collapse
No announcement yet.

Code request

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

  • Code request

    I am student and I want to create my own HTML database for my education and future work.

    My database will have lots of small image with it's own Title, comments and hidden tags for each image.

    One example below
    Screen shot 2011-04-30 at 2.51.03 PM.jpg

    I want to have a search box in the top of HTML page, which should provide me the results when I type the particular hidden tag.

    I also want to create a smart link for each tag (Tags cloud) which can automatically retrieve the corresponding image. For example I want to have a link for Food which can bring the images belongs to Food.

    I also don't know how to give hidden tags for each image in HTML coding.

    Any of you please help me.. I know HTML coding but much about CSS & Java
    Attached Files

  • #2
    Re: Code request

    I don't know much about making websites, but I don't think there's such a thing as an "HTML database" per se. I think what you're looking for is an SQL database. BTW, if you do use an SQL database, I think you will need to use PHP on your website. And I assume you mean "I know HTML coding but NOT much about CSS & Java". CSS has nothing to do with the database, it's mainly for formatting your website. You can use Java to access databases, but I don't think that's the optimal way to do this.

    Comment


    • #3
      Re: Code request

      Yes, like randomguy said, it might be better if you use a mysql database and php to access it :)
      It easily combats your hidden tag problem, you just have a column in your database called tags, then you search for the tag you want :)

      Comment


      • #4
        Re: Code request

        I don't know how you would make a search box in html to call the tags but a simple start to your tag cloud would be like:
        <a href="#food">food</a> <- Put it in your tag cloud.

        Then, where ever your image that you wanted to link to on the page would be:
        <dt id="food">food</dt> <- images for food go after this

        That way whenever you you click the food link it will scroll down the page to the food tag where you have your food images.
        Unless you were asked to use HTML 5? Then I couldn't help you.
        Retired and happy :)

        Comment


        • #5
          Re: Code request

          Thanks for your suggestion "Synth"

          but this will not work since it has lots of images for a single. I think I have to go on with Mysql and php.

          ---------- Post added at 02:34 PM ---------- Previous post was at 02:32 PM ----------

          Last two days I learned a lot about php and mysql. I planed to create a table with 4 columns (Title, image, comments and tags) in mysql database (It will have thousand of rows).

          I want to view my database in a web browser using php scripts.

          My questions.

          Is it possible to add an image into mysql database? or any other way to work around (I always view the database in a web browser)
          How to get a search box (script?) in html page where I can search for a particular tag.
          What is php script that will bring the particular tag in HTML page.

          I hope somebody can help me.... Thanks

          Comment


          • #6
            Re: Code request

            @ramkat, store all your images in a folder called images or something, then in the mysql database just put the filename of the image, then call it back using php.

            For your search question, create a nice little form, get the input using $_POST, then search the database with something like this:
            PHP Code:
            //Connect to mysql databse
            $result mysql_query("SELECT * FROM mytable WHERE tag LIKE '%$_POST['search']%' "
            //% is a wildcard symbol
            or die(mysql_error()); 
            Then you can display it like so:
            PHP Code:
            while($row mysql_fetch_array$result )) {
                
            // Print out the contents of each row
                
            echo $row['Title']." <img src=" .$row['image']. " alt='Big Boat' ... //rest of what you want to display, either from the table or other html

            ?> 
            My syntax may be slightly wrong, but it's the basic idea :)
            I also heartily recommend MySQL Tutorial - Introduction and the PHP: Hypertext Preprocessor website too for tutorials, examples and anything else you need.
            Last edited by CerealGOAT; May 2, 2011, 10:33 AM.

            Comment


            • #7
              Re: Code request

              Thanks for your help and learned a lot about php and MySQL

              I am successful to submit data from a browser and also retrieve the submitted data from MySQL. Since I am a newbie, I have the following to problems to solve,

              1. I can retrieve the data from MySQL and can view the results from the php file by opening it in a browser.

              I don't know how to bring the php file output to a html page, so that I can view my MySQL data from a html page and I want to add more html codes to get better view of the results.

              2. I want to add a search form in the html page, so that I can search the MySQL database and view the results back in html page.

              3. I have a column named "tag" in my database and each row has several words on the tag column.

              I want to have a link for each tag in my html page that can bring me the results of the corresponding tags.


              Here's the script that I have done so far.

              HTML form to submit data

              <html><body>
              <form enctype="multipart/form-data" action="randam_new.php" method="POST">
              Title: <input type="text" name="title"><br>
              Year: <input type="text" name = "year"><br>
              Tags: <input type="text" name = "tag"><br>
              DOI: <input type="text" name = "doi"><br>

              <table>
              <tr>
              <td width="246">
              Image: <input type="hidden" name="MAX_FILE_SIZE" value="2000000">
              <input name="userfile" type="file" id="userfile">
              </td>
              <td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
              </tr>
              </table></form></body></html>

              php script to write the submitted data into MySQL database

              <?php
              $uploadDir = 'images/';

              $title=$_POST['title'];
              $year=$_POST['year'];
              $tag=$_POST['tag'];
              $doi=$_POST['doi'];

              if(isset($_POST['upload']))
              {
              $fileName = $_FILES['userfile']['name'];
              $tmpName = $_FILES['userfile']['tmp_name'];


              // get the file extension first
              $ext = substr(strrchr($fileName, "."), 1);

              // make the random file name
              $randName = md5(rand() * time());


              //$filePath = $uploadDir . $fileName;
              $filePath = $randName . '.' . $ext;

              $result = move_uploaded_file($tmpName, $uploadDir.$filePath);
              if (!$result) {
              echo "Error uploading file";
              exit;
              }

              include '../library/config.php';
              include '../library/opendb.php';

              if(!get_magic_quotes_gpc())
              {
              $fileName = addslashes($fileName);
              $filePath = addslashes($filePath);
              }


              // Connects to your Database
              mysql_connect("127.0.0.1", "Ramesh", "") or die(mysql_error()) ;
              mysql_select_db("test") or die(mysql_error()) ;

              $query = "INSERT IGNORE INTO new2 (title, year, tag, doi, image ) ".
              "VALUES ('$title', '$year', '$tag', '$doi', '$filePath')";

              mysql_query($query) or die('Error, query failed : ' . mysql_error());

              include '../library/closedb.php';

              echo "<br>Files uploaded<br>";

              }
              ?>


              php script to retrieve the data from MySQL


              <?php
              // Connects to your Database
              mysql_connect("127.0.0.1", "Ramesh", "") or die(mysql_error()) ;
              mysql_select_db("test") or die(mysql_error()) ;

              //Retrieves data from MySQL
              $data = mysql_query("SELECT * FROM new2") or die(mysql_error());
              //Puts it into an array
              while($info = mysql_fetch_array( $data ))

              {
              //Outputs the image and other data
              Echo "<b>Title:</b> ".$info['title'] . "<br> ";
              Echo "<b>Year:</b> ".$info['year'] . " <br>";
              Echo "<b>Tag:</b> ".$info['tag'] . " <br>";
              Echo "<b>DOI:</b> ".$info['doi'] . " <br>";
              Echo "<img src=images/".$info['image'] ."> <hr>";
              }
              ?>


              Please assist me to get better coding.

              Comment


              • #8
                Re: Code request

                you need to make a data base for the images to be saved on to in MYSQL and then you need to make a record set to retrieve the pics in a search bar witch is also a MYSQL query of the same record set as the images as in if you call the record set lets say a catalog for albums EG(

                <table width="180" border="0" cellspacing="0" cellpadding="2">
                <tr height="30">
                <td height="30" width="160" bgcolor="#89AA80"><font face="Verdana, Geneva, sans-serif" size="2" color="#FFFFFF"><strong>Search Catalogue</strong></font></td>
                </tr>
                <tr height="3">
                <td height="3" width="160" bgcolor="#FFFFFF">&nbsp;</td>
                </tr>
                <tr>
                <td width="160" bgcolor="#FFFFFF">

                </td>
                </tr>
                </table>

                <!-- end here-->

                <table width="100%" border="0" cellspacing="0" cellpadding="2">
                <tr>
                <td>&nbsp;</td>
                <td><strong>Album</strong></td>
                <td><strong>Artist</strong></td>
                <td><strong>Style</strong></td>
                <td><strong>Price</strong></td>
                </tr>
                <?php do { ?>
                <tr>
                <td><img src="<?php echo $Search_catalog['AlbumCoverThumbnailURL']; ?>" alt="Album Cover"></td>
                <td><a href="albumdetail.php?albumID=<?php echo $Search_catalog['AlbumID']; ?>"><?php echo $Search_catalog['AlbumName']; ?></a></td>
                <td><?php echo $Search_catalog['ArtistGroupName']; ?></td>
                <td><?php echo$Search_catalog['ArtistStyle']; ?></td>
                <td>$<?php echo $Search_catalog['AlbumPrice']; ?></td>
                </tr>
                <?php } while ($Search_catalog = mysql_fetch_assoc($catalog)); ?>
                </table>




                that will retrieve different results like if you type 19$ all albums worth 19$ will popup there is a little more to add ill type the rest tomorrow ill give you a preview of a page with the whole code written in it and functioning ok if you want
                Last edited by shollibone; May 13, 2011, 09:01 AM.

                Comment

                Working...
                X