Php expert visit here

Started on the old forum in October 2011 · view the original in the archive · old links redirect here

1 reply · 338 views · started 15 years ago · 1 min read

2 participants
jaidon20k Developer · 64 posts #1

id name 1 john 2 joe 3 san 4 jesus 5 mark 6 nike 7 sam 8 love i am show two rows per page Now jesus as fall on 2nd page because i order by id ASC, jesus id is 4.

MY QUESTION: i want to tell people the Jesus is on the 2nd page or the directory.

Thanks

something else Fellow · 2,296 posts #2
$jid = mysql_fetch_array(mysql_query("SELECT id FROM table WHERE name='jesus'"));
echo 'Jesus is on page '.ceil($jid[0]/2);

if you know there is going to be some rows deleted from your database..... eg: say joe and san was deleted then you would need to do something like this:

$jid = mysql_fetch_array(mysql_query("SELECT id FROM table WHERE name='jesus'"));
$nor = mysql_num_rows(mysql_query("SELECT * FROM table WHERE id<'".$jid[0]."'"));
echo 'Jesus is on page '.ceil($nor/2);

or you could use something like this:

$nor = mysql_num_rows(mysql_query("SELECT * FROM table WHERE name BETWEEN '' AND 'jesus'"));
echo 'Jesus is on page '.ceil($nor/2);

but you would have to go a little careful with it as BETWEEN will include the result jesus on some databases and not on others. if it doesnt include it you would need to add 1 to $nor

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close