You are here: Re: Display X Items per page with sort option? « PHP Programming Language « IT news, forums, messages
Re: Display X Items per page with sort option?

Posted by muldoonaz on 09/09/05 01:19

yellow1912 wrote:
> Big thanks guys!
> But what if the field must be string, and I cant really control what
> user input?
> They can input Item 1, or Item 01, .... There's no way ?
>
you can control what you put in the db though. There's a php function
that'll float the number to any given number of leading 0's.

I wrote some code that helps me move things around in my knowledge base
when incidents or articles are added.

$code = "FF00512"; // KB code, pulled from the end of the table
$prefix = substr($code,0,2); // output: "FF"
$suffix = substr($code,2,5)+1; // "00512" + 1, output: "513"
$suffix = sprintf("%05d", $suffix); // output: "00513"
$solutionid = $prefix.$suffix; // combine the prefix and the suffix

echo $solutionid; // output: "FF00513"

you could change the %05d to %03d, it'll make sure the integer is 3
numbers long and add leading zero's until it matches that. %05d will be
5 numbers, %07d 7 numbers and so on...

im sure there are easier ways to do this, but this was my solution.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация