|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Next doesn't grab next record?
Ok, my code works to the point that i get the first record from the database, but when i press next it doesn't show the next record?
[highlight=php] <?php $start = isset($start) && is_numeric($start) ? $start : 0; $query = "SELECT * FROM users LIMIT " . $start . ", 1"; $db = mysql_connect("******", "*********"); mysql_select_db("ijwHotel"); $result = mysql_query($query); $row=mysql_fetch_array($result); $real_name=$row [ 'real_name' ]; $username=$row [ 'username' ]; $email=$row [ 'email' ]; $query = "SELECT count(*) as count FROM users"; $result = mysql_query($query); $row = mysql_fetch_array($result); $numrows = $row['count']; echo "<form action=$PHP_SELF method=GET>"; echo "Real Name:<input type=text name=real_name value=$real_name><br>"; echo "Username:<input type=text name=username value=$username><br>"; echo "Email:<input type=text name=email value=$email><br><br>"; if($start > 0) echo "<a href="" . $PHP_SELF . "?start=" . ($start - 1) . "">Previous</a><BR>n"; if($numrows > ($start + 1)) echo "<a href="" . $PHP_SELF . "?start=" . ($start + 1) . "">Next</a><BR>n"; ?> |
|
#2
|
|||
|
|||
|
RE: Next doesn't grab next record?
It seems to get it from the database just fine...
add a print_r($row); just under line 13 ($email=$row [ 'email' ];) and see if that gives you the results? |
|
#3
|
|||
|
|||
|
RE: Next doesn't grab next record?
when i run that print_r($row) this is what i get?
Array ( [0] => 1 [uid] => 1 [1] => Cory Bedard [real_name] => Cory Bedard [2] => bedcor [username] => bedcor [3] => faith [password] => faith [4] => cory@ijws.com [email] => cory@ijws.com ) it just shows the first record twice and there are 3 more records in the database? |
|
#4
|
|||
|
|||
|
RE: Next doesn't grab next record?
ah, hang on, try printing $start in the beginning of the script.
My bet is that register_globals is set to off, so you need to to go $start = $_GET["start"] or $start = $_HTTP_GET_VARS["start"] in the beginning of the code... |
|
#5
|
|||
|
|||
|
RE: Next doesn't grab next record?
sorry, but that doesn't work either? can't understand why it doesn't go past the first record?
|
|
#6
|
|||
|
|||
|
RE: Next doesn't grab next record?
is_numeric -- Finds whether a variable is a number or a numeric string
from the manual, so it doesn't mind if it's a string, it sees if it can convert it.. point is. it worked on mine.. what happened when you print($start) in the beginning of the script (just before the query, ie. line 4))? [Edit: eh? did you delete your post nemesis, or am i just going crazy? |
|
#7
|
|||
|
|||
|
RE: Next doesn't grab next record?
Sorry, my fault it works!
I didn't try start = $_GET['start']; but now when i run the program i get an error message: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:apacheapachehtdocsuserview.php on line 11 and i'll just show you the top of the code: $start = $_GET ['start']; $query = "SELECT * FROM users LIMIT " . $start . ", 5"; $db = mysql_connect("localhost", "root"); mysql_select_db("ijwHotel"); $result = mysql_query($query); $row = mysql_fetch_array($result); $uid=$row['uid']; $real_name=$row ['real_name']; $username=$row ['username']; $email=$row ['email']; $query = "SELECT count(*) as count FROM users"; $result = mysql_query($query); $row = mysql_fetch_array($result); $numrows = $row['count']; why does it not like it? |
|
#8
|
|||
|
|||
|
RE: Next doesn't grab next record?
modify the line
$start=$_GET["start"] to $start=$_GET["start"] ? $_GET["start"] : 0; --- if it still doesn't work, insert "print(mysql_error());" right after $result = mysql_query($query); |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Next doesn't grab next record? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|