Jump to content

ScoobyDont

Members
  • Posts

    43
  • Joined

  • Last visited

ScoobyDont's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. Bitterly disappointed that you need to get your crystal ball out, as an administrator you should know they have bought a Magento 1.0 ecommerce site from theme forest/ebay with a special offer of 42 addons/plugins And what chokes me even more, you have not even offered 2 lines of code to bring the load times down.
  2. Thank you, I fully understand that and thank you for your input, but everything I seem to do with this framework seems to give me problems. So I have ditched it, so I no longer need any more answers on the topic. Yesterday I carried out some testing with Laravel, Cake and CodeIgniter and out of the 3 I personally like CI so going to run with that. Thanks again for all your help
  3. Oh great, to be honest it was to help me start to understand MVC of which I first thought it seemed quite simple until I tried to do a simple bloody count Now I am starting to wonder what ever was wrong with <? $carcount = $db->query("SELECT id FROM vehicledetails WHERE id=id"); $carscounted = $carcount->rowCount(); ?> It was a course on Udemy,(£9.99) and to be fair I thought it had given me an insight into MVC but by your response maybe not. OT but which framework would you recommend for a beginner/advancing php'er
  4. Something like this should work <?php foreach $rows as $row) : ?> <div class="card"> <h4 class="card-title">Card Title</h4> <p class="card-text"> User: <?php echo $row['name']; ?> <br> Date: <?php echo $row['date']; ?> </p> </div> <?php endforeach; ?> Obviously you need to style the card as you see fit
  5. Wow thank you for your detailed repsonse, The MVC is one I followed on a tutorial online, here is a copy of my Database Lib <?php /* * PDO DATABASE CLASS * Connects Database Using PDO * Creates Prepeared Statements * Binds params to values * Returns rows and results */ class Database { private $host = DB_HOST; private $user = DB_USER; private $pass = DB_PASS; private $dbname = DB_NAME; private $dbh; private $error; private $stmt; public function __construct() { // Set DSN $dsn = 'mysql:host=' . $this->host . ';dbname=' . $this->dbname; $options = array ( PDO::ATTR_PERSISTENT => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ); // Create a new PDO instanace try { $this->dbh = new PDO ($dsn, $this->user, $this->pass, $options); } // Catch any errors catch ( PDOException $e ) { $this->error = $e->getMessage(); } } // Prepare statement with query public function query($query) { $this->stmt = $this->dbh->prepare($query); } // Bind values public function bind($param, $value, $type = null) { if (is_null ($type)) { switch (true) { case is_int ($value) : $type = PDO::PARAM_INT; break; case is_bool ($value) : $type = PDO::PARAM_BOOL; break; case is_null ($value) : $type = PDO::PARAM_NULL; break; default : $type = PDO::PARAM_STR; } } $this->stmt->bindValue($param, $value, $type); } // Execute the prepared statement public function execute(){ return $this->stmt->execute(); } // Get result set as array of objects public function resultset(){ $this->execute(); return $this->stmt->fetchAll(PDO::FETCH_OBJ); } // Get single record as object public function single(){ $this->execute(); return $this->stmt->fetch(PDO::FETCH_OBJ); } // Get record row count public function rowCount(){ return $this->stmt->rowCount(); } // Returns the last inserted ID public function lastInsertId(){ return $this->dbh->lastInsertId(); } } If you could see any errors that is causing the problem it would be appreciated, I will also look at what you have previously sent and get back to you if I get stuck
  6. hi, I have changed the code a little bit and put everything in my index page to try and to get it to work, I am not getting the Undefined error anymore I am just getting a 0 value with everything I do. The new revised code Model <?php public function countVehicles (){ $this->db->query("SELECT COUNT(id) FROM vehicles WHERE id = :id"); $counter = $this->db->rowCount(); return $counter; } And Controller <?php public function index(){ $counter = $this->vehicleModel->countVehicles(); $data = [ 'counter' => $counter ]; $this->view('vehicletracker/index', $data); } And View <?php <h2><?php echo $data['counter'];?></h2> Like mentioned I am just getting a return of 0, If someone can point me in the right direction it would be much appreciated And please KISS (Keep It Simple as I am Stupid)
  7. Hi, thanks for your response I have tried SELECT COUNT, but I still get the same "Undefined index: total" Is there a way I can check if the controller is getting the data?
  8. Hi I will try and explain this as best I can, as I am not sure if the "include" is causing the problem. What I am trying to achieve is count the total number of vehicles in the "vehicles" db table and pass it to views (I have recently moved over to MVC so still learning so please be kind and keep it simple for me please) I have a folder in views called "vehicletracker" , within this folder I have 2 files "index.php" and "widget.php".........The "widget.php" file is an "include" within "index php". The problem I am having is passing data from the controller to the view, I keep getting an "Undefined index: total" error and wonder if someone can help and show me where I am going wrong. This is my Model <?php class Widget { private $db; public function __construct(){ $this->db = new Database; } public function countVehicles(){ $this->db->query("SELECT * FROM vehicles"); return $this->db->rowCount(); } } This is my controller <?php class Widgets extends Controller{ public function __construct(){ $this->widgetModel = $this->model('Widget'); public function widget (){ $data['total'] = $this->widgetModel->countVehicles(); $this->view('vehicletracker/widget', $data); } } And my view <h2 class="text-white"><?php echo $data['total']; ?></h2> Thanks in advance for any help you can give
  9. Hi, Sorry lost you a little, this is the db Obviously it has'insert_time' and 'update_time' which is all well and good I am struggling to understand or get to grips with what I have to do to keep 'update_time' static for front end as like my image in OT What I want is:- Previous States status 1 = updated @ 20.09 Current State status 2 = updated @ 20.11 But currently if I changed the status to 2 I would get this results Previous States status 1 = updated @ 20.11 Current State status 2= updated @ 20.11 Would I be best to do 'fwrite' to a new file or is there another way
  10. Hi, I have managed to get it partially working but now stuck again, When I change the status the time changes in the db..which is what I wanted I will now try and explain what I want to do next When I change from Status 1 to Status 2 is it possible to grab the time of status change and make it static so it wont change when the status alters in the db again from 2-3 Will I need another column in the db or is there something I can do with php Thanks in advance
  11. Ooops my bad, sorry But thanks for adding the solution for me.
  12. Hi Is it possible to go above 12mths using %m, so for example 5 years = 60mths I am using this code to change the colour of panels which works ok until I make the due date 1yr 2 mths away it makes the panel go red, I need it to stay green and echo 14 mths <?php $expire = $dates->datedue; $date = new DateTime($expire); $now = new DateTime(); ?> <div class="col-md-3"> <div class="panel <?php if ($now->diff($date)->format("%m") < 3) { echo 'panel-red'; } else if ($now->diff($date)->format("%m") < 6) { echo 'panel-orange';} else { echo 'panel-green'; } ?>"> <div class="dark-overlay">Due Date</div> <div class="panel-body"> <h4 class="duedate"><?php echo $now->diff($date)->format("%m Months");?></h4> </div> </div> <?php if ($now->diff($date)->format("%m") < 3) { echo '<div class="text-center"><button class="btn btn-success"> Book Now</button></div>'; } ?> </div> So the question is Is it possible to have more than 12mths?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.