Jump to content


gizmola

Member Since 06 May 2003
Offline Last Active Yesterday, 05:33 PM

Posts I've Made

In Topic: Accessing Values with in a Simple Multidimensional Array?

02 May 2015 - 09:25 PM

Following up on Requinix's answer, print_r exists so you can just quick dump out an array or object. So you wouldn't print_r a single element.

His answer shows you how you can reference elements in multiple nested arrays.

In Topic: Newbie Help.

02 May 2015 - 09:19 PM

When people don't provide code, we can only call out things that sound hinkey.
 
Regardless, you are complicating something that is simple.
 
You display images in a browser using the img tag.
 
Whether you stored one image file or many in a specific row, that is not going to change the fact that each individual image you want to display on a web page has to be available in the src= param of the the img tag.
 
With that said, as ginerjm advised, it's a lot easier to write an img helper script if you have a solid table structure with one image per row referenced.  Then you tend to write something like:
 
// getimg.php
 
$id = (int)$_GET['id];
$sql = "SELECT * FROM images WHERE id = $id";
 
//query for image row
 
if ($found) {

  $fp = fopen($row['filepath'], 'rb');
  //Determine right header -- jpeg example here
  // ....
  $imgMimeType = 'image/jpeg';
  header('Content-Type: ' . $imgMimeType);
  header("Content-Length: " . filesize($row['filepath']));

  fpassthru($fp);
  exit;
   
} else {
  //return data for default img.  Remember this is returning image data, so you have to return a valid image.
}
Then of course where you want to display the images you will have markup like this in your output script:


echo '<img src="getimg.php?id=' . $images_id  . '">';

In Topic: Why am I not able to really learn any CMS?

02 May 2015 - 08:36 PM

There are basically 2 modern php5+ frameworks right now that have most of the mindshare.

 

Symfony -> http://symfony.com

 

Laravel -> http://laravel.com

 

Both of these frameworks have a lot of similarities, excellent documentation, tutorials, and highly active communities that support people.

 

My suggestion to you would be to take a look at both of them and try building a small test app with them to see how they can help you.

 

I don't want to put the cart before the horse, but they also both have CMS components available, but before you get in over your head, I'd urge you to try and build a basic app first so you're clear on the basics like routing, db/orm/models, views/templates, session/security etc.  You'll find state of the art support for search solutions any number of different ways.


In Topic: Interfaces

02 May 2015 - 08:27 PM

An interface is typically used by framework and library creators.

 

It facilitates certain types of design patterns, for example the factory pattern or for use in dependency injection situations.   What an interface guarantees is that *your* class will be sure to include some number of methods that another class can call.

 

For example, let's say that I have a "shapeMaker" class that instantiates a graphic canvas and then adds and removes objects of different shapes to it.  It might have a method like this:

class ShapeMaker($canvas) {
    private $shapes = array();
    private $canvas;
    .....   
    
    function addShape($shapeObj) {
        $this->shapes[] = $shapeObj;
        $shapeObj->draw($this->canvas);
   }
}

The designer of the framework will very probably include an interface for people to create new shape classes, which include the draw($shapeObj) method signature.  By providing that interface, they guarantee that any object that is passed into the shapeMaker class via the addShape, can then immediately have it's draw($canvas) method called.

 

The details of exactly how draw works are left to the class developer, but the interface helps establish the contract of methods needed by the factory class in order to manipulate any object that implements an interface.

 

I rarely see the use of interfaces outside of a framework or library, but there is no reason you can't use them yourself if you have a solid grasp of what they are for.  Usually people are utilizing inheritance rather than interfaces, but in complicated class dependency situations, it's good to keep in mind that you can write a class that can implement 2 or 3 different interfaces, and still inherit from a base class. 

 

In PHP, you only have single inheritance, so interfaces were a way to get around that limitation in some circumstances, although in php5.4 they added traits which are another way of getting around single inheritance in many cases.


In Topic: ob_start to speed up experience

01 May 2015 - 11:48 PM

No, you pompous dipshits. I need ALL the records to appear on one page. I thought your stupid mysql pagination suggestion was some way to do some loop (i.e. look up a few records at a time and output to browser in segments), but none of you fagt geeks read my question. I want ALL the records to appear on the same page. Anyway, forget it.
 
Oh, and don't give me this "old timer" crap -- most of you aren't even in college, except for one or two of you that I know to be worms from the old Perl usenet forum.


Ok, great, so we can dispense with the curiosity aspect of it.  You just made up some wild claim of a decade of php development experience for god knows what reason.  You're not an experienced php developer.  That was pretty evident from the get-go and really wasn't that great of a charade.  
 

  1. Stop kidding yourself that your question was some model of clarity right out of the back of Eric Raymond's dissertation on the subject.  Most of us found the idea of spitting out a 10k row html table to be far too ridiculous a premise to be what someone would actually want. 
  2. Google was not involved.  I quoted the manual page for a function you used, but did not understand.  If you actually read what was quoted to you,  and spent a second trying to understand it, you'd understand why you got your so called "Goofy results" and possibly you'd use that monster intellect of yours to fix your code, which would probably take all of 30 seconds.
  3. Your comments in regards to a community of people who donate their time helping others try to improve their skills make you look sad and petty.  If indeed most of the people who responded are far younger than you, what does that say about you?

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com