PHP - Using Php To Set The Li Class, To Change Color Using Css...
Hey,
I'm trying to add an class so I can have different background colors on my tabs. This is the nav code for my site Code: [Select] <?php function art_get_menu_auto($theme_location = 'primary-menu', $source='Pages', $Subitems = 'true', $menu = null) { $depth = (!$Subitems ? 1 : 0); if (($source != 'Custom Menu') && function_exists('wp_nav_menu')) { $locations = get_nav_menu_locations(); if ($locations && isset( $locations[ $theme_location ] ) ) { $nav = wp_get_nav_menu_object($locations[$theme_location]); if($nav){ $source = 'Custom Menu'; $menu = $nav; } } } return art_get_menu($source, $depth, $menu); } function art_get_menu($source='Pages', $depth = 0, $menu = null) { if ($source == 'Custom Menu' && function_exists('wp_nav_menu') && $menu) { return art_get_list_menu( array( 'menu' => $menu, 'depth' => $depth)); } if ($source == 'Pages') { return art_get_list_pages(array('depth' => $depth, 'sort_column' => 'menu_order, post_title')); } if ($source == 'Categories') { return art_get_list_categories(array('title_li'=> false, 'depth' => $depth)); } return "Error in menu source ".$source. "."; } /* menus */ function art_get_list_menu($args = array()) { $menu = $args['menu']; $menu_items = wp_get_nav_menu_items($menu->term_id); if(empty($menu_items)) { return sprintf( '<li><a>' .art_option('menu.topItemBegin') .__("Empty menu (%s)", THEME_NS) .art_option('menu.topItemEnd') .'</a></li>', $menu->slug); } $nav_menu = ''; $items = ''; _art_menu_item_classes_by_context($menu_items); $sorted_menu_items = array(); foreach ((array) $menu_items as $key => $menu_item) $sorted_menu_items[$menu_item->menu_order] = wp_setup_nav_menu_item($menu_item); $walker = new art_MenuWalker(); $items .= $walker->walk($sorted_menu_items, 0, array()); $items = apply_filters('wp_nav_menu_items', $items, $args); $items = apply_filters("wp_nav_menu_{$menu->slug}_items", $items, $args); $nav_menu .= $items; $nav_menu = apply_filters('wp_nav_menu', $nav_menu, $args); return $nav_menu; } function _art_menu_item_classes_by_context( &$menu_items ) { global $wp_query; $home_page_id = (int) get_option( 'page_for_posts' ); $queried_object = $wp_query->get_queried_object(); $queried_object_id = (int) $wp_query->queried_object_id; $active_ID = null; $IdToKey = array(); foreach ( (array) $menu_items as $key => $menu_item ) { $IdToKey[$menu_item->ID] = $key; if ( $menu_item->object_id == $queried_object_id && ( ( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && $wp_query->is_home && $home_page_id == $menu_item->object_id ) || ( 'post_type' == $menu_item->type && $wp_query->is_singular ) || ( 'taxonomy' == $menu_item->type && ( $wp_query->is_category || $wp_query->is_tag || $wp_query->is_tax ) ) ) ) { $active_ID = $menu_item->ID; } elseif ( 'custom' == $menu_item->object ) { $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $item_url = strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url; if ( $item_url == $current_url ) { $active_ID = $menu_item->ID; } } } $currentID = $active_ID; while ($currentID !== null && isset($IdToKey[$currentID])) { $current_item = $menu_items[$IdToKey[$currentID]]; $current_item->classes[] = 'active'; $currentID = $current_item->menu_item_parent; if ($currentID === '0') break; } } class art_MenuWalker extends Walker { var $tree_type = array('post_type', 'taxonomy', 'custom'); var $db_fields = array('parent' => 'menu_item_parent', 'id' => 'db_id'); var $is_active = false; function start_lvl(&$output, $depth) { $indent = str_repeat("\t", $depth); $output .= "\n$indent<ul"; if ($this->is_active){ $output .= ' class="active" '; } $output .= ">\n"; $this->is_active = false; } function end_lvl(&$output, $depth) { $indent = str_repeat("\t", $depth); $output .= "$indent</ul>\n"; } function start_el(&$output, $item, $depth, $args) { global $wp_query; $indent = ($depth) ? str_repeat("\t", $depth) : ''; $classes = empty( $item->classes ) ? array() : (array) $item->classes; $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) ); $active = in_array('active', $classes); $output .= $indent . '<li'; if ($active) { $this->is_active = true; $output .= ' class="active" '; } else { $output .= ' class="1" '; // This line..... } $output .= '>'; $attributes = ! empty($item->attr_title) ? ' title="' . attribute_escape($item->attr_title) .'"' : ''; $attributes .= ! empty($item->target) ? ' target="' . attribute_escape($item->target) .'"' : ''; $attributes .= ! empty($item->xfn) ? ' rel="' . attribute_escape($item->xfn) .'"' : ''; $attributes .= ! empty($item->url) ? ' href="' . attribute_escape($item->url) .'"' : ''; $attributes .= ! empty($class_names) ? ' class="' . attribute_escape($class_names) .'"' : ''; $item_output .= '<a'. $attributes .'>'; if ($depth == 0) $item_output .= art_option('menu.topItemBegin'); $item_output .= apply_filters('the_title', $item->title, $item->ID); if ($depth == 0) $item_output .= art_option('menu.topItemEnd'); $item_output .= '</a>'; $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); } function end_el(&$output, $item, $depth) { $output .= "</li>\n"; $this->is_active = false; } } /* pages */ function art_get_list_pages($args = array()) { global $wp_query; $pages = &get_pages($args); $IdToKey = array(); $currentID = null; foreach ($pages as $key => $page) { $IdToKey[$page->ID] = $key; } if ($wp_query->is_page) { $currentID = $wp_query->get_queried_object_id(); } $frontID = null; $blogID = null; if ('page' == get_option('show_on_front')) { $frontID = get_option('page_on_front'); if ($frontID && isset($IdToKey[$frontID])) { $frontKey = $IdToKey[$frontID]; $frontPage = $pages[$frontKey]; unset($pages[$frontKey]); $frontPage->post_parent = '0'; $frontPage->menu_order = '0'; array_unshift($pages, $frontPage); $IdToKey = array(); foreach ($pages as $key => $page) { $IdToKey[$page->ID] = $key; } } if (is_home()) { $blogID = get_option('page_for_posts'); if ($blogID && isset($IdToKey[$blogID])) { $currentID = $blogID; } } } $activeIDs = array(); $activeID = $currentID; while($activeID && isset($IdToKey[$activeID])) { $activeIDs[] = $activeID; $activePage = $pages[$IdToKey[$activeID]]; if ($activePage && $activePage->post_status == 'private') { break; } $activeID = $activePage->post_parent; } $result = ''; if (art_option('menu.showHome') && ('page' != get_option('show_on_front') || (!get_option('page_on_front') && !get_option('page_for_posts')))) { $result = '<li><a' . (is_home() ? ' class="active"' : '') . ' href="' . get_option('home') . '">' .art_option('menu.topItemBegin') . art_option('menu.homeCaption') .art_option('menu.topItemEnd') . '</a></li>'; } if (!empty($pages)) { $walker = new art_PageWalker('list', 'ul', $activeIDs, $frontID); $result .= $walker->walk($pages,$args['depth'], array(), $currentID); } return $result; } class art_PageWalker extends Walker { var $db_fields = array('parent' => 'post_parent', 'id' => 'ID'); var $activeIDs = array(); var $frontID = array(); var $is_active = false; function art_PageWalker($type='list', $tag='ul', $activeIDs=array(), $frontID=null){ $this->tag = $tag; $this->activeIDs = $activeIDs; $this->frontID = $frontID; $this->type = $type; } function start_lvl(&$output) { $output .= "\n<".$this->tag; if($this->is_active){ $output .= ' class="active" '; } $output .= ">\n"; $this->is_active = false; } function end_lvl(&$output) { $output .= "</".$this->tag.">\n"; } function start_el(&$output, $page, $depth, $args, $current_page) { $active = in_array($page->ID, $this->activeIDs); $output .= '<li'; if ($active) { $this->is_active = true; $output .= ' class="active" '; } $output .= '><a'; if ($active) { $output .= ' class="active"'; } $href = get_page_link($page->ID); if ($this->frontID && $this->frontID == $page->ID) { $href = get_option('home'); } $title = apply_filters( 'the_title', $page->post_title, $page->ID ); $output .= ' href="'.$href.'" title="'.attribute_escape($title).'">'; if ($depth == 0) $output .= art_option('menu.topItemBegin'); $output .= $title; if ($depth == 0) $output .= art_option('menu.topItemEnd'); $output .= '</a>'; } function end_el(&$output, $page) { $output .= "</li>\n"; $this->is_active = false; } } /* categories */ function art_get_list_categories($args = array()) { global $wp_query; $categories = &get_categories($args); $IdToKey = array(); foreach ($categories as $key => $category){ $IdToKey[$category->term_id] = $key; } $currentID = null; if ($wp_query->is_category) { $currentID = $wp_query->get_queried_object_id(); } $activeID = $currentID; $activeIDs = array(); while ($activeID && isset($IdToKey[$activeID])) { $activeIDs[] = $activeID; $activeCategory = $categories[$IdToKey[$activeID]]; $activeID = $activeCategory->parent; } $result = ''; if (!empty($categories)) { $walker = new art_CategoryWalker('list','ul', $activeIDs); $result .= $walker->walk($categories, $args['depth'], array('count' => false, 'current_category' =>$currentID)); } return $result; } class art_CategoryWalker extends Walker { var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); var $activeIDs = array(); var $is_active = false; function art_CategoryWalker($type='list', $tag='ul', $activeIDs=array()){ $this->tag = $tag; $this->activeIDs = $activeIDs; $this->type = $type; } function start_lvl(&$output){ $output .= "\n<".$this->tag; if ($this->is_active) { $output .= ' class="active" '; } $output .= ">\n"; $this->is_active = false; } function end_lvl(&$output) { $output .= "</".$this->tag.">\n"; } function start_el(&$output, $category, $depth, $args) { $count = intval($category->count); $count_text = sprintf(__('%s posts', THEME_NS), $count); $active = in_array($category->term_id, $this->activeIDs); $output .= '<li'; if ($active) { $this->is_active = true; $output .= ' class="active" '; } $output .= '>'; if ($category->description) { $title = $category->description; } else { $title = $count_text; } $output .= '<a'; if ($active) { $output .= ' class="active"'; } $output .= ' href="'.get_category_link($category->term_id).'" title="'.$title.'">'; if ($depth == 0) $output .= art_option('menu.topItemBegin'); $output .= attribute_escape($category->name); if ($depth == 0) $output .= art_option('menu.topItemEnd'); $output .= '</a>'; } function end_el(&$output, $page) { $output .= "</li>\n"; $this->is_active = false; } } This the line... Code: [Select] $output .= ' class="1" '; // This line..... How could I set the class to the page number - So for example if page 1 then background is blue, if its 5 then its green etc... I want to set up the css but I need to assign the class to the page number.... (Or parent page number if the page number is not top level..) Any ideas? Similar TutorialsHi,
I'm having the following problem. I want to change the row color depending on the value of a record.
i made three different td class in the style.
Then i check the value of the record "TOEGEZEGD" and connect this to $NewClass,
The i try to change the color of the background.
$NewClass takes the value i want (check by display echo $NewClass)
But the background of the row doesn't change, i tried different methodes:
<td class = "$NewClass">'.$row['TOEGEZEGD'].'</td> <td class = \"$New$Class\">'.$row['VORM'].'</td> <td><DIV CLASS="$NewClass">'.$row['PAKKET'].'</DIV></td> But non of them work please help, it's driving my crazy <?php // checking for started session function is_session_started() { if ( php_sapi_name() !== 'cli' ) { if ( version_compare(phpversion(), '5.4.0', '>=') ) { return session_status() === PHP_SESSION_ACTIVE ? TRUE : FALSE; } else { return session_id() === '' ? FALSE : TRUE; } } return FALSE; } if ( is_session_started() === FALSE ) session_start(); if(isset($_SESSION ['ingelogd']) AND $_SESSION['ingelogd'] == 1) {} else { header("location:index.php"); exit; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>**********</title> <meta name="" content=""> </head> <body> <style> textarea, input, button, a, td, span{ font-family: "Trebuchet MS", Helvetica, sans-serif; } td{ color: blue; width: 100px; background-color: #ceffce; height: 50px; text-align: center; } td.JA{ color: red; width: 100px; background-color: #00ee00; height: 50px; text-align: left; } .JA{ color: red; width: 100px; background-color: #00ee00; height: 50px; text-align: left; } td.NEE{ color: green; width: 100px; background-color: #ff0000; height: 50px; text-align: left; } td.MISSCHIEN{ color: orange; width: 100px; background-color: #f07700; height: 50px; text-align: left; } td.op{ color: black; width: 450px; background-color: #ceDDce!important; height: 50px; text-align: left; } th{ color: black; width: 40px; background-color: #cecece; height: 50px; text-align: center; } th.op{ color: black; width: 450px; background-color: #cecece; height: 50px; text-align: center; } .a{ height: 25%; cursor: pointer; } button{ width: 100%; height: 100%; margin: -5 auto -5 auto; } textarea { height: 100%; width: 100%; } .verwijder{ width: 10px; height: auto; background-color: #ffa8a8; } .space{ width: 20px; height: auto; } .invoegen{ background-color: #6dbbdc; width: 1434px; padding: 5px; margin: 5px; } .content{ background-color: #FFDD67; width: 1500px; ; padding: 0 5 0 5; margin: 0 5 0 5; } .content table{ margin-bottom: 100px; } span{ text-decoration: underline; } select{ height: 90%; } </style> <div class="content"> <?php mysql_connect("localhost", "************", "*********") or die(mysql_error()); mysql_select_db("*********"); $sql = "SELECT ID, NAAM, CONTACT, TOEGEZEGD, bestuur1, bestuur2, bestuur3, bestuur4, bestuur5, VORM, PAKKET, KANGEFACTUREERD, GEFACTUREERD, AANTAL, POST, OPMERKING FROM `sponsoren` ORDER BY $field $sort"; $result = mysql_query($sql) or die(mysql_error()); echo'<table>'; while($row = mysql_fetch_array($result)) { $BESTUUR1 = $row['bestuur1']; $BESTUUR2 = $row['bestuur2']; $BESTUUR3 = $row['bestuur3']; $BESTUUR4 = $row['bestuur4']; $BESTUUR5 = $row['bestuur5']; if ($row['TOEGEZEGD'] == 'ja') { $NewClass = "JA" ; } elseif ($row['TOEGEZEGD'] == 'nee') { $NewClass = "NEE"; } elseif ($row['TOEGEZEGD'] == 'misschien') { $NewClass = "MISSCHIEN"; } echo $NewClass; echo'<tr> <td><a href="full_table_row_results.php?ID='.$row['ID'].'">'.$row['ID'].'</a></td> <td>'.$row['NAAM'].'</td> <td>'.$row['CONTACT'].'</td> <td >'; if($BESTUUR1 == 1){ echo "<div class='item'><label>Kk</label></div>"; }; if($BESTUUR2 == 1){ echo "<div class='item'><label>Rutger</label></div>"; }; if($BESTUUR3 == 1){ echo "<div class='item'><label>Toby</label></div>"; }; if($BESTUUR4 == 1){ echo "<div class='item'><label>Meijke</label></div>"; }; if($BESTUUR5 == 1){ echo "<div class='item'><label>Boele</label></div>"; }"</td>"; echo'<td class = "$NewClass">'.$row['TOEGEZEGD'].'</td> <td class = \"$New$Class\">'.$row['VORM'].'</td> <td><DIV CLASS="$NewClass">'.$row['PAKKET'].'</DIV></td> <td>'.$row['KANGEFACTUREERD'].'</td> <td>'.$row['GEFACTUREERD'].'</td> <td>'.$row['AANTAL'].'</td> <td>'.$row['POST'].'</td> <td class = "op">'.$row['OPMERKING'].'</td>'; echo'</tr>'; } echo'</table>'; ?> </div> </body> </html> Hi, I have the following code to change font color from within an IF staement but I can't seem to sort it out. //code if ($server['b']['ip'] == $adminarray1[6] && $server['b']['c_port'] == $adminarray2[6] && $player['name'] == $adminarray3[6]) { $player['name'] = "<font color='blue'>{$server['p'][$key]['name']}</font>"; } //code any help would be greatly appreciated. -Dodge I need a button in php to change my background color every 5 presses with a random one, every five presses the color have to change once and need to stay for the next 5 presses. here is my code <head>
<title>click 5 times</title> hi all, in my blog (made by me, no wordpress or similar) i would want to change the color of comments written by author of article My code is: $sql = "SELECT author WHERE art_id=..."; //print all comments... while ($row = mysql_fetch_array($result)) { if ($_SESSION['ID_user'] == $sql['ID_user'] ) { $color = "#FFFFFF"; } else { $color = "#FF0000"; } echo '<div id="comment" style="background-color: ' . $color . '">post</div>'; } but the code above print all FFFFFF or all FF0000 Where it is wrong? thanks I have a method that is returning a funny variable, it should be returning what is below and when I echo the return from inside the method it is right. Code: [Select] Software/Section but when I goto echo the from outside the class I get the following. It adds a back slash Code: [Select] Software//Section this is the method code and it works fine when I echo the returnValue the value is right Code: [Select] // Creates a dymamic case statement for making a the choice // inside and array foreach (scandir($dir) as $folderItem) { if ($folderItem != "." AND $folderItem != "..") { if (is_dir($dir.$folderItem.DIRECTORY_SEPARATOR)) { $folderItem = $folderItem ; // this allows the the dir to be placed if statements below $folderContents = $this->showPage( $dir.$folderItem ,$getPageGlobal , $subdir); $subdir = ""; // this resets so that ithe value does not get added to main links; } else { // put into if into array if($getPageGlobal== $folderItem) { $pageReturn = $dir . $folderItem; } } } } echo $pageReturn.'<br>'; return $pageReturn; This is the way I am echoing the class. This is when it decides to add the back slash Code: [Select] echo $dynamicMenu->getShowPage(); Hi, I've making a script that's almost a todo list, and i want to have 3 colors to the posts. Post under 7 days old should be green, and thoose older then 7 days yellow and over 14 days should be red. How could i do that? Every post i timestamp when stored in my MYSQL table. Here is my code: Code: [Select] <?php $servername='localhost'; $dbusername='root'; $dbpassword=''; $dbname='store'; connecttodb($servername,$dbname,$dbusername,$dbpassword); function connecttodb($servername,$dbname,$dbuser,$dbpassword) { global $link; $link=mysql_connect ("$servername","$dbuser","$dbpassword"); if(!$link){die("Could not connect to MySQL");} mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error()); } $result = mysql_query("SELECT * FROM henvendelser ORDER by id desc ") or die(mysql_error()); echo "<table cellspacing='12px' cellpaddomg='5px' align='center'>"; echo "<tr> <th>ID</th> <th> Opprettet </th> <th>Navn</th> <th>Telefon</th> <th>Emne</th> </tr>"; while($row = mysql_fetch_array( $result )) { echo "<tr> <td>"; echo $row['id']; echo "</td> <td>"; echo date("d.m.y", strtotime($row["date"])); echo "</td> <td>"; echo "<a href=\"detaljer.php?view=$row[id]\">$row[Navn]</a>"; echo "</td> <td>"; echo $row['Telefon']; echo "</td> <td>"; echo $row['Emne']; echo "</td> </tr>"; } echo "</table>"; ?> Hello I want to be able to change the class depending on if a variable is 1 or 0. <html> <p class="note-general"> This is the general </p> <p class="note-warning"> And this is the warning </p> </html> I want the variable $adult (that can be 1 or 0) to set if the class should be a note-general or note-warning. Thank you for support Hi php freaks i am new to php im doin a small project to handle tickets created by customers now i want to change the font color based on the status for example: ID + Name + Product + Status ------------------------------------------------------------------------------------------------------------------------------------ 1111 + abcdef + bat + processing ----------------+--------------------------------------+------------------------------------------+------------------------------ i can connect to database and fetch it the only place i need help is changing the any help would be very helpful thanks in advance Hi,
I have the following submit button and would like to change it into a link with a class.
<input type="image" alt="Click here to Continue" name="I2" src="altimages/buttons/continue.gif" id="submit">How would I do this using jQuery? Thanks! I have mysqli object in Database class base: [color=]database class:[/color] class Database { private $dbLink = null; public function __construct() { if (is_null($this->dbLink)) { // load db information to connect $init_array = parse_ini_file("../init.ini.inc", true); $this->dbLink = new mysqli($init_array['database']['host'], $init_array['database']['usr'], $init_array['database']['pwd'], $init_array['database']['db']); if (mysqli_connect_errno()) { $this->dbLink = null; } } } public function __destruct() { $this->dbLink->close(); } } Class derived is Articles where I use object dBLink in base (or parent) class and I can't access to mysqli methods (dbLink member of base class): Articles class: require_once ('./includes/db.inc'); class Articles extends Database{ private $id, .... .... $visible = null; public function __construct() { // Set date as 2009-07-08 07:35:00 $this->lastUpdDate = date('Y-m-d H:i:s'); $this->creationDate = date('Y-m-d H:i:s'); } // Setter .... .... // Getter .... .... public function getArticlesByPosition($numArticles) { if ($result = $this->dbLink->query('SELECT * FROM articles ORDER BY position LIMIT '.$numArticles)) { $i = 0; while ($ret = $result->fetch_array(MYSQLI_ASSOC)) { $arts[$i] = $ret; } $result->close(); return $arts; } } } In my front page php I use article class: include_once('./includes/articles.inc'); $articlesObj = new articles(); $articles = $articlesObj->getArticlesByPosition(1); var_dump($articles); [color=]Error that go out is follow[/color] Notice: Undefined property: Articles::$dbLink in articles.inc on line 89 Fatal error: Call to a member function query() on a non-object in articles.inc on line 89 If I remove constructor on derived class Articles result don't change Please help me If a class has a constructor but also has a static method, if I call the static method does the constructor run so that I can use an output from the constructor in my static method? --Kenoli Ok. I know you can pass the object of a class as an argument. Example: class A { function test() { echo "This is TEST from class A"; } } class B { function __construct( $obj ) { $this->a = $obj; } function test() { $this->a->test(); } } Then you could do: $a = new A(); $b = new B($a); Ok so that's one way i know of. I also thought that you could make a method static, and do this: (assuming class A's test is 'static') class B { function test() { A::test(); } } But that is not working. I'd like to know all possible ways of accomplishing this. Any hints are appreciated. thanks Hi Can you call Class A's methods or properties from Class B's methods? Thanks. I have an existing instance of my class Database, now I want to call that instance in my Session class, how would I go about doing this? Hi, I need to be able to call a class based on variables. E.G. I would normally do: Code: [Select] $action = new pattern1() but i would like to be able to do it dynamicaly: Code: [Select] $patNum = 1; $action = new pattern.$patNum.() Im wondering if that's possible? If so what would the correct syntax be? Many Thanks. Hi people! class FirstOne{ public function FunctionOne($FirstInput){ //do stuff and output value return $value1; } } Then:- class SecondOne{ public function FunctionTwo($AnotherInput){ //do stuff and output value return $value2; } } What I want to know is this, if I want to use FunctionOne() in Class SecondOne do I do it like this:- (Assume as I have instantiated the first class using $Test = new FirstOne(); ) class SecondOne{ function SecondedFunction(){ global $Test; return $Test->FunctionOne(); } public function FunctionTwo($AnotherInput){ //do stuff and output value return $value2; } public function FunctionThree(){ //some code here $this->Test->SecondedFunction();<--I think as I can omit the $this-> reference } } My point is: Do I have to do it this way or is there way of having this done through __construct() that would negate the need for a third party function? I have a version working, I just think that it is a little convoluted in the way as I have done it, so I thought I would ask you guys. Any help/advice is appreciated. Cheers Rw I have two classes: ## Admin.php <?php class Admin { public function __construct() { include("Config.php"); } /** * deletes a client * @returns true or false */ function deleteClient($id) { return mysql_query("DELETE FROM usernames WHERE id = '$id'"); } } ?> ## Projects.php <?php class Projects { public function __construct() { include("Config.php"); $this->admin = $admin; $this->dataFolder = $dataFolder; } /** * Deletes a project * @returns true or false */ function deleteProject($id) { $root = $_SERVER['DOCUMENT_ROOT']; $theDir = $root . $this->dataFolder; $sql = mysql_query("SELECT * FROM projectData WHERE proj_id = '$id'"); while ($row = mysql_fetch_array($sql)) { $mainFile = $row['path']; $thumb = $row['thumbnail']; if ($thumb != 'null') { unlink($theDir . "/" . substr($thumb,13)); } unlink($theDir . "/" . substr($mainFile,13)); } $delete = mysql_query("DELETE FROM projectData WHERE proj_id = '$id'"); $getDir = mysql_query("SELECT proj_path FROM projects WHERE id = '$id'"); $res = mysql_fetch_array($getDir); rmdir($theDir . "/" . $res['proj_path']); return mysql_query("DELETE FROM projects WHERE id = '$id'"); } } ?> How can I call deleteProject() from within Admin.php? Hello everyone! I need a little help to get functions names from the GD library. first i want to say i have a little knowledge with GD library like create image with words and etc. So , what i'm trying to do is to take image and than take the color of the first pixel on the top left than do some function work and than set this pixel on the top left to another color. now , i know how the algorithm should look like , i just don't know what function i need to use to: take specific pixel color from the image set new color for pixel on specific place i'll be glad if you could help me with that , regards , Mor. Hi all, I have two classes. Registration and Connection. Inside a registration.php I include my header.php, which then includes my connection.php... So all the classes should be declared when the page is loaded. This is my code: registration.php: <?php include ('assets/header.php'); ?> <?php class registration{ public $fields = array("username", "email", "password"); public $data = array(); public $table = "users"; public $dateTime = ""; public $datePos = 0; public $dateEntryName = "date"; function timeStamp(){ return($this->dateTime = date("Y-m-d H:i:s")); } function insertRow($data, $table){ foreach($this->fields as $key => $value){ mysql_query("INSERT INTO graphs ($this->fields) VALUES ('$data[$key]')"); } mysql_close($connection->connect); } function validateFields(){ $connection = new connection(); $connection->connect(); foreach($this->fields as $key => $value){ array_push($this->data, $_POST[$this->fields[$key]]); } $this->dateTime = $this->timeStamp(); array_unshift($this->data, $this->dateTime); array_unshift($this->fields, $this->dateEntryName); foreach($this->data as $value){ echo "$value"; } $this->insertRow($this->data, $this->table); } } $registration = new registration(); $registration->validateFields(); ?> <?php include ('assets/footer.php'); ?> At this point I cannot find my connection class defined on another included/included page. $connection = new connection(); $connection->connect; config.php (included within header.php) <? class connection{ public $dbname = '**'; public $dbHost = '**'; public $dbUser = '**'; public $dbPass = '**'; public $connect; function connect(){ $this->connect = mysql_connect($this->dbHost, $this->dbUser, $this->dbPass) or die ('Error connecting to mysql'); mysql_select_db($this->dbname, $this->connect); } } ?> Any ideas how to call it properly? |