Jump to content

icthos

New Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by icthos

  1. Its cool I found the answer. $this->records = $db->loadResult(); Should be $this->records = $db->loadRowList();
  2. Hey Forum, I am writing a Joomla component extension. Im trying to get all the records out of the database and set to an array, which should be a piece of cake - think SELECT * FROM mytable; Problem is when I use this code, it only returns one piece of data from one column, as a variable. public function getRecords() { $db =& JFactory::getDBO(); $query = 'SELECT * FROM #__sproj_proj'; $db->setQuery( $query ); $this->records = $db->loadResult(); return $this->records; } It should return the whole table. IE ############################### | id | name | number | | 1 | jane | 04983843947 | | 2 | dave | 04748444784947 | | 3 | mark | 54367747474754 | ############################### but of course as a multi-dimensional array $this->records ( 1 (1, Jane, 04983843947) 2 (2, Dave, 04748444784947) 3 (3, Mark, 54367747474754) ) But it just returns the first value it encounters and nothing else. echo $this->records; // Outputs '1'. The value of the first column of the first record. Its driving me insane. One of those things that should be simple but you can't find the fix anywhere. Can anyone help? Cheers, icthos
  3. Can you echo a $var that is defined later on in the script? Ive got a good grasp of PHP basics but Im struggling in building a control structure that addresses this problem. I am making a web application that can be simplified to this: <?php include('functions.php'); include('head.php'); include('body.php'); ?> functions.php connects to the database etc, but for ease of explanation it is just this: <?php $pageNumber = 6; ?> head.php contains basic HTML head code with a dynamic stylesheet loader <!doctype html> <html> <head> <link rel="stylesheet" href="<?php echo $stylesheet; ?>.css" type="text/css"> </head> body.php contains basic body template code, and gets its actual contents from another file <body> <div class="wrapper"> <?php include($pageNumber.".php"); ?> </div> </body> </html> And then as we are on page 6, page 6 contains: <?php $stylesheet = "yellow"; ?> <p>This is page six! You will notice that page six is coloured yellow, unlike any of the other pages</p> I need to be able to control which stylesheet loads at the level of this page. I could put the stylesheet inclusion code after the include($pageNumber) part but then it wouldnt validate. Is there any way I can make it look futher on in the code for the value of $stylesheet if it isnt defined yet? Or is there a better control structure?
×
×
  • 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.