SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    May 2003
    Location
    Lanka
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Insert Html script into a table

    Hi guys,

    I'm a tranee php programer. I want to insert an variable which contain
    html code in to a mysql table (field type is text)please someone explain
    how to do it.here's the variable

    $test = "<table width=\"100%\" height=\"26\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
    <tr>
    <td height=\"26\" background=\"http://localhost/test/images/Layout_06.gif\">
    <table width=\"776\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">
    <tr>
    <td> <div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\" color=\"#666666\">Your
    company.com </font><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\" color=\"#666666\">&copy;
    2003</font></div></td>
    </tr>
    </table></td>
    </tr>
    </table> ";

  2. #2
    SitePoint Enthusiast lhatkins's Avatar
    Join Date
    Dec 2002
    Location
    Exeter, UK
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try a different type of data field, like longtext or longblog. Then insert into your table using the INSERT INTO table SET fieldname ='$test';
    Regards

    ---
    Lee

  3. #3
    SitePoint Member
    Join Date
    May 2003
    Location
    Lanka
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    had used both ,nothing happens and anyway can't use longbolb too big!!here's my query

    mysql_query ("INSERT INTO seller (header,footer)
    VALUES('$test')") die ("wwwww");

    ------------------
    hasitha

  4. #4
    SitePoint Addict
    Join Date
    Mar 2003
    Location
    In a house in the USA
    Posts
    293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this:
    PHP Code:
    CREATE TABLE tablename (
      
    fieldname longtext NOT NULL
    TYPE=MyISAM
    I hope this helps
    Daniel
    http://www.wlscripting.com - PHP Tutorials and code snippets
    Notepad++ Function List plugin tip - for PHP developers

  5. #5
    SitePoint Member
    Join Date
    May 2003
    Location
    Lanka
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it works.but tell me how you guys going to do it
    if you want to store some html coding in a
    database table

    thanks
    ------------------------
    hasitha

  6. #6
    SitePoint Addict
    Join Date
    Mar 2003
    Location
    In a house in the USA
    Posts
    293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What you will need to do is to query the database using something like:
    PHP Code:
    $q mysql_fetch_array(mysql_query("SELECT * FROM table_name WHERE id=1" )); 
    $test $q[Database Field];
    echo 
    $test
    Try something like that to show the database information.
    </FONT>
    Daniel
    http://www.wlscripting.com - PHP Tutorials and code snippets
    Notepad++ Function List plugin tip - for PHP developers

  7. #7
    SitePoint Enthusiast Powerlord's Avatar
    Join Date
    May 2003
    Location
    Mason, MI, USA
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by hasitha
    it works.but tell me how you guys going to do it
    if you want to store some html coding in a
    database table
    Personally, I try not to store html in the database itself... rather, I prefer creating columns for each piece of data I need to store, then reassemble the html code when I retrieve the values from the database.
    Ross Bemrose,
    Independant MySQL/Perl/PHP Developer

  8. #8
    SitePoint Member
    Join Date
    May 2003
    Location
    Lanka
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Quote Originally Posted by Powerlord
    Personally, I try not to store html in the database itself... rather, I prefer creating columns for each piece of data I need to store, then reassemble the html code when I retrieve the values from the database.
    I didn't get it!!!.


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
  •