Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    Regular Coder
    Join Date
    May 2003
    Location
    34 54' N 82 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Add to database, create new file

    I want to insert information through a form to a databse (thats not the problem for me)...

    From each entry into the database I want to create a page for that i.e. http://www.mydomain.com/somefile.php?article=7787

    and that would intern lead the user to the 7787 article in the database. Same way for somefile.php?article=1, etc. etc.

    How can I do this??

    Thanks
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Are you joking ?

    You mean like George, who creates a new file each time you open a thread like showthread.php?threadid=26988

    What you describe are typical html-links in a dynamically generated page.
    For instance you select all articles of a firm and run the recordset in a while loop, building the urls like
    <a href=\"somepage?article=" . $row['aritcleID'] . "\"> ...
    and display them in a table like

    somepage.php?article=1
    somepage.php?article=2
    somepage.php?article=3
    somepage.php?article=4
    somepage.php?article=5
    somepage.php?article=6


    They all point to the same page (somefile.php) and inside
    somefile.php, you will grab the value for article (with $_GET['article'] and use it inside a select or so. Then you build the page with the results from the select and display them

    The whole point in a db-driven webapplication is to have only a few dynamically build files that completely generic and are filled in with date from the db.

    Or do i misunderstand the question ?

  • #3
    Regular Coder
    Join Date
    May 2003
    Location
    34 54' N 82 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No, you did not misunderstand the question. Now, could you show me the code of how to do this?

    Thanks....
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Euh ... OK. Say we have this page (page.php) where we select all articles from a specific catagory. So you build the selectstatement and run it, and then you loop through the recordset and build the list of links. Like:
    PHP Code:
    $select = ("SELECT articleID, articlename FROM article WHERE catagory = 1 "); // normally, this 1 will also be grabed from the querystring or from a form
    $result mysql_query($sql_select,$link) or die(mysql_error());
    while (
    $row mysql_fetch_array($results,$link)) {
           echo(
    "<br /><a href=\"somepage.php?article=" $row['articleID'] . "\" title=\"Show details of article "$row['articlename']. "\">All about " $row['articlename'] . "</a>");

    So this will display a list a links. When you hoover over them, you'll see the adress in the adresbar looks like http://domain.com/somepage.php?article=145
    http://domain.com/somepage.php?article=245
    http://domain.com/somepage.php?article=8
    etc

    If the user clicks on one of them, somepage.php is loaded.

    Now in this page, you will run some code for the selected article, like selecting all details of it, like
    PHP Code:
    $select=("SELECT article.articlename, article.price, suppliers.suppliername, suppliers.suppliersadress, suppliers.supplierID FROM article INNER JOIN suppliers ON article.supID = suppliers.suopliersID WHERE articleID = " $_GET['article'] ); // so the value is grabbed from the querystring and injected in the SQL statement
    $result mysql_query($select,$link);
    then your code to check if the recordset isnt empty and to display the data from the recordset 
    When you display this data, you could display the suppliersnames as links to "... href=\"supplierdetails.ph?supplier=" . $row['supplierID'] . "\" ..." etc

    You see ?

  • #5
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    If you are going to create static pages from the data submitted in the form then why do you also want to store it in a database?

    Like raf said if you just store it in the database you can then dynamically create the pages on the fly using a template. In other words, open the template stick in the data retrieved from the database and display it to the user.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #6
    Regular Coder
    Join Date
    May 2003
    Location
    34 54' N 82 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, then how can I dynamically create pages on the fly??

    Thanks
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #7
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Originally posted by SDP2006
    Well, then how can I dynamically create pages on the fly??

    Thanks
    Ok just to make sure you folks from South Carolina understand....when we say dynamically create pages on the fly we mean they do not actually exist and are only created temporarily using the data from the database and putting that data into the code being stored in the template.

    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #8
    Regular Coder
    Join Date
    May 2003
    Location
    34 54' N 82 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh yeah, spookster...

    Might wanna change ur sig, Isabel is only what? 2 weeks old?
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #9
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Originally posted by SDP2006
    Well, then how can I dynamically create pages on the fly??

    Thanks
    Do you even read the answers and code people give you?

  • #10
    Regular Coder
    Join Date
    May 2003
    Location
    34 54' N 82 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Of course I read them...geez
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #11
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    *cough* look at raf's post

  • #12
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Originally posted by SDP2006
    Oh yeah, spookster...

    Might wanna change ur sig, Isabel is only what? 2 weeks old?
    Is that better?


    Yes as Nightfire pointed out raf has already discussed this a bit. Besides there are many threads on this if you use the search feature not to mention dozens of tutorials on this at places like www.zend.com and www.php.net . You just have to look around.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #13
    Regular Coder
    Join Date
    May 2003
    Location
    34 54' N 82 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Love ur new sig...

    We here in tha Upstate caint reeed becuz of 'ire low eye q's
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!


  •  

    Posting Permissions

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