1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Convert Mysql DB into html page

Discussion in 'PHP' started by mahdi_fci3, Jul 19, 2010.

  1. #1
    hi all
    I would like to convert data I get from DB into html page,
    for example: if the ID of a row in DB is 123 I need to display this row to www.sitename.com/displaypage-123.html

    Thnaks 4 ur reading.
     
    mahdi_fci3, Jul 19, 2010 IP
  2. yohanip

    yohanip Well-Known Member

    Messages:
    350
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #2
    using php should do the job fine ;)
     
    yohanip, Jul 19, 2010 IP
    lonewolff likes this.
  3. lonewolff

    lonewolff Member

    Messages:
    338
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    30
    #3
    Agreed, PHP is the way to go.
     
    lonewolff, Jul 19, 2010 IP
  4. kaviarasankk

    kaviarasankk Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    use MOD_REWRITE
     
    kaviarasankk, Jul 19, 2010 IP
  5. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #5

    You are either going to have to be more specific, or you should read up on how to process
    SQL data in PHP.

    You can start here; http://www.tizag.com/mysqlTutorial/

    Here's something to get you started but be warned its very basic, at its best.

    <?php
    mysql_connect("localhost", "yourDBuser", "yourDBpassword") or die(mysql_error());
    mysql_select_db("yourDB") or die(mysql_error());
    
    $sql = "SELECT ID from yourtable WHERE yourconditions";
    $res = mysql_query($sql) or die(mysql_error());
    
    while($r = mysql_fetch_array($res))
    	{
            # Or include HTML to format as a hyperlink
    	print "www.sitename.com/displaypage-".$r[0].".html<br />";
    	}
    ?>
    PHP:
     
    lukeg32, Jul 19, 2010 IP
  6. mahdi_fci3

    mahdi_fci3 Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thank u all
    but I need when I click an ID it must display the rest of the row to a new page, which means creating dynamic page
     
    Last edited: Jul 20, 2010
    mahdi_fci3, Jul 20, 2010 IP
  7. WhyButUs

    WhyButUs Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    So, make a php file, i.e. displaypage.php, pass ID with GET (displaypage.php?id=123 or any other number) and put in php code to connect to mysql, and extract row with given ID. And if you want your link to look something like displaypage-123.html, use Apache's MOD_REWRITE.
    If it is to hard for you, PM me, i'll try to help you with this.
     
    WhyButUs, Jul 20, 2010 IP
  8. mahdi_fci3

    mahdi_fci3 Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Thank u all 4 ur time especially WhyButUs
    I really need Apache's MOD_REWRITE. but I dont know how to do, now I am using displaypage.php?id=123 but I need to convert it as displaypage-123.html so please help me
     
    mahdi_fci3, Jul 25, 2010 IP
  9. Deacalion

    Deacalion Peon

    Messages:
    438
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Your .htaccess should look something like this:
    
    Options +FollowSymlinks
    RewriteEngine On
    
    RewriteRule ^displaypage-(.+)\.html$  displaypage.php?id=$1 [NC,L]
    
    Code (markup):
     
    Deacalion, Jul 25, 2010 IP
  10. lkboy4u

    lkboy4u Peon

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    You need to generating a cache of the parsed output of a PHP page. Change 'your-folder/displaypage-123.html' to point to the location and name of your static html file. The folder and file should have write permissions ( 666 ).

    Php ob_start() starts the caching process. http://php.net/manual/en/function.ob-start.php
     
    lkboy4u, Jul 25, 2010 IP