TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-09-2009, 03:14 AM   #21 (permalink)
The Contributor
 
WebSavvy's Avatar
 
Join Date: Mar 2009
Location: Springfield, IL USA
Posts: 75
Thanks: 3
WebSavvy is on a distinguished road
Default

Hey ... I am soooo happy you were able to get it sorted! That's just super

Yep, I'm a tad busy tonight. But I'm making good progress. I just wish I had more hands, more fingers, and better eyesight. LOL.
WebSavvy is offline  
Reply With Quote
Old 04-09-2009, 03:18 AM   #22 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Quote:
Originally Posted by WebSavvy View Post
Hey ... I am soooo happy you were able to get it sorted! That's just super

Yep, I'm a tad busy tonight. But I'm making good progress. I just wish I had more hands, more fingers, and better eyesight. LOL.
I hear ya....but you're "savvy", I know you'll get things done.

I won't bother you anymore tonite then, I'm heading out anyways as soon as i finish checking out my apache logs...

Have a good one and thanks again!
allworknoplay is offline  
Reply With Quote
Old 04-09-2009, 03:23 AM   #23 (permalink)
The Contributor
 
WebSavvy's Avatar
 
Join Date: Mar 2009
Location: Springfield, IL USA
Posts: 75
Thanks: 3
WebSavvy is on a distinguished road
Default

Ah, you were no bother. I don't mind helping people, ever. Have a good time. I'll be ready to call it a night shortly. Then it'll be return to the slog in the morning.
WebSavvy is offline  
Reply With Quote
Old 04-09-2009, 09:12 AM   #24 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Just a question; Why would you want a pagination script that is limited to MySQL results? Or even limited to database? Sometimes you want to paginate other things than results from a database.

Try to make it paginate data independent if it's result from a database, images from a folder, or just simply; An array of data.
__________________
Tanax is offline  
Reply With Quote
Old 04-09-2009, 02:13 PM   #25 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Quote:
Originally Posted by Tanax View Post
Just a question; Why would you want a pagination script that is limited to MySQL results? Or even limited to database? Sometimes you want to paginate other things than results from a database.

Try to make it paginate data independent if it's result from a database, images from a folder, or just simply; An array of data.
Well, when we start to turn this into a class, I was thinking of having the SQL results be separate, so in theory you would be able to feed it anything I suppose. I guess it should be DB independant, but I personally haven't ran into any situations where I need pagination that doesn't deal with mySQL, so the thought never really occurred to me...
allworknoplay is offline  
Reply With Quote
Old 04-09-2009, 03:38 PM   #26 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quote:
Originally Posted by allworknoplay View Post
Well, when we start to turn this into a class, I was thinking of having the SQL results be separate, so in theory you would be able to feed it anything I suppose. I guess it should be DB independant, but I personally haven't ran into any situations where I need pagination that doesn't deal with mySQL, so the thought never really occurred to me...
I personally haven't used everything I know of PHP, that doesn't mean that it's a waste to learn it

Check this, might give you some inspiration
Pagination class
__________________
Tanax is offline  
Reply With Quote
Old 04-09-2009, 03:45 PM   #27 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Quote:
Originally Posted by Tanax View Post
I personally haven't used everything I know of PHP, that doesn't mean that it's a waste to learn it

Check this, might give you some inspiration
Pagination class
Thanks I will check it out. I found a quick typo in your post.

You said, "Also, this *should* work without MySQL, eventhough my example is based on MySQL"

So one of them I assume should be MS SQL...

allworknoplay is offline  
Reply With Quote
Old 04-09-2009, 03:58 PM   #28 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quote:
Originally Posted by allworknoplay View Post
Thanks I will check it out. I found a quick typo in your post.

You said, "Also, this *should* work without MySQL, eventhough my example is based on MySQL"

So one of them I assume should be MS SQL...

I didn't understand that xD
My example is based on MySQL and not MS SQL, but you can use the pagination class for MS SQL, MySQLi, Oracle, images in a folder(whihch salathe posted an example of as a reply post), etc. Just about any array of data it will paginate

But probably I misunderstood what you meant with your post xD
__________________
Tanax is offline  
Reply With Quote
Old 04-09-2009, 08:19 PM   #29 (permalink)
The Contributor
 
WebSavvy's Avatar
 
Join Date: Mar 2009
Location: Springfield, IL USA
Posts: 75
Thanks: 3
WebSavvy is on a distinguished road
Default

Quote:
Originally Posted by Tanax View Post
Just a question; Why would you want a pagination script that is limited to MySQL results? Or even limited to database? Sometimes you want to paginate other things than results from a database.
By the same token, why would I want a pagination script that's doing more things than what I need?

I don't use anything other than MySQL and the only things I require to be paginated are results from a database. My usage is in my directory script and it works perfectly fine for me. I have no desire to change what isn't broken.

However, I can see examples of some instances where someone would require pagination that isn't database dependent. So, it basically comes down to this: People will use what fits their needs and suits their purposes.
WebSavvy is offline  
Reply With Quote
Old 04-09-2009, 08:33 PM   #30 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Quote:
Originally Posted by Tanax View Post
I didn't understand that xD
My example is based on MySQL and not MS SQL, but you can use the pagination class for MS SQL, MySQLi, Oracle, images in a folder(whihch salathe posted an example of as a reply post), etc. Just about any array of data it will paginate

But probably I misunderstood what you meant with your post xD
It's the way I read what you wrote. After reading it I can see what you mean, but I will explain what I thought you meant anyways since I like to talk a lot...

When you said, "this should work in mySQL, eventhough your example is based on mySQL"

When you read it fast it looks like you meant to say that one of them is MS SQL like this:

"this should work in mySQL, eventhough my example is based on MS SQL"...

The way it's worded, sounds like it's designed to work with one DB and SHOULD work in another DB, eventhough it was designed with a different DB...see what I mean?
allworknoplay is offline  
Reply With Quote
Old 04-09-2009, 08:36 PM   #31 (permalink)
The Frequenter
Zend Certified 
 
Join Date: Sep 2007
Location: Denmark
Posts: 352
Thanks: 8
Kalle is on a distinguished road
Default

Hmm your code is sort of weird in the manner that you say:
<?php print_r("$variable"); ?>

and later you use:
<?= $variable; ?>

Also, why use string interpolation when you don't concate the data with something else? Seems pretty pointless to waste time on something so simple.


ps. I see you use notation on the $strSQL = mysql_query(...);, well technically that is a resource returned and not a string, but heeeey :)
__________________
Send a message via MSN to Kalle Send a message via Skype™ to Kalle
Kalle is offline  
Reply With Quote
Old 04-09-2009, 08:43 PM   #32 (permalink)
The Contributor
 
WebSavvy's Avatar
 
Join Date: Mar 2009
Location: Springfield, IL USA
Posts: 75
Thanks: 3
WebSavvy is on a distinguished road
Default

Quote:
Hmm your code is sort of weird in the manner that you say:
<?php print_r("$variable"); ?>

and later you use:
<?= $variable; ?>
I use print_r("$variable") when I'm coding. The <?=$variable;?> was added just as an example for something to place there for allworknoplay to get an idea. I did this quickly yesterday as I was busy with other work, which I mentioned already.

Quote:
Also, why use string interpolation when you don't concate the data with something else? Seems pretty pointless to waste time on something so simple.


ps. I see you use notation on the $strSQL = mysql_query(...);, well technically that is a resource returned and not a string, but heeeey :)
I code things in a way that's easy for the screen reader to read it back to me so I can understand it. If you've ever used a screen reader in your life you'd know where I'm coming from with that regard.
WebSavvy is offline  
Reply With Quote
Old 04-10-2009, 09:44 AM   #33 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quote:
Originally Posted by WebSavvy View Post
By the same token, why would I want a pagination script that's doing more things than what I need?

I don't use anything other than MySQL and the only things I require to be paginated are results from a database. My usage is in my directory script and it works perfectly fine for me. I have no desire to change what isn't broken.

However, I can see examples of some instances where someone would require pagination that isn't database dependent. So, it basically comes down to this: People will use what fits their needs and suits their purposes.
It's not doing more things than what you need. It's doing exactlyy what you need. It just CAN do other things aswell.

I don't use anything other than MySQL aswell, which is why my example usage of the pagination class was based on MySQL - heck, I didn't even know how to use the class without MySQL. But my point still stands. Why use something that is limited to one thing, instead of using a more "allround" solution. It will work with your database. It will work later when you do use results from another source, for example an image folder on your host.

It's like.. buying a stereo, and there are 2 types of stereos, one that supports only CD, and then another that supports CD and DVD. They're the same price. You only use CD, so you buy the one that only supports CD, but then later, you wanna use DVD cause everything moves over from CD to DVD, then you'd need to buy another one. In this case you would need to recode your whole script just so it can support pagination for data other than results from a database.

Quote:
Originally Posted by allworknoplay View Post
It's the way I read what you wrote. After reading it I can see what you mean, but I will explain what I thought you meant anyways since I like to talk a lot...

When you said, "this should work in mySQL, eventhough your example is based on mySQL"

When you read it fast it looks like you meant to say that one of them is MS SQL like this:

"this should work in mySQL, eventhough my example is based on MS SQL"...

The way it's worded, sounds like it's designed to work with one DB and SHOULD work in another DB, eventhough it was designed with a different DB...see what I mean?
OOoh, I see. No no, I meant exactly what I wrote: This should work without MySQL(with any array of data), even if I used MySQL in my example xD ^_^
__________________
Tanax is offline  
Reply With Quote
The Following User Says Thank You to Tanax For This Useful Post:
WebSavvy (04-11-2009)
Old 04-10-2009, 11:37 AM   #34 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Quote:
Originally Posted by Tanax View Post
OOoh, I see. No no, I meant exactly what I wrote: This should work without MySQL(with any array of data), even if I used MySQL in my example xD ^_^
I was just reviewing your code, is this just a quick form for the if conditional?

(isset($p)) ? $p : 1;

Basically it's just saying, if $p is set, then take that value of $p, if it's not set, then set it to 1.

I had no idea you can do an "if" conditional without the actual call to an "if"...
allworknoplay is offline  
Reply With Quote
Old 04-10-2009, 11:57 AM   #35 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Yes, that's an if condition, btw, post in that thread if you have any more questions about that code since it's quite offtopic here.

And that class is quite old, it's not the best. But it definitely get the job done(I've recoded it on localhost so I got a better version though).

Every day we learn something new
__________________
Tanax is offline  
Reply With Quote
Old 04-11-2009, 12:27 AM   #36 (permalink)
The Contributor
 
WebSavvy's Avatar
 
Join Date: Mar 2009
Location: Springfield, IL USA
Posts: 75
Thanks: 3
WebSavvy is on a distinguished road
Default

Quote:
Originally Posted by Tanax View Post
It's not doing more things than what you need. It's doing exactlyy what you need. It just CAN do other things aswell.

I don't use anything other than MySQL aswell, which is why my example usage of the pagination class was based on MySQL - heck, I didn't even know how to use the class without MySQL. But my point still stands. Why use something that is limited to one thing, instead of using a more "allround" solution. It will work with your database. It will work later when you do use results from another source, for example an image folder on your host.

It's like.. buying a stereo, and there are 2 types of stereos, one that supports only CD, and then another that supports CD and DVD. They're the same price. You only use CD, so you buy the one that only supports CD, but then later, you wanna use DVD cause everything moves over from CD to DVD, then you'd need to buy another one. In this case you would need to recode your whole script just so it can support pagination for data other than results from a database.
Ahhh, I now see what you mean. Thank you for taking the time to explain things more clearly.

The code that I've written above is very old. In fact, I was very new to php at the time when I coded it -- only about 2 months into it.

I just have never gone back to recode it to where it's more up to date. I probably should take the time to do it though, but it'll have to wait until I'm finished with the 11,000 url entries I'm working on in my db at the moment.

I'll look into using your class as an example sometime next week perhaps. If I run into anything I'm not sure about I'll ask in that thread.
WebSavvy is offline  
Reply With Quote
Old 06-06-2009, 11:54 AM   #37 (permalink)
The Visitor
 
lema's Avatar
 
Join Date: Jun 2009
Posts: 2
Thanks: 0
lema is on a distinguished road
Default

Hi is anyone helpe me wait this sql table

CREATE TABLE video (
id tinyint(4) NOT NULL auto_increment,
singer_name text NOT NULL,
category text NOT NULL,
song_name text NOT NULL,
video_url text NOT NULL,
img_url text NOT NULL,
dis text NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;

the result code is

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<div align="left">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="1%">&nbsp;</td>
<td width="99%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td height="395" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="11%"><?php
include ("config.php");
mysql_connect($db_host,$db_user,$db_pass) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());

$result = mysql_query("SELECT * FROM video order by id desc LIMIT 3");
while($r=mysql_fetch_array($result))
{
$singer_name=$r["singer_name"];
$song_name=$r["song_name"];
$dis=$r["dis"];
$id=$r["id"];
$img_url=$r["img"];
?></td>
<td width="89%">&nbsp;</td>
</tr>
<tr>
<td height="96" align="center" valign="top"><? echo "<img border='0' src="; if ($img_url=="") { echo 'images/nopic.gif'; } else { echo "$img"; } echo" width='80' height='70'>"; ?></td>
<td><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="26" valign="middle"><?=$Singer_name?></td>
</tr>
<tr>
<td height="21"><?=$song_name_name?></td>
</tr>
<tr>
<td height="21"><?=$dis?></td>
</tr>
<tr>
<td height="21"><a href="viewvideo.php?id=<?=$id?>">Click Here To Watch
<?=$video?>
Video </a></td>
</tr>
</table></td>
</tr>
<tr>
<td height="14" align="left" valign="top">&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<? } ?>
<?php mysql_close(); ?></td>
</tr>
</table></td>
</tr>
</table>
</div>
</body>
</html>

but it show only limit
how does it work wait pagination 10 row per page ?

Last edited by lema : 06-06-2009 at 06:10 PM.
lema is offline  
Reply With Quote
Old 06-06-2009, 02:04 PM   #38 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Welcome Lema! Why did you bury your post in a random thread? Don't be afraid to create a new thread!

Do you want pagination then for this? As in, page 1, page 2, page 3, etcetera.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 06-06-2009, 06:14 PM   #39 (permalink)
The Visitor
 
lema's Avatar
 
Join Date: Jun 2009
Posts: 2
Thanks: 0
lema is on a distinguished road
Default Thanx Wildhoney

can you please helpe me how to use pagination in complate code resuld from my sql table thanx .
lema is offline  
Reply With Quote
Old 12-22-2011, 09:48 AM   #40 (permalink)
The Visitor
 
Join Date: Dec 2011
Posts: 2
Thanks: 0
krishnacoolsoft is on a distinguished road
Smile thanks

hey script very simple nice thanq dude
krishnacoolsoft is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help on PHP MYSQL Forms Input deesudesu Absolute Beginners 1 03-20-2009 10:50 AM
Basic php form update mysql script dp2 Absolute Beginners 3 03-11-2009 04:06 PM
Nginx Rewrite Causing Wrong Path for PHP Script stewart General 0 11-09-2008 12:32 AM
Securing your MySQL Queries with Sprintf Wildhoney General 26 03-18-2008 06:52 PM
Error in connecting to MySQL via PHP EyeDentify MySQL & Databases 0 01-03-2008 01:06 PM


All times are GMT. The time now is 06:14 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design