SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2000
    Location
    Catalonia
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help: generate dynamic pages for each row

    Hi,

    I've tried to do it myself testing a variety of codes but the success doesn't come
    I want to generate dynamic pages for each row that i have in the db. That's it: one page <=> one row.

    --> Add-on to my ask: i want to generate pages like index.php?id=200, without having to make every page myself. That's what i was trying to say: each row in the db has its own page.<--

    If someone can tell me how to do it or where to find it i'd be very very happy!
    Last edited by ax3; Oct 25, 2001 at 00:15.

  2. #2
    SitePoint Guru Majglow's Avatar
    Join Date
    Aug 1999
    Location
    B-Town
    Posts
    645
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,

    I'm sorry, but I didn't exactly understand what you are trying to do.

    Carl
    Ohai!

  3. #3
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You will need to have an id for each row. You will then be able to select your data from the table where the id is the id you call the script with:

    script.php?id=12

    then SELECT * FROM table where id = '$id'

    Sean
    Last edited by seanf; Oct 25, 2001 at 11:07.
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2000
    Location
    Catalonia
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I modify my question above 4 better understanding.

  5. #5
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by seanf
    SELECT * FROM table where id = '$id'
    have you tried that?

  6. #6
    SitePoint Enthusiast
    Join Date
    Aug 2000
    Location
    Catalonia
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, that's the function that has been nearest of what i'm trying to do:

    PHP Code:
    function club() { 
    $result mysql_query("SELECT * FROM es WHERE zona ='and'"); 
    while (
    $row mysql_fetch_array($result)) { //gets error here
    $output "<a href=\"$php_self?content=$row[idn]\">".stripslashes($row[nom])."</a><br>"
    }
    echo 
    $output;

    function 
    es($id) { 
    $result mysql_query("SELECT * FROM `es`
    WHERE ((`zona` ='and') AND (`idn` = '
    $id'))"); 
    while (
    $row mysql_fetch_array($result)) { //error here too
    $output "<h3>$row[nom]</h3>"
    $output .="<br>".stripslashes($row[poblacio])."<br>"

    return 
    $output

    And the output result errors are:
    "Warning: Supplied argument is not a valid MySQL result resource in ..."

    Then I call them:
    PHP Code:
    echo club();
    echo 
    es($content); 

  7. #7
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    hmm

    Hmm...

    Did you connect to the database???

    I alway spit it up into smaller pieces so it is very clear what is happening.. lets see

    Lets try this:

    Code:
    function club() { 
    $sql = "SELECT * FROM es WHERE zona ='and'";
    $result = mysql_query($sql)
    	or die("No result.");
    
    $row = mysql_fetch_array($result);
    
    while ($row){
    
    $output = "<a href=\"$php_self?content=$row[idn]\">".stripslashes($row[nom])."</a><br>"; 
    
    echo $output;
    }
    And ofcourse something like that for the other function aswell..

    If you still get an error try mysql_error() in the or die part so you get the exact error..

    Good luck,

    Peanuts
    the neigbours (free) WIFI makes it just a little more fun

  8. #8
    SitePoint Enthusiast
    Join Date
    Aug 2000
    Location
    Catalonia
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Doing like you've said Peanuts I get this:
    "Parse error: parse error in C:\apache\htdocs\edj\es\clubs\es\and15.php on line 86"

    and line 86 is after the </html>


  9. #9
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you close everything off all the echo's all the if - elses ??

    You have to make sure all the stuff is closed.. So all { have }
    and all the echo " have ";

    otherwise dump the complete code here or in a pm ...

    Greets

    Peanuts
    the neigbours (free) WIFI makes it just a little more fun

  10. #10
    SitePoint Enthusiast
    Join Date
    Aug 2000
    Location
    Catalonia
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, now it does run.

    But i don't understand why i get no results, although having the db connections well.
    Can the problem be "echo es($content);"???

  11. #11
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've answered your pm!!!
    the neigbours (free) WIFI makes it just a little more fun


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
  •