cmps 26 Light Poster

AAARGH!!! silly me :P

Scanner scan = new Scanner(System.in);
int numb = scan.nextInt();
int t = numb/100;
System.out.println("" + t);
numb -= (t*100);
t = numb/10;
System.out.println("" + t);
numb -= (t*10);
System.out.println("" + numb);

Yeahhhhhh mannnnnn u did it!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

HAHAHA Thank you bro
Regards

cmps 26 Light Poster

read it in as a String, using the
next() method
then:
print them using .charAt(0) .charAt(1) .charAt(2)

u r not allowed to use charAt() :\

cmps 26 Light Poster

PS: the number to enter will be 3 digits

cmps 26 Light Poster

PS: we should use, only

println()
print()
next()
nextLine()

you are not allowed to use variable.method()

cmps 26 Light Poster

I am trying to create an application that will:
1) ask the person to enter a number (ex: 321)
2) the application will display each number on a line
ex:3
2
1

Rules: Don't use looping and don't use arrays

Someone told me it could be done but I can't find it!!

What I've done:

Scanner scan = new Scanner(System.in);
int numb;
numb = scan.nextInt();

but what next ?

cmps 26 Light Poster

yup Solved

cmps 26 Light Poster

ardav Thank you ... I am using framework and I can see in approx all video tutorials they are using <?= ?> instead of <?php echo ?>, it makes me curious to know more about it!!

cmps 26 Light Poster

Hello, does all php versions accept the <?= ?> or no ??

Don't you think for designers <?= ?> is easier than <? echo ?>

Thank you

cmps 26 Light Poster

Hello, it's me with oop again,
So now I understand what are oop and how to use it,

but I have 2 questions:
[1] - How to use controllers models views libs
[2] - Is there any tutorial on how to create a cms using oop even if I should pay for it ...

Please recommend me videos books websites or whatever could teach me how to create a cms using oop, NOT USING CLASSIC PHP

Thank you

cmps 26 Light Poster

skraps yeah ur right =)
good luck for you and me ;)

cmps 26 Light Poster

No am ok, am I understood it, but with more tutorials for advanced steps I think i'll touch the pro ...
Good luck for all of you,
Best regards

cmps 26 Light Poster

Thank you all, I am now afraid of frameworks :P
mm so ... when I finish learning classes for 100% I'll take a look at Zend cuz @veedeoo talked about =).
My goal is to discover languages more and more and make huge projects, I just don't want to be hired now and stop learning new things ...
Btw in feb I'll start my first year of university Computer Science, Hope I'll learn all these and I don't want to learn c++ :( ahhhhhh

cmps 26 Light Poster

Thank you @skraps,
mm I don't want to use wordpress, cuz I think it's limited and dunno I just don't like to use it, in fact, I want to create a software or a customized cms but very advanced and I think doing this using classic php, will be very complicated with all variables and repetition etc... WordPress has his own "limited" cms ...
Now after I learned classes (still beginner in it), I decided to go into huge projects like a creating an online music store or photo gallery or video gallery etc ...
The problem is, am not able to create this with my own code using classes, so i am searching for help of an experienced who could tell me if framework (like phpcake) is a good way to learn how professionals works, or i will use it as a separate language like an idiot and learn nothing of it ...

Hope I have cleared my question Thank you

cmps 26 Light Poster

Hello,
I have created many websites using only classic php and functions
But now I decided to learn classes, I understood how it works but haven't used it yet.
I have phpcake tutorials, but don't know if it is good to learn it or it is not a good idea or it not for professionals ...

Please give me more idea about phpcake and if I should learn it, so I will understand more how we use classes in big projects and cms ?

Does professional programmers use a framework or code every thing by themselves ?

Thank you,

cmps 26 Light Poster

@cereal I didn't get my answer in these pagse ... sorry
But thank you anyway

cmps 26 Light Poster

I am using the pagination, but the question is even if i use pagination,
in the code there will be

mysql_query('select * from TABLE')

and

mysql_query('select * from TABLE LIMIT $a,$b')

because first I should count all data and than do a math trick !!

mmm ...

Thank you anyway =)

cmps 26 Light Poster

Hello,

I want to know if I am doing a list of students, which are executed from database (mysql),

does the number of data influence in the speed of the page load?

if yes:
What to do ?

And for how much data should I start to think for a solution ?

Thank you

cmps 26 Light Poster

Sorry but it doesn't work ...
Btw you cannot fetch 2 times

in your script your doing
fetch (fetch()) which is not correct ...

.........

I have done this using PDO:

$dbh = new PDO(etc..)

$query = $dbh -> query('select * from TABLE');
$result = $query -> fetch();

do{
echo 'a';
}while($result = $query -> fetch())

And it work correctly!!

but am searching to do this by myself ...
is there any way to check what the PDO class is made by ??

cmps 26 Light Poster

Sorry, I made this mistake, but it's not working :S

I tried also

do
{
	echo 'a';
}while($result = $dbh -> fetch());

Can't understand why it's not working !!

cmps 26 Light Poster
class db
{
	private $connection;
	private $preapre;
	public $query;
	public $result;
	
	public function __construct()
	{
		$this -> connection = mysql_pconnect('localhost','root','') or die(mysql_error());
		mysql_select_db('oop',$this -> connection) or die(mysql_error());
	}
	
	public function prepare($prepare)
	{
		mysql_query($prepare,$this -> connection);
	}
	
	public function query($query)
	{
		$this -> query = $query;
		return mysql_query($query,$this->connection);
	}
	
	public function fetch()
	{
		$this -> result = mysql_fetch_assoc($this -> query($this -> query));
		return $this -> result;
	}
	
}

$dbh = new db;
$dbh -> query("select * from player");
$result = $dbh -> fetch();
do
{
	echo 'a';
}while($db -> result = mysql_fetch_assoc($db -> query($db -> query)))
cmps 26 Light Poster

Usually the procedural way:

$r = mysql_query(...sql...);
while($data=mysql_fetch_array($r)){
  //do something with the data
}

This won't change anything ...
I want it using the class

cmps 26 Light Poster

Hello,

I want to display all data from database (repeat) and not only the last one:
In classic php I do this using:

...

$row_record = mysql_fetch_assoc($record);

do
{
   echo 'Record <br />';
}while($row_record = mysql_fetch_assoc($record))

In advanced php (using class)

I decided to create my own way, so here I arrived:

//class db

...

public function fetch()
	{
		$this -> result = mysql_fetch_assoc($this -> query($this -> query));
		return $this -> result;
	}
//end class

$dbh = new db;
$dbh -> query("select * from player");
$result = $dbh -> fetch();
do
{
	echo 'a';
}while($result = $dbh -> fetch())

I have created the same concept as the classic php way but it's not working ...
if I print_r($result), It will gives me an array of the data (so it work in single mode)...

Can anyone gives me an idea =) thank you

cmps 26 Light Poster

mm yeah i am actually finding some problem understanding, I think because of the course narrator, He's not a good teacher!!
Anw I will try to create my own class =) Thanks

cmps 26 Light Poster

Hello,

Am not new to PHP but new to OOP, I have watched lot of tutorials for oop and as I saw, class is almost a new language!!
To be a pro programmer, I should learn existing class attributes or I should create my own??

example of default class attribute:
$dbh = new PDO("mysql:host=localhost;dbname=test","root","");
$sth = $dbh -> query("select * from page");
$result = $sth -> fetch();

example of my own classic class:
class db{
function connect(){
mysql_pconnect('localhost','root','');
}

function etc...

}

cmps 26 Light Poster

@arctushar
I had the same problem understanding function and class, and how do they differ ...
Ok now I have 90% understood what does the class exactly offer us!

Function example:

function CommentHtmlentites($comment)
{
   1)make the comment htmlentities
   2)echo the comment
}

fcuntion CommentNl2br($comment)
{
   1)make the comment nl2br
   2)echo the comment
}

Class example:

class Comment
{
   function MakeCommentHtmlentites($commentHere)
   {
      1) Make the comment htmlentites
   }

   function MakeCommentNl2br($commentHere)
   {
      2) Make the comment nl2br
   }

   function EchoComment()
   {
      3) echo the comment
   }
}

Ok now after doing these two example, let's display the comment:

First Using Function

CommentHtmlentites('This is a Comment With Htmlenties');
CommentNl2br('This is a Comment With Nl2br');

Second Using Class

$Comment = new Comment();
$Comment -> MakeCommentHtmlentites('This make the comment Htmlenties');
$Comment -> MlaeCommentNl2br('This make the comment Nl2br');
$Comment -> EchoComment(); // This will echo the comment After Htmlenties and Nl2br

So In Conclusion, Class gives the chance to choose between Htmlentities or Nl2br or both,
But in functions you only can echo comment with Htmlenties or Nl2br
To echo comment in function example with Htmlenties and Nl2br, you must have to create another function with both Nl2br and Htmlenties

Hope this Helps !! And remember this is a small example!! When you will create a big software, you will feel the difference
BR

arctushar commented: I like this comment. this more helpful +0