Results 1 to 4 of 4

Thread: New to SQL

  1. #1
    Join Date
    Jun 2005
    Location
    Canada
    Posts
    68
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default New to SQL

    I am starting the process of learning MySQL through W3 Schools and going to develop it on a WAMP localhost. By and large it seems straight forward enough BUT - before I make a complete hash of it I have what I know will be a very elementary question.
    When I call up the db into the web site, I will want the images and product names linked to an outside URL. When I set the db up do I place the information directly in the field (i.e: <URL-TAG>Product- A</a> or am I calling the information from two distinct cells of the db (i.e. a column with the URL and a column for the Product Name)?
    I realize this is basic stuff, but it will clearly help me get my head around this dbase process since I have never developed one before.

    Thanks
    D

  2. #2
    Join Date
    Jul 2007
    Location
    Azerbaijan, Baku
    Posts
    144
    Thanks
    11
    Thanked 27 Times in 25 Posts

    Default

    I don't know if i understood you correctly, but let me answer.

    "I am calling the information from two distinct cells of the db" - this. For url one and for product name other one.

  3. #3
    Join Date
    Jun 2005
    Location
    Canada
    Posts
    68
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default

    To be clear Allahverdi, in html when one requires an image or text with a link it is set up <a href="http://www.xyz.com" title=""><img src="images/pic.jpg"</a>
    So my question is this! How is the image column merged with the URL to gain the same effect in MySql.
    Hopefully, I did a better job of explaining it this time out.

    Many thanks
    D

  4. #4
    Join Date
    Jul 2007
    Location
    Azerbaijan, Baku
    Posts
    144
    Thanks
    11
    Thanked 27 Times in 25 Posts

    Default

    Then i said correct. Your table will be like this:

    imgsrc | url
    -------------------------------------
    images/pic1.jpg | http://www.xyz.com
    images/pic2.jpg | http://www.ccc.com
    images/pic3.jpg | http://www.dsd.com

    If you are doing it with php, your query will be like this:

    Code:
    <?php
    $result = mysql_query("SELECT * FROM mytable");
    while($rows = mysql_fetch_array($result, MYSQL_ASSOC)){ //this will get all rows
    $img = $rows['imgsrc']; //imgsrc coloumn
    $url = $rows['url']; //url coloumn
    echo"<a href=".$url."><img src=".$img." /></a> <br/>"; //echo image and url
    }
    ?>
    Output will be:

    Code:
    <a href="http://www.xyz.com"><img src="images/pic1.jpg"/></a>
    <a href="http://www.ccc.com"><img src="images/pic2.jpg"/></a>
    <a href="http://www.dsd.com"><img src="images/pic3.jpg"/></a>
    This output is just it's source. But it will be like image and when you click it goes to that url.

    I wish it will help you.

  5. The Following User Says Thank You to allahverdi For This Useful Post:

    Diversions (06-24-2008)

Bookmarks

Posting Permissions

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