Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Chris

Pages: [1] 2
1
Beginners - Learning PHP / Re: Is Precedural Enough?
« on: July 22, 2012, 08:49:14 PM »
Thank you so much for the very insightful response, Andrew.

2
Hello Tanoloo1,

I just saw your site and I think it looks nice. This is a question rather than a reply.

I'm new to programming myself (very new , actually) and was wondering how you applied the month-calendar that appears on arrival and departure date box? Is it some sort of plug-in.

Thanks,
Chris


3
Beginners - Learning PHP / Re: Is Precedural Enough?
« on: July 18, 2012, 10:13:59 AM »
Thanks, RaythXC.

4
Beginners - Learning PHP / Re: Understanding "Formula" Code
« on: July 11, 2012, 12:34:38 AM »
Thanks, Wilson382.

I was wondering about that modulus.

Your explanation makes perfect sense.

Chris

5
Beginners - Learning PHP / Is Precedural Enough?
« on: July 11, 2012, 12:28:10 AM »
A Note to Moderators: If you feel that my question below does not belong in this section, please let me know where it should be posted.

Thanks,
Chirs



Hello,

Without any programming experience whatsoever, I started studying PHP beginning in the second quarter of this year with the goal of slowly building my dream website starting later this summer.

Just as I was wrapping my head around PHP and beginning--I felt-- to truly understand the different concepts and how the code works (this is why I prefaced my post with my non-experience--I've really had to bang and cram it all in my head), I come across Object Oriented PHP.

I've taken the approach of of mastering (trying, as much as possible, at least) as many of the concepts and ideas before diving in to try and create my own scripts; much like learning how to dribble, throw a baseball or football well, before playing a single game. (of course I've played around with and done some code -drills).

My question to the experts is this: Should or must I learn and delve deep
into OOPHP, thus delaying my "start-to-code" date? Or will procedural PHP Programming suffice if one would like to build good E-commerce, forum/comment-type (like PHP Help) or basic social networking websites?

How far will procedural programming take me? A site with 1,000; tens-of-thousands; hundred thousand visitors?

Your expert opinion and insight and input is greatly appreciated.

Chris

6
Beginners - Learning PHP / Understanding "Formula" Code
« on: July 10, 2012, 10:35:43 AM »
Hello,

Came across this piece of code for a Factorial "formula" and can't seem to get it:

PHP Code: [Select]
<html>
    <
head>
        <
title>Factorial Test</title>
    </
head>
    <
body>
        <?
php
            $var 
rand 10;
            
            
$counter $var;
            
            
$echo_var $var;
            
            while (
$counter 1) {
                
$var $var * ($counter 1);
                
                
$counter--;
            }
            
            echo 
"The Factorial of $echo_var is: $var";
        
?>
    </body>
</html>


Could an expert kindly explain how the code works (step by step, if possible).

Thanks in advance.
Chris

7
Beginners - Learning PHP / Re: Empty array
« on: July 10, 2012, 10:32:59 AM »
Thanks for expounding, ErnieAlex.

8
Beginners - Learning PHP / Re: Empty array
« on: July 09, 2012, 08:53:00 PM »
Thanks again for the wonderfully clear explanation, OpzMaster. Greatly appreciated.

Chris.

9
Beginners - Learning PHP / Re: Empty array
« on: July 08, 2012, 12:57:45 PM »
Thanks so much for the thorough explanation, OpzMaster.

I have just one other question: In your last paragraph, specifically about my example ($_SESSION['cart'][1] = 10), since the script assigned a value for the second key, what becomes of the first key (0)? Will php not start with--or "search" for--ZERO (the first key) first? For that matter, why didn't the script writer start with zero.

I hope I'm understanding it correctly and that my question makes sense.

Thanks again.

10
Beginners - Learning PHP / Empty array
« on: July 06, 2012, 06:54:54 PM »
Hello,

Need some help understanding array().

I'm confused about an empty array. How does it work?

I found this example (about shopping carts):

PHP Code: [Select]
$_SESSION['cart'] = array();
$_SESSION['cart'][1] = 10;
$_SESSION['cart'][6] = 5;


Again, what does the array() mean? Aren't you supposed to put  values in arrays?

Thanks in advance.

11
Beginners - Learning PHP / $row[0]
« on: May 24, 2012, 06:56:14 PM »
Hello,

I know this may sound like a stupid question, but I just want to make sure I understand correctly.

After a query, what does $row[0] stand for/ result in?

Is my understanding correct that $row[0] shows ALL results?

HERE ARE EXAMPLES:

PHP Code: [Select]
$query "SELECT count(commentid) from comments where jokeid = $jokeid";

$result mysql_query($query);

$row=mysql_fetch_array($result);

if (
$row[0] == 0)

{

   echo 
"No comments posted yet.&nbsp;&nbsp;\n";

  

} else

{

   echo 
$row[0] . "\n";
   echo 
"&nbsp;comments posted.&nbsp;&nbsp;\n";



AND THIS ONE

PHP Code: [Select]
$query "Select count(prodid) from products where catid = $catid";
      
$result mysql_query($query);
      
$row mysql_fetch_array($result);
      if (
$row[0] == 0)
      {
         echo 
"<h2><br>Sorry, there are no products in this category</h2>\n";
      }
      else
      {
         
$totrecords $row[0];


Thanks in advance,
Chris

12
Beginners - Learning PHP / ob_?
« on: May 18, 2012, 02:17:05 PM »
Hello,

I'm on my seventh week of learning PHP (no previous coding experience) and came upon this code:

PHP Code: [Select]
         //create thumbnail
         
$width imageSX($SourceImage);
         
$height imageSY($SourceImage);
         
$newThumb imagecreatetruecolor(8060);
         
//resize image to 80 x 60
         
$result imagecopyresampled($newThumb$SourceImage
                                      
0000,
                                      
8060$width$height);
         
//move image to variable
         
ob_start();
         
imageJPEG($newThumb);
         
$thumbnail ob_get_contents();
         
ob_end_clean();



QUESTION:
What exactly is ob_start() in plain english; along with it ob_get_contents() and ob_end_clean()? --In general and what it does for the specific code example above (I get the manipulating image part of the code).
How does buffering work?

Thanks in advance,
Chris

13
Beginners - Learning PHP / Forms Processing--PHP/HTML
« on: May 02, 2012, 05:57:55 PM »
Hello,

I'm learning and trying to understand how html forms and php processing works.

Came across this pair of examples:

HTML FORM:
PHP Code: [Select]
<html>
<
body>

  <
form action="hello-web.php" method="GET">
  <
label>Name:</label>
  <
input type="text" name="yourName" size="24">
  <
input type="submit">
  </
form>

</
body>
</
html>



PHP PROCESSOR:
PHP Code: [Select]
?php
$fname 
$_GET["yourName"];

echo 
"Hello $fname!";
?>


OUTPUT SHOULD BE:
Hello Entered/Example Name!


QUESTIONS:
When I play around with the code and try to change the variable "yourName" (on BOTH HTML and PHP files) to, for example "typeName" , the entered name on the form does not show up/ not processed.

In other words, the output becomes just: Hello  !

Is yourName a standard php or html variable? Can it not be changed to what ever you want it to be?

Better yet, how exactly does the form process data?

Thanks in advance,
Chris

14
Beginners - Learning PHP / Re: Back Slashes
« on: April 18, 2012, 03:57:43 PM »
I hadn't logged back in till now (busy with work) but thank you, Sarthak Patel and richei!
Chris

15
Beginners - Learning PHP / Back Slashes
« on: April 12, 2012, 05:03:52 PM »
Hello,

Still learning PHP and came across these examples:

PHP Code: [Select]
echo "<a href=\"index.php?content=register\">Try again</a><br>;

echo "
<a href=\"index.php\">Return to Home</a>;


AND

PHP Code: [Select]
echo "<input name=\"goButton\" type=\"submit\" value=\"browse\" />;
echo "
<input name=\"content\" type=\"hidden\" value=\"edit\" />;


My question is: What purpose or function do all the back slashes serve?
Can't it be just :
PHP Code: [Select]
echo "<input name="goButton" type="submit" value="browse"
 --without all the backslashes?

Thanks in advance.
-Chris


Pages: [1] 2