veedeoo 474 Junior Poster Featured Poster

Also, if you run this

<?php 

phpinfo(); 

?>

you will be able to check for whatever php extension you have installed on your server.

If you go down about 3/4 of the page, you will see the session directives. The latest Registered serializer handlers is php php_binary wddx.

Most PHP configuration will always have files as the default value for the session.save_handler directive. So, if you set the CI to save it to the database, then this directive will be overriden.

The session.save path is always defaulted to tmp directory. However, if you want to change this to some encrypted name, you are always welcome to do so, as long as you change the value on your php.ini file.

If you are using xampp or equivalent, you can literally view the sessions generated by PHP

For example, Symfony2 will generate a session text file inside the tmp directory similar to this.

logged|
    b:0;id_user|
    i:0;username|
    s:0:"";privs|
    i:0;email|
    s:0:"";_symfony2|
    a:3:{
    s:10:"attributes";a:0:{}s:7:
    "flashes";a:0:{}s:6:"locale";s:2:"en";}

does it look familiar? those are the same as the example above, but I would never post anything on how CI handles its session transactions.

Looking at the code above, it appears that this session belongs to the site admin of a Symfony2 website. The privs for the admin is 7, the user id of the admin is 6.

Can we fixiate this session ? Sure, middle school kids can probably figure this out in no time.

veedeoo 474 Junior Poster Featured Poster

I forgot, when you distribute your application, make sure that your installation database table for members must have a predefined auto-increment value to prevent clever users from guessing the member's user id.

So for example, we packaged our application for distribution of a beta release.

Normally, installer will have to parse the table from the default sql file. Below is a make up users table..

CREATE TABLE IF NOT EXISTS `users` (
  `id_user` int(11) NOT NULL AUTO_INCREMENT,

  PRIMARY KEY (`id_user`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ;

to prevent incrementing from 1 of which in most cases are assigned to the admin, we can change the distribution sql to something like this for all tables with auto increment

CREATE TABLE IF NOT EXISTS `users` (
  `id_user` int(11) NOT NULL AUTO_INCREMENT,

  PRIMARY KEY (`id_user`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1549;

the first registered user will be given the next incremented value from 1549 and not 1 which is almost a give away to anyone who knows how to spoof sessions.

veedeoo 474 Junior Poster Featured Poster

Yes, you are correct a clever user can edit their session. Just be very careful and always make sure to manually itimized the session you ONLY! need for the user to move around the site.

I don't use this method as strongly suggested by many blog tutorials

$this->session->set_userdata();

What I normally do to my application is to manually assign things that I need so that I can use it to query any additional data about the user. For example, if user A is logged_in and he has been granted the Privilege of 300 which is equivalent to regular memeber in the hierarchy of users.

my session assignment would be pretty conservative. I would only assigned three to four things in there at the most.

$sess_data = array(
               'username'  => 'user_name',
               'user_id' => 'user_id',
               'time_logged_in' => time(), //always affix and suffix something and make sure to add delimiters anywhere for you to explode.
               'logged_in' => TRUE
           );

$this->session->set_userdata($sess_data);

we can set the number of minutes in the script to re-verify the user or else logged him out.

$session_expiry = 3600;

if(time() - $this->session->userdata('time_logged_in') >= $session_expiry){

    ## time to terminate the session for this user
    $this->session->sess_destroy();
    redirect('mainpage', 'refresh');

}

Controlling page access based on privilege rule. There are some sites where the contents shown based on the user privilege. For example, all members with priv 300 can only view banana pictures, priv 400 are allowed to view pears and apples, and priv 500 can view all the fruits available …

veedeoo 474 Junior Poster Featured Poster

I second the quantum computing.

veedeoo 474 Junior Poster Featured Poster

I just need 3 rows..

for example, the most common CSV file format are similar to this.

First row as column names with delimiter |

username | email_address | phone_no | status | hobbies |

after the first row, it will be followed by the entries with | delimiter. Hobbies with delimiter ,.

veedeoo | veedeoo@any_do_com | 000-000-0000 | active | scuba diving, skateboarding, rock concerts, playing ukelel, playing Les Paul electric guitar, pink floy riffs

Line 0 or first row are commonly written like that. The CSV file dumper can parse that and make them the column names.

veedeoo 474 Junior Poster Featured Poster

can you post your codes from model?

veedeoo 474 Junior Poster Featured Poster

Hi,

Can you at least give us few lines of the CSV file. It is okay to change the data to something else as long as the structure is the same as the original.

I can't promise you with anything, but I need to see at least few entries on the CSV then I let you know if I can do anything about it. Else, I cannot draw any analysis about the hammer's effeciency without looking at the nail first.

veedeoo 474 Junior Poster Featured Poster

you need to rewrite your array to something like below to associate every fruit to each color.

<?php

    echo '<b> Fruits </b> <br/>';

             $fruits = array('lemon'=>'#FFFF00','orange'=>'#FFA500', 'apple'=>'#FF0000');

    ksort($fruits);

    foreach($fruits as $k => $v){

        echo '<p style="color:'. $v .';">'. $k .'</p>';

        }
veedeoo 474 Junior Poster Featured Poster

From what script is this? Is it from PHP using a PHP/Java bridge, or simply a regular PHP script?

If it is from regular PHP application script, then the IO is the class or object and intValue is the static method of that object.

for example, we can have a class with static method like this

class IO{

    public function __construct(){
    }

    public static function intValue($id){

        return(intval($id));

        }
  }      

The class above can duplicate or allow us to test your code.

echo IO::intValue('50');

it should print out 50 which is an integer. Eventhough, I made it like a string.

My example above is extremely simple that in real world application, the class is not even needed due to int() function that can do the job with less code.

veedeoo 474 Junior Poster Featured Poster

it is similar to the template engine cache function. The only difference is that in template engine such as smarty, we can define which block of contents should be ignore by the cacheing mechanism.

In codeigniter, it will keep the cached the contents based on the definition of $x as time in minutes.

$this->output->cache($x); // $x is the number of minutes

Warning!
Only use this function outside the form, login form, user's account page, administration page and other contents where login authentication is required.

If you will be using this function, it is helpful to create a purging script or class to give you the option to purge the cached content on demand without manually deleting them.

It is useful in delivering contents that don't change a lot. For example, a front page with content from the database that don't change a lot can use the cache function. It will definitely saves a great deal of server resources by just loading the cache page rather than executing a database fetch queries for the contents.

veedeoo 474 Junior Poster Featured Poster

good catched AndrisP. Spaces indeed.

veedeoo 474 Junior Poster Featured Poster

pretty much there are few things you can do with .htaccess file. Please read #9 on this article. While you are at it, try reading some topics that are related to your situation.

veedeoo 474 Junior Poster Featured Poster

if the photos name and file name are stored in the database, you need pagination. We have plenty of pagination scripts and threads here in Daniweb.

if the photos are in the directory and you are reading the contents by way of PHP, then you want the pagination using javascript as shown here. DynamicDrive's example is only for one image. For 25 images, you can modify the demo script to this...

<script type="text/javascript">

var pagecontent=new virtualpaginate({
 piececlass: "virtualpage", //class of container for each piece of content
 piececontainer: "div", //container element type (ie: "div", "p" etc)
 pieces_per_page: 25, //Pieces of content to show per page (1=1 piece, 2=2 pieces etc)
 defaultpage: 0, //Default page selected (0=1st page, 1=2nd page etc). Persistence if enabled overrides this setting.
 wraparound: false,
 persist: false //Remember last viewed page and recall it when user returns within a browser session?
})

pagecontent.buildpagination(["paginatediv"])

</script>

Here is another one.

veedeoo 474 Junior Poster Featured Poster

just another maybe :). I am borrowing Diafol's last line of code.

$followers = json_decode($ids, true);

foreach($followers as $follower){

    echo $follower .'<br/>';

    }
veedeoo 474 Junior Poster Featured Poster

in addition to Mr. Pritaeas's response, this

$regex = '/TITLE>(.+?)TITLE/';

gives us the expected result.

Blank website. Blank site. Nothing to see here.</

Yes, this </ is included. So, it isn't really the same result as

$regex = '/<TITLE>(.+?)\<\/TITLE\>/';

which will give us

 Blank website. Blank site. Nothing to see here.

One limitation of the regex code above is that, it will not give us anything if the title tag is written in lowercase as in html5 standard

$title = '<title>Blank website. Blank site. Nothing to see here.</title>';

to make our regex case-insensitive we can change the regex filter to

$regex = '/<title>(.*)<\/title>/i';

the above should return the title string from either

$title = '<title>Blank website. Blank site. Nothing to see here.</title>';

or

$title = '<TITLE>Blank website. Blank site. Nothing to see here.</TITLE>';

test:

    if(preg_match('/<title>(.*)<\/title>/i',$title,$matches)){
echo $matches[1];

 }

should return the title string from either of the title variables.

veedeoo 474 Junior Poster Featured Poster

Hi,

If you are running PHP version 5.3.6 or higher, this should work

<?php

function get_file_ext($filename){

        $info = new SplFileInfo($filename);
        return($info->getExtension());
}

to test the function above try..

echo get_file_ext('05.Judaiyaan [MusikMaza.Com].mp3');

that should output mp3

side notes: If you will be renaming the uploaded file, you need to get the filename without extension. To get the filename without extension, we can simply do it like this.

echo '<br/>'. basename('05.Judaiyaan [MusikMaza.Com].mp3', '.'.get_file_ext('05.Judaiyaan [MusikMaza.Com].mp3'));

the above should give us

05.Judaiyaan [MusikMaza.Com]

make sure to sanitize the filename as suggested above by Diafol.

veedeoo 474 Junior Poster Featured Poster

catalinetu is correct, just add second and third parameter to the get method. Derived from this

public function get($table = '', $limit = null, $offset = null)
{

}
veedeoo 474 Junior Poster Featured Poster

you can use explode if you want.

$this_category = explode(',' , $row['category_id']);

    foreach($this_category as $cat){
        echo $cat.'<br/>';
        }

or if you want to become creative , you can do it like this

foreach((explode(',',$row['category_id'])) as $cat){

    echo $cat.'<br/>';

    }
veedeoo 474 Junior Poster Featured Poster

hi,

there are many ways of achieving this. The most simple is to create a session on index.php and then check if the session exists on home.php. If the session does not exist, the user is redirected to the index.php

sample codes

filename: index.php

<?php

    session_start();

    $_SESSION['been_here'] = true;

    header("Location: http://your_domain_dot_com/home.php");
     die();

home.php

<?php

    if(isset($_SESSION['been_here'])){
        ## do all the things you want to do
        }

        else{

            header("Location: http://your_domain_dot_com/index.php");
     die();
     }

you can also do this kind of statement

     if($_SESSION['been_here'] && (isset($_SESSION['been_here']))){

         ## do all the things you want to do

         }

         else{

             ## redirect the unexpected intruder here..

         }
veedeoo 474 Junior Poster Featured Poster

Pretty much all of the frameworks have a pretty good security. Companies geared in ecommerce development based on Magento will require you to know Zend. Magento is based on the Zend Framework. However, there is a pretty steep learning curve in Zend. You will have to know the basics of MVC design pattern first and then move on to Zend, else prepare to pay a high price for the course being offered by Zend.

There are some companies doing ecommerce development based on CodeIgniter, Laravel and Kohana. Most corporate and business websites are built on CI with foundation or bootstrap. There are some downside to using CI. CI is no longer being maintain by its creator. Meaning, that from that day Ellis Lab ceased their support, you are on your own. Using CI to this date requires you to be able to write your own module. For example, the password module is not as effecient as the latest PHP password hash function found in PHP 5.5.x or higher. You will need to know how to create a modules and helpers for CI so that you can utilize this.

Regardless on which one you learned and mastered, employer will always look for proficiency in OOP, MVC design patterns, and the knowledge and experience in creating an application in either one or two of these frameworks CI, Kohana, Laravel, Zend, or Symfony 2.

If you are crazy like me, learn all of them and you wouldn't be asking this type …

veedeoo 474 Junior Poster Featured Poster

if you do

var_dump($_SESSION["ServiceOrders"]);

, it will give you all the hints you need on how to index the stored session vars.

try it.. :)

veedeoo 474 Junior Poster Featured Poster

can you try running this

<?php

     phpinfo();

direct your browser to this page and look for the loaded configuration file. It should tell you which php.ini is being loaded by the xampp.

veedeoo 474 Junior Poster Featured Poster

There is function in PHP called date_default_timezone_set() which can set the default time zone of an application or the runtime configuration.

For example, we can define the default timezone of an application to any timezone supported.

date_default_timezone_set('Europe/London');

if we do this

echo time();

Will give us the timestamp for London. I am not sure if the time is adjusted to DST. If not, then the timestamp will be an hour late to the actual time.

If you have access to php.ini file and if you are allowed to edit it, you can add or define the date.timezone to whatever timezone you want as long as it is supported.

date.timezone = "Europe/London"

Please read this list of supported timezones.

Update:
For mysql, please refer to this documentation.

veedeoo 474 Junior Poster Featured Poster

If we want FIFO, then we can sort by the date in DESC order. It will be easier if the date is in unix timestamp. Just reverse the order for the LIFO order.

veedeoo 474 Junior Poster Featured Poster

one of the many ways of doing this is to get the image file extension first.

for example,

$this_ext = pathinfo($filename, PATHINFO_EXTENSION);

The above codes will give us the image extension of the uploaded image.

The next step is to rename the image

$result1 = move_uploaded_file($tmpname, $uploadDir.'.'.$this_ext);
veedeoo 474 Junior Poster Featured Poster

I think Diafol have already given you what you need. Store the submitted information in session.

In fact, you can store them as an array. Below is a sample codes...

$upload_info = array($title, $description, $uploaded_file_name, $other_things_you_want);

$_SESSION['up_data'] = $upload_info;
header("Location: form.php");
exit;

on redirect, the user will land on the form.php. place session_start() on top of the page as suggested above.. we can access the information stored in the session.

echo 'Title : '. $_SESSION['updata'][0].'<br/>';
echo 'Description :'. $_SESSION['updata'][1].'<br/>';
echo 'Uploaded File: '. $_SESSION['updata'][2].'<br/>';

That's pretty much it.....................

Added Later:
You can also do the database insertion here if you desire to do so.

veedeoo 474 Junior Poster Featured Poster

also, you can try running this

<?php
    echo '<br/>'.ini_get('upload_max_filesize').'<br/>';
    echo (ini_get('post_max_size'));
    echo '<br/>'.ini_get('max_execution_time').'<br/>';

    ?>

post back your output...

momonq1990 commented: thank you :D +2
veedeoo 474 Junior Poster Featured Poster

Honestly, I don't see any reasons why it shouldn't work? All static method can be use by other classes. Except, if this is a separate controller file /login . That would change the application's loaded controller.

It is pretty much equivalent to

<form method="post" action="/login">

On form submit, it would take you to /application_directory/login_Controller/Method/. In your case you are loading the login controller instance. If the login controller page does not require the User class, then User::login() method cannot be executed.

I wrote an application on CI where the user can login and will never leave the page. To do this, you make the method of the current controller page that will process the form.

So, for instance a URI appdirectory/login_controller/ can process the form by assigning the processing to another method called process. That would give us a new uri of /appdirectory/login_controller/process/. However, even after the form has been processed, the controller page did not change and we are still using the same controller. Only the method process is added.

If the login_controller file require the User class, then the static method of User should be available.

Example class uitilizing static method of another class: This is an example only. Your framework may have different ways of doing things.

require_once('user.php');

class LoginController extends BaseController{

    public function __construct(){}

    public function index(){
        echo 'this is the default content on load';

        }

    public function process(){
        echo 'This is the form processor';
        if(isset($email) AND (isset($password)){
            User::login($email, $password);
            }
            }

        }

The …

veedeoo 474 Junior Poster Featured Poster

var_dump($pkcs12) , what do you get? Is it the right structure expected by the webservice?

e.g.

Array ( [this_array] =>( [something] => something_value)[another_array]=>[index_b] =>[value_b]))

veedeoo 474 Junior Poster Featured Poster

Another efficient alternative is to load these models

 $this->load->model('Stuff');// this the basic model for the content without control
$this->load->model('most_viewed'); //second model for most viewed
$this->load->model('most_popular');//third model
$this->load->model('most_commented');//fourth model

to the controller's method needing them. The reason is that the model will not be instantiated until the browser request the most_viewed method.

public function most_viewed(){

    $this->load->model('most_viewed');
    $this->load->view('forum/mostviewed', $this->most_viewed->get_post());

    }

That should deliver the most_viewed content from the most_viewed model class==> method get_post() to the template file mostviewed.php

By doing this alternative, we isolated the instantiation of the model objects only when needed, instead of loading them in the instantiation of the object forum.

veedeoo 474 Junior Poster Featured Poster

I am currently looking at your ultralite forum application. I have few recommendations later on. For now, I would like to recommend adding adding a constructor on the the application's controllers. Just make sure prior to releasing the application, remove all the echo from the controller file.

For example, on the file called /application/controllers/forum.php, it would be nice to add a constructor. Kind'a like this

class Forum extends CI_Controller {

public function __construct(){

    parent::__construct();

        ## this is also the perfect time to load helpers and library
        ## if the application will be using non-persistent database connection, then this is the right place to set an instance of the database for the model to use.
        $this->load->database();
        $this->load->model('Stuff');
        $this->load->helper("url");
        $this->load->library("pagination");// paginating long results



}

public function index()
{
    // main index function  
}

## rest of the forums methods here



}

Some people reading this maybe wondering why did veedeoo load the database on the controller's contructor? Isn't it suppose to load in the application's model class? The questions are pretty valid and yes we are supposed to load database on the model class. In fact, the CI documentation suggested to set the database connection in the model class. However, if we want to run 4 different models in one controller, we want the database connection to be persistent in that very specific controller, instead of renewing an ovelapping database connection throughout the application. Unless, there is a sigleton library that we can use to confirm if the database connection class …

veedeoo 474 Junior Poster Featured Poster

okay, I will download it and take a look at the source code.

I have a minor corrections on my recommendations above. I mentioned that CI uri convention was mydomain.com/controllers_name/method_name/. However, the out of the box CI was not like that. It is like this mydomain.com/index.php/controllers_name/method_name/.

To eliminate the index.php in the middle of the url, we need to add this .htaccess file in the installation directory

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]  

That should eliminate the needs of typing index.php .

When I was learning about MVC design patterns, my older brother told be to practice on CI. Although I am Zend Certified, my very first taste of PHP MVC framework was in CI and not in Zend Framework.

I also wrote a PDO CRUD library for CI, because the database library is getting really old now.

iamthwee commented: super! +14
veedeoo 474 Junior Poster Featured Poster

we can also assign the default page for the admin if session and log-in are validated. We can do this by creating the default function index or method index().

public function index(){

    ## validate admin credentials
    ## show whatever contents the admin needs to see after log-in validation

    ## send output to the template file

    ## if the session expired, the log-in credentials are no longer valid, send the user to the login page.

    if( not admin or not logged in or the session logged_in does not exists){
    //redirect('login/','location');

    }

    }

CI is using two different redirects refresh and location ( this is the second parameters of the function redirect. I strongly recommend location as the second parameter because it is somewhat faster).

veedeoo 474 Junior Poster Featured Poster

just to add a little more on the admin class. we can also create separate methods for the user management interface. In my example, above I created method called manage_users() which is intended to all registered users.

Another question that may come up will be how to execute the actions by the admin ? e.g. delete user, add user, suspend user, etc..

A good approach in implementing this can either creating separate method or can be included in the manage_users method. I prefer the first, because it will be a lot easier to submit form.

suppose we have a form to manage members

<form action="mydomain.com/admin/delete_user/" method="post">
<input type="hidden" value="member_id"/>
<input type="text" name="delete_m" value="member username from database"/>
</form>

The form is normally attached by the codeigniter to the view. Something like this.. this is just an example form attributes assignment in CI.

$attributes = array('class' => 'manage_users', 'id' => 'm_users');

## we can send the form to the template file
$form_array =  array(
                'form'=> form_open('admin/delete_user',$attributes),
                'form_submit'=>form_submit( 'submit', 'Delete')
                );

Our template file can be something like this

 <?php echo $form_array['form'];?>
 <input type="text" name="delete_m" value="member username from database">
 <!-- we call the form submit -->

 <?php echo $form_array['form_submit'];?>
 <!-- lastly, we close the form -->

 </form>

If we run the codes above the form will be posted to /admin/delete_user. Again, this is a classic CI convention in practice here. The router will look for the admin object and for the delete_user method.

We can add the delete_user method …

veedeoo 474 Junior Poster Featured Poster

I would difinitely create a separate controller and methods intended for the admin. For example, if we have a url mydomain.com/admin/settings/, then our object will be called admin and the method is called settings.

Using the target url above we can device our admin class

class Admin extends CI_Controller {

    public function __construct(){
            $this->load->helper('url');
            $this->load->library('session');
            ## we can also load the form validation and form helper here if needed.
            }

    public function settings(){

        ## if logged_in and privs is equal to admin
        ## set is_admin to session

        }

   /*
   * create methods for whatever options available to the admin
   */

   public function manage_users(){

   ##create Admin_model class with method called get_users()
   ## we can load our database and then create an instance of the Admin_model

   $this->load->database();
    $this->load->model('admin_model');

    ## send members array to the view
    $these_members = $this->admin_modle->get_users();

    }

    }

so if the user is admin and the session is_admin exists, then mydomain.com/admin/settings and mydomain.com/admin/manage_users can be served.

veedeoo 474 Junior Poster Featured Poster

there is another PHP function for sorting called uksort.

function syntax is pretty self explanatory.

bool uksort ( array &$array , callable $key_compare_func )
veedeoo 474 Junior Poster Featured Poster

I forgot to add

mysqli_close($db_conn);

after the

fclose($fp);
veedeoo 474 Junior Poster Featured Poster

I think you need to save the csv file before attaching it to the email.

Here is a test script I made to create and send csv file.

Step 1 : Download the phpmailer class here.

Step 2 : Unzipped the phpmailer zip file.

Step 3: In your server, create a directory named phpmailer. Move these files from the unzipped files to the phpmailer directory.

phpmailer/
class.phpmailer.php
class.pop3.php
class.smtp.php
PHPMailerAutoload.php

Step 4: Take a look at this example fputcsv script post 14.

Step 5: We modify the script to use MySQLI. I urged you to modify the MySQLI. I wrote it just to be able to connect an retrieve data for my testing.

 <?php
require_once('phpmailer/class.phpmailer.php');

## set database credentials
$db_host = '';
$db_user = '';
$db_pass = '';
$db_name = '';


$db_conn = new mysqli($db_host, $db_user, $db_pass, $db_name);

if (mysqli_connect_errno($db_conn))
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }


 ## the function from http://us3.php.net/fputcsv

function query_to_csv($db_conn, $query, $filename, $attachment = false, $headers = true) {

    if($attachment) {
        // send response headers to the browser
        header( 'Content-Type: text/csv' );
        header( 'Content-Disposition: attachment;filename='.$filename);
        $fp = fopen('php://output', 'w');
    } else {
        $fp = fopen($filename, 'w');
    }

    $result = mysqli_query( $db_conn, $query);

    if($headers) {
        // output header row (if at least one row exists)
        $row = mysqli_fetch_assoc($result);
        if($row) {
            fputcsv($fp, array_keys($row));
            // reset pointer back to beginning
            mysqli_data_seek($result, 0);
        }
    }

    while($row = mysqli_fetch_assoc($result)) {
        fputcsv($fp, $row);
    }

    fclose($fp);
}

Step 6: We …

veedeoo 474 Junior Poster Featured Poster

Are you using phpmailer class or the native php mail function? For what I have heard, phpmailer class is more reliable in terms of sending email with file attachement.

example implementation of phpmailer class with attachements. You can download phpmailer class here.

veedeoo 474 Junior Poster Featured Poster

Yes, this is possible. There are four options to be able achieved this.

  1. Use PHP
  2. Use the HTML5 file reader
  3. Use javascript
  4. ASP.net

Try google with 'reading text file in javascript' and for PHP read this. If you are developing in asp.net mvc there is a method called ReadAllText, I don't remember the proper syntax, but it should be on the Microsoft website.

veedeoo 474 Junior Poster Featured Poster

Hi,

Please allow me to use the first database you have presented. Keep in mind the query is pretty much the same, regardless if we use the second database that you posted. Just replace the column names.

In my example that should represent the school_id on the first table and school_id on the second.

Simple rule I made for myself only. I always assign my query to some variable for easy update and modification.

Here we go. Say we have these tables school and school_info as shown above.

I would do this in a long-hand version for clarifications, but you are always welcome to do it differently.

Itimize all pertinent columns from both tables.

$db_filters = "school_id,school_name,district,persion_in_charge,in_charge_title,in_charge_contact, date_added,address,telephone,badge,badge_name";

I only use school_id once because both tables have the same column name.

We define our query

$get_items = ("SELECT ".$db_filters." FROM YOUR_DATABASE LEFT JOIN school_info ON(school.school_id = school_info.school_id) ORDER by `date_added`");

We execute our query... WARNING! please USE PDO. I don't have any PDO reference at this moment, so I will use the OLD mysql. $conn is the database instantiated or persistent connection

$result = mysql_query($get_items, $conn) or trigger_error("SQL", E_USER_ERROR);

loop the result

echo 'put your table tags here';
while($row = mysql_fetch_array( $result )) {

    /*
    * the column name can be from either table.
    */

    echo $row['column_name'];

    }

If you are happy with the result, slowly build your html around them to achieve the presentation style your boss wanted.

I am not really sure if your …

veedeoo 474 Junior Poster Featured Poster

If you are using windows, try Microsoft Web Matrix 3. It is an all around web developing tool. I have not seen it yet, but a good friend of mine told me it is worth trying.

veedeoo 474 Junior Poster Featured Poster

have you look into join as described here?

Can you show us your tables?

veedeoo 474 Junior Poster Featured Poster

You cannot forcebly destroy session on a remote client using script. The only way you can do this is by connecting by way of FTP or when you change the session.save_path directive to something else.

Sessions are stored above your public directory. In some servers, it is called 'tmp' directory.

You can easily find the exact location by running a simple phpinfo() and look for the session directive called session.save_path

If you want to change the directory for the save_path, please read more here.

Warning! changing the location for the save_path create serious vulnerabilities. This is the reason why we don't want to put the item price in session variables.

veedeoo 474 Junior Poster Featured Poster

The path should be the directory wherein the wordpress is installed. I believe that is an strict rule given by the wordpress codex.

Looking at your site, the reason it is blank because of this error

Call to undefined function language_attributes()

Try loading your page with all of the language_attribute() function commented just to see if the page will load properly.

I personally tested the above code snippets on the latest version of wordpress and it is working just the way I would expect them to work.

veedeoo 474 Junior Poster Featured Poster

correction: update the $posts variable.

$posts = get_posts('numberposts='.$number_of_post.'&order='.$order.'&orderby='.$order_by);
veedeoo 474 Junior Poster Featured Poster

Hi,

I thought it should be like this

<?php
require('Your_Wordpress_directory/wp-blog-header.php');
?>

If you want to show your article, it can be written like this

<?php
require('Your_Wordpress_directory/wp-blog-header.php');
?>

<?php
$number_of_post = 5; ## change this value to your own needs
/*
*@order is for the database query Ascending or Descending sort method
*/
$order = 'ASC'; 

/*
*@ order_by
* post title is the column name of the wp_post table. 
* You can change this to several options e.g. post_date, etc..
*/
$order_by = 'post_title'; 

$posts = get_posts('numberposts=10&order=ASC&orderby=post_title');
foreach ($posts as $post) : setup_postdata( $post ); ?>
<?php the_date(); echo "<br />"; ?>
<?php the_title(); ?>    
<?php the_excerpt(); ?> 
<?php
endforeach;
?>

You can also copy and paste these codes from the codex as shown..

<?php
    require('Your_Wordpress_directory/wp-blog-header.php');

    global $post;

    $args = array( 'posts_per_page' => 3 );
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) :  setup_postdata($post); ?>
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a><br />
    <?php endforeach; ?>

Those PHP tags mixed-up are so tempting for correction, please don't do it. It is part of the Wordpress Syntax.

To acquire the theme style, just view the html source of your wordpress and use the css file url.

veedeoo 474 Junior Poster Featured Poster
  1. Pirates of the Caribbean (all)
  2. Ironman ( All)
  3. Spiderman ( All)
  4. Superman ( 1 and 2 only)
  5. Django Unchained
  6. Kill Bill (all)
  7. The GodFather ( all)
  8. Matrix ( all)
  9. Face Off
  10. My Way ( Korean Movie 2011)
veedeoo 474 Junior Poster Featured Poster

it is also working on my side.

veedeoo 474 Junior Poster Featured Poster

@Douglas

You can pretty much add a column on your dbtable to accomodate the processed status.

for example, if we have a database table called prod_enroll, having the following columns. enroll_id, rel_code, fname, lname, gender, birthdate, cover_start, cover_end, enroll_status. We can easily add a column named process.

enroll_id, rel_code, fname, lname, gender, birthdate, cover_start, cover_end, enroll_status, process.

The process column value could be set to bolean false as default and then update it to true ONLY WHEN the CSV file creation was successful.

If we go this route, then on your query during the CSV file creation, we can add another WHERE clause.

something like this.

FROM prod_enroll
WHERE mem_id = '$mem_id'
AND enroll_status!='A'
AND process = false
ORDER BY enroll_id

So, if we are to use the above query then we should assign a default value of 0 to the column process.

We can then check if the csv file exist in the directory and if it exist, we can run the update query setting the "process" column value to true or 1 for all of the rows affected by the first query.