This is a discussion on Viewing records within the MySQL forums, part of the Database Server Software category; --> Hello friends, I have a mysql database which I am using in conjuction with PHP in hopes of allowing ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 wrote: > 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. This had fit a lot better at alt.php.sql. > I am running in to > difficulties accomplishing this. This is what i have tried: > > //PHP code > $sql = "select * from myTable" ; No point asking the SQL to fetch all data, we can limit it with LIMIT x,y > $result = mysql_query( $sql ) ; > $row = mysql_fetch_row($result) ; > $description = $row[ 0 ] ; /* 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); > 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 That won't work, the resource won't have any meaning next page. -- //Aho |
| ||||
| On 10 May, 05:18, Cyron <mdigit...@yahoo.com> wrote: > 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 Take a look at phpclasses.org, you'll find ready made classes for handling all of this. |