#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Surabaya, Indonesia
    Posts
    3
    Rep Power
    0
    Hello...

    I'm having problems creating urls when taking data from a table.
    for example a table with NewsId, NewsDate, NewsTime, NewsTitle, NewsAbstrak, NewsDetails. Then you've set up a template there this information will be displayed.

    You have this information in the database :
    NewsID : 10
    NewsDate : 02 August 2000, NewsTime : 21:30:35
    NewsTitle : Whatever
    NewsAbstrak : Information about News

    Now in this template it should create an URL for this info That looks something like : www.coba.com/ShowNews.php3?id=10

    When the user click on this link. another page will be appear with information like :
    NewsID : 10
    NewsDate : 02 August 2000, NewsTime : 21:30:35
    NewsTitle : Some Information
    NewsAbstrak : Some Information
    NewsDetails : Some Indormation--->(Important)

    Does anyone know how to write this ?
    I appreciate all your help, haven't found any good tutorial for this kind of thing..

    For Mr. Shiju Rajan----> thanks for your answering my problem...in (problem...php and mysql)

    Thanks in advance
    andre
    WebDeveloper from Indonesia
  2. #2
  3. Senior Member
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2000
    Location
    Enschede, The Netherlands
    Posts
    1,527
    Rep Power
    16
    Hi Andre,

    I assume the first time the info will be displayed you display all the items on a page and you want users to be able to read the whole article.. Am I right?

    In that case, it will look something like this:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>
    NewsID NewsDate NewsTitle NewsAbstrak
    ---------------------------------------------
    9 1/1/2000 News is new Nonsense
    10 2/1/2000 This is newer Also nonsense
    [/quote]

    Since you would retrieve all data from a database in a loop you can generate a link to the 'more-info-page' by doind something like this:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>
    print( "<tr>" );
    print( "<td><a href="http://www.coba.com/ShowNews.php3?id=".$row["NewsID"]."">".$row["NewsID"]."</a></td>" );
    print( "<td>Other columns</td>" );
    print( "</tr>" );
    [/quote]

    And this for each news-item.
    $row = mysql_fetch_array( $result ); btw

    The page ShowNews could look something like:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>
    <?php

    if ( $id ) { // when an individual news-item should be showed
    // get only data from table where id=$id
    }
    else {
    // show all data
    }

    ?>
    [/quote]

    Well, I hope this helps and I hope I understood your problem well.

    Mirax
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Pune, Maharashtra, India
    Posts
    86
    Rep Power
    15
    Try something like this:
    $sql="Select * from newstablename";
    $result=mysql_query($sql);
    while($re=mysql_fetch_array($result))
    {
    echo("<a href="www.coba.com/ShowNews.php3?id=$re['id'];>$re['title'];");
    }


    ------------------
    Nikunj
    MYSQL/PHP/XML
    ** Expertise comes with experiece ** Nikunj
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Surabaya, Indonesia
    Posts
    3
    Rep Power
    0
    Thanks You Guys...

    my problem is..at the user click www.coba.com/ShowNews.php3?Id=10 data can not be display...I dont Know What I'm Wrong..
    Mr. Mirax and Mr. Nikunjh would you mind If want your help..
    My script for ShowNews.php3 is :

    <?php
    require("coba.inc.php3");
    $tablename = "BERITA";

    mysql_connect($hostname,$username,$password);
    mysql_select_db($databasename);

    $result=mysql_query("SELECT * FROM $tablename WHERE BeritaId ='$query'");

    if(mysql_num_rows($result)==1) {
    ?>
    <?php echo $row[1] ?>
    <?php echo "&nbsp&nbsp&nbsp&nbsp" ?>
    <?php echo $row[2] ?>
    <?php echo "&nbsp&nbsp&nbsp&nbsp" ?>
    <?php echo $row[3] ?>
    <?}?>

    Thanks in advance..
    andre
    Indonesia

    ------------------
    adipoer@esensi.com
  8. #5
  9. Senior Member
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2000
    Location
    Enschede, The Netherlands
    Posts
    1,527
    Rep Power
    16
    Hi Andre,

    I don't know what's in your coba.inc.php3 so I don't know if you already have some of the code below:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>
    <?php

    require("coba.inc.php3");
    $tablename = "BERITA";

    mysql_connect($hostname,$username,$password);
    mysql_select_db($databasename);

    $result=mysql_query("SELECT * FROM $tablename WHERE BeritaId ='$id'"); //The name you give it when you call the page

    //if(mysql_num_rows($result)==1) {
    //?>
    //<?php echo $row[1] ?>
    //<?php echo " " ?>
    //<?php echo $row[2] ?>
    //<?php echo " " ?>
    //<?php echo $row[3] ?>
    //<?}
    // First of all, you don't decalre $row

    $row = mysql_fetch_array( $result );
    do {
    print( $row["1"] );
    print( " " );
    print( $row["2"] );
    print( " " );
    print( $row["3"] );
    }
    while ($row = mysql_fetch_array( $result ));
    // this works also if the query returns multiple results.. in your case (with the id) it should return just one, so this works fine
    // if it's not certain the query gives a result, you could put if 'around' the fetch_array thing and make an else statement


    ?>
    [/quote]

    Mirax

Similar Threads

  1. PHPSESSID shown in URL on firstload of my site...
    By agatt42 in forum PHP Development
    Replies: 7
    Last Post: March 11th, 2004, 08:10 PM
  2. UTF-8 problem in 4.1.1a
    By mehran20 in forum MySQL Help
    Replies: 1
    Last Post: February 8th, 2004, 02:21 PM
  3. Wierd problem inserting data with VB6
    By gregquinn in forum MySQL Help
    Replies: 5
    Last Post: February 2nd, 2004, 07:37 AM
  4. Decode problem [Only Perl related : NO ]
    By mono in forum Perl Programming
    Replies: 0
    Last Post: January 31st, 2004, 07:49 AM
  5. Display and Refresh of PHP in URL query
    By wuji in forum PHP Development
    Replies: 3
    Last Post: January 30th, 2004, 12:20 PM

IMN logo majestic logo threadwatch logo seochat tools logo