PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
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  
Old July 24th, 2002, 07:43 PM
bedcor bedcor is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Ontario, Canada
Posts: 6 bedcor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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";

?>

Reply With Quote
  #2  
Old July 24th, 2002, 08:00 PM
CmdrDats CmdrDats is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: <br><img src='http://www.dats.co.za/icon.gif'>
Posts: 269 CmdrDats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to CmdrDats Send a message via AIM to CmdrDats Send a message via Yahoo to CmdrDats
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?

Reply With Quote
  #3  
Old July 24th, 2002, 08:13 PM
bedcor bedcor is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Ontario, Canada
Posts: 6 bedcor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #4  
Old July 24th, 2002, 08:31 PM
CmdrDats CmdrDats is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: <br><img src='http://www.dats.co.za/icon.gif'>
Posts: 269 CmdrDats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to CmdrDats Send a message via AIM to CmdrDats Send a message via Yahoo to CmdrDats
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...

Reply With Quote
  #5  
Old July 24th, 2002, 08:37 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
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?

Reply With Quote
  #6  
Old July 24th, 2002, 08:43 PM
CmdrDats CmdrDats is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: <br><img src='http://www.dats.co.za/icon.gif'>
Posts: 269 CmdrDats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to CmdrDats Send a message via AIM to CmdrDats Send a message via Yahoo to CmdrDats
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? ]

Reply With Quote
  #7  
Old July 24th, 2002, 09:24 PM
bedcor bedcor is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Ontario, Canada
Posts: 6 bedcor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?


Reply With Quote
  #8  
Old July 24th, 2002, 09:27 PM
CmdrDats CmdrDats is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: <br><img src='http://www.dats.co.za/icon.gif'>
Posts: 269 CmdrDats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to CmdrDats Send a message via AIM to CmdrDats Send a message via Yahoo to CmdrDats
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);

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Next doesn't grab next record?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway