Professional Web Applications Themes

Viewing records - MySQL

Hello friends, I have a mysql database which I am using in conjuction with PHP in hopes of allowing my website visitors to view the contents of the database. I invision an html form which contains the various fields of the database, along with (next) and (prev) buttons that will progress respectively through the records. I am running in to difficulties accomplishing this. This is what i have tried: //PHP code $sql = "select * from myTable" ; $result = mysql_query( $sql ) ; $row = mysql_fetch_row($result) ; $description = $row[ 0 ] ; Now, it was my hope tha ...

  1. #1

    Default Viewing records

    Hello friends,

    I have a mysql database which I am using in conjuction with PHP in
    hopes of allowing my website visitors to view the contents of the
    database. I invision an html form which contains the various fields
    of the database, along with (next) and (prev) buttons that will
    progress respectively through the records. I am running in to
    difficulties accomplishing this. This is what i have tried:

    //PHP code
    $sql = "select * from myTable" ;
    $result = mysql_query( $sql ) ;
    $row = mysql_fetch_row($result) ;
    $description = $row[ 0 ] ;

    Now, it was my hope tha I could also pass hidden form values (ie.
    $result) which could be used on subsequent (next) clicks to execute
    $row = mysql_fetch_row( $result ) and therefore obtain the new values
    for the next record. This doesn't seem to be working and it feels
    very hackish.

    What the correct way to accomplish what I'm trying to do?

    Thanks,

    Mike

    Cyron Guest

  2. #2

    Default Re: Viewing records

    Cyron wrote: 

    This had fit a lot better at alt.php.sql.
     
    No point asking the SQL to fetch all data, we can limit it with LIMIT x,y
     

    /* Just a sloppy test to set a value */
    $getthisrow=($_POST['row'])?$_POST['row']:0;
    $sql = "select * from myTable LIMIT {$getthisrow},1";
    $result = mysql_query( $sql );
    $row = mysql_fetch_row($result);
    $description = $row[ 0 ];

    /* If you use anchor */
    $nextlink="page.php?row=".($getthisrow+1);
    prevlink="page.php?row=".($getthisrow-1);

     

    That won't work, the resource won't have any meaning next page.


    --

    //Aho
    J.O. Guest

  3. #3

    Default Re: Viewing records

    On 10 May, 05:18, Cyron <com> wrote: 

    Take a look at phpclasses.org, you'll find ready made classes for
    handling all of this.

    Captain Guest

Similar Threads

  1. Replies: 1
    Last Post: October 9th, 02:17 AM
  2. Viewing and Updating Mulktiple Records
    By DJ5MD in forum Coldfusion - Advanced Techniques
    Replies: 3
    Last Post: July 27th, 08:33 PM
  3. Replies: 1
    Last Post: October 14th, 01:32 PM
  4. Many form records to many table records
    By Anne in forum Microsoft Access
    Replies: 4
    Last Post: September 3rd, 02:12 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139