PHP - Change Post Author Color
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 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> 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? Hello I'm new to the forum, I need your help. I want to make a review place. but i have a problem. The name of the logged in user does not appear in the comment. can you examine the code and help me. user registration, login, done everything. this is my only problem. I tried everything, it didn't work. or I'm new. I just started. I don't know php very well.but I think I've come here so well: D <?php session_start(); include('header.php'); include_once("db_connect.php"); ?> <script src="rating.js"></script> <script type="text/javascript" src="script/ajax.js"></script> <link rel="stylesheet" href="style.css"> <?php include('container.php');?> <div class="container"> // User Register Sign Place <div class="collapse navbar-collapse" id="navbar1"> <ul class="nav navbar-nav navbar-left"> <?php if (isset($_SESSION['user_id'])) { ?> <li><p class="navbar-text"><strong>Welcome!</strong> You're signed in as <strong><?php echo $_SESSION['user_name']; ?></strong></p></li> <li><a href="logout.php">Log Out</a></li> <?php } else { ?> <li><a href="login.php">Login</a></li> <li><a href="register.php">Sign Up</a></li> <?php } ?> </ul> </div> </div> // Rating Star Place <?php include_once("db_connect.php"); $ratingDetails = "SELECT ratingNumber FROM item_rating"; $rateResult = mysqli_query($conn, $ratingDetails) or die("database error:". mysqli_error($conn)); $ratingNumber = 0; $count = 0; $fiveStarRating = 0; $fourStarRating = 0; $threeStarRating = 0; $twoStarRating = 0; $oneStarRating = 0; while($rate = mysqli_fetch_assoc($rateResult)) { $ratingNumber+= $rate['ratingNumber']; $count += 1; if($rate['ratingNumber'] == 5) { $fiveStarRating +=1; } else if($rate['ratingNumber'] == 4) { $fourStarRating +=1; } else if($rate['ratingNumber'] == 3) { $threeStarRating +=1; } else if($rate['ratingNumber'] == 2) { $twoStarRating +=1; } else if($rate['ratingNumber'] == 1) { $oneStarRating +=1; } } $average = 0; if($ratingNumber && $count) { $average = $ratingNumber/$count; } ?> <br> // Rating Details <div id="ratingDetails"> <div class="row"> <div class="col-sm-3"> <h4>Rating and Reviews</h4> <h2 class="bold padding-bottom-7"><?php printf('%.1f', $average); ?> <small>/ 5</small></h2> <?php $averageRating = round($average, 0); for ($i = 1; $i <= 5; $i++) { $ratingClass = "btn-default btn-grey"; if($i <= $averageRating) { $ratingClass = "btn-warning"; } ?> <button type="button" class="btn btn-sm <?php echo $ratingClass; ?>" aria-label="Left Align"> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> </button> <?php } ?> </div> <div class="col-sm-3"> <?php $fiveStarRatingPercent = round(($fiveStarRating/5)*100); $fiveStarRatingPercent = !empty($fiveStarRatingPercent)?$fiveStarRatingPercent.'%':'0%'; $fourStarRatingPercent = round(($fourStarRating/5)*100); $fourStarRatingPercent = !empty($fourStarRatingPercent)?$fourStarRatingPercent.'%':'0%'; $threeStarRatingPercent = round(($threeStarRating/5)*100); $threeStarRatingPercent = !empty($threeStarRatingPercent)?$threeStarRatingPercent.'%':'0%'; $twoStarRatingPercent = round(($twoStarRating/5)*100); $twoStarRatingPercent = !empty($twoStarRatingPercent)?$twoStarRatingPercent.'%':'0%'; $oneStarRatingPercent = round(($oneStarRating/5)*100); $oneStarRatingPercent = !empty($oneStarRatingPercent)?$oneStarRatingPercent.'%':'0%'; ?> <div class="pull-left"> <div class="pull-left" style="width:35px; line-height:1;"> <div style="height:9px; margin:5px 0;">5 <span class="glyphicon glyphicon-star"></span></div> </div> <div class="pull-left" style="width:180px;"> <div class="progress" style="height:9px; margin:8px 0;"> <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="5" aria-valuemin="0" aria-valuemax="5" style="width: <?php echo $fiveStarRatingPercent; ?>"> <span class="sr-only"><?php echo $fiveStarRatingPercent; ?></span> </div> </div> </div> <div class="pull-right" style="margin-left:10px;"><?php echo $fiveStarRating; ?></div> </div> <div class="pull-left"> <div class="pull-left" style="width:35px; line-height:1;"> <div style="height:9px; margin:5px 0;">4 <span class="glyphicon glyphicon-star"></span></div> </div> <div class="pull-left" style="width:180px;"> <div class="progress" style="height:9px; margin:8px 0;"> <div class="progress-bar progress-bar-primary" role="progressbar" aria-valuenow="4" aria-valuemin="0" aria-valuemax="5" style="width: <?php echo $fourStarRatingPercent; ?>"> <span class="sr-only"><?php echo $fourStarRatingPercent; ?></span> </div> </div> </div> <div class="pull-right" style="margin-left:10px;"><?php echo $fourStarRating; ?></div> </div> <div class="pull-left"> <div class="pull-left" style="width:35px; line-height:1;"> <div style="height:9px; margin:5px 0;">3 <span class="glyphicon glyphicon-star"></span></div> </div> <div class="pull-left" style="width:180px;"> <div class="progress" style="height:9px; margin:8px 0;"> <div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="3" aria-valuemin="0" aria-valuemax="5" style="width: <?php echo $threeStarRatingPercent; ?>"> <span class="sr-only"><?php echo $threeStarRatingPercent; ?></span> </div> </div> </div> <div class="pull-right" style="margin-left:10px;"><?php echo $threeStarRating; ?></div> </div> <div class="pull-left"> <div class="pull-left" style="width:35px; line-height:1;"> <div style="height:9px; margin:5px 0;">2 <span class="glyphicon glyphicon-star"></span></div> </div> <div class="pull-left" style="width:180px;"> <div class="progress" style="height:9px; margin:8px 0;"> <div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="2" aria-valuemin="0" aria-valuemax="5" style="width: <?php echo $twoStarRatingPercent; ?>"> <span class="sr-only"><?php echo $twoStarRatingPercent; ?></span> </div> </div> </div> <div class="pull-right" style="margin-left:10px;"><?php echo $twoStarRating; ?></div> </div> <div class="pull-left"> <div class="pull-left" style="width:35px; line-height:1;"> <div style="height:9px; margin:5px 0;">1 <span class="glyphicon glyphicon-star"></span></div> </div> <div class="pull-left" style="width:180px;"> <div class="progress" style="height:9px; margin:8px 0;"> <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="1" aria-valuemin="0" aria-valuemax="5" style="width: <?php echo $oneStarRatingPercent; ?>"> <span class="sr-only"><?php echo $oneStarRatingPercent; ?></span> </div> </div> </div> <div class="pull-right" style="margin-left:10px;"><?php echo $oneStarRating; ?></div> </div> </div> <div class="col-sm-3"> <button type="button" id="rateProduct" class="btn btn-default">Rate this product</button> </div> </div> <div class="row"> <div class="col-sm-7"> <hr/> // Review Place <div class="review-block"> <?php $ratinguery = "SELECT ratingId, itemId, userId, ratingNumber, title, comments, created, modified FROM item_rating"; $ratingResult = mysqli_query($conn, $ratinguery) or die("database error:". mysqli_error($conn)); while($rating = mysqli_fetch_assoc($ratingResult)){ $date=date_create($rating['created']); $reviewDate = date_format($date,"M d, Y"); ?> <div class="row"> <div class="col-sm-3"> <img src="image/profile.png" class="img-rounded"> <div class="review-block-name">By <a href="#">phpcode</a></div> <div class="review-block-date"><?php echo $reviewDate; ?></div> </div> <div class="col-sm-9"> <div class="review-block-rate"> <?php for ($i = 1; $i <= 5; $i++) { $ratingClass = "btn-default btn-grey"; if($i <= $rating['ratingNumber']) { $ratingClass = "btn-warning"; } ?> <button type="button" class="btn btn-xs <?php echo $ratingClass; ?>" aria-label="Left Align"> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> </button> <?php } ?> </div> <div class="review-block-title"><?php echo $rating['title']; ?></div> <div class="review-block-description"><?php echo $rating['comments']; ?></div> </div> </div> <hr/> <?php } ?> </div> </div> </div> </div> <div id="ratingSection" style="display:none;"> <div class="row"> <div class="col-sm-12"> <form id="ratingForm" method="POST"> <div class="form-group"> <h4>Rate this product</h4> <button type="button" class="btn btn-warning btn-sm rateButton" aria-label="Left Align"> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> </button> <button type="button" class="btn btn-default btn-grey btn-sm rateButton" aria-label="Left Align"> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> </button> <button type="button" class="btn btn-default btn-grey btn-sm rateButton" aria-label="Left Align"> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> </button> <button type="button" class="btn btn-default btn-grey btn-sm rateButton" aria-label="Left Align"> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> </button> <button type="button" class="btn btn-default btn-grey btn-sm rateButton" aria-label="Left Align"> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> </button> <input type="hidden" class="form-control" id="rating" name="rating" value="1"> <input type="hidden" class="form-control" id="itemId" name="itemId" value="12345678"> </div> <div class="form-group"> <label for="usr">Title*</label> <input type="text" class="form-control" id="title" name="title" required> </div> <div class="form-group"> <label for="comment">Comment*</label> <textarea class="form-control" rows="5" id="comment" name="comment" required></textarea> </div> <?php if (isset($_SESSION['user_id'])) { ?> <div class="form-group"> <button type="submit" class="btn btn-info" id="saveReview">Save Review</button> <button type="button" class="btn btn-info" id="cancelReview">Cancel</button> </div> <?php } else { ?> <div class="well" style="margin-top: 20px;"> <h4 class="text-center"><a href="login.php">Sign in</a> to post a comment</h4> </div> <?php } ?> </form> </div> </div> </div> </div> <?php include('footer.php');?> in this line of code <div class="row"> <div class="col-sm-3"> <img src="image/profile.png" class="img-rounded"> <div class="review-block-name">By <a href="#">phpcode</a></div> <div class="review-block-date"><?php echo $reviewDate; ?></div> </div> How can I show the name of the user logging in this field? <div class="review-block-name">By <a href="#">phpcode</a></div> she will comment and her name will appear. When someone else logs in, if they comment in the same way, their name will appear. Whatever I tried did not happen. Can you help me ? Â Â
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, 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>"; ?> Im trying to create a website where users login, and then when they add a new entry to the database there name is put as the author. This is how my tables are set up. One table is named job and has the columns id, jobtext, jobdate, and authorid. Another table is called author. This table contains the columns id, username, password, and name. Authorid from the job table matches with id from the author table. When a user logins in this code is used to register the name...session_start(); $_SESSION['myusername'] = $_POST['myusername']; $_SESSION['mypassword'] = $_POST['mypassword']; header("location: index.php"); } else { echo "Wrong Username or Password"; } This is the form users use to add a new entry... if (isset($_GET['add'])) { $pagetitle = 'New Job'; $action = 'addform'; $text = ''; $authorid = ''; $id = ''; $button = 'Add job'; include $_SERVER['DOCUMENT_ROOT'] . '/jobs/includes/db.inc.php'; // Build the list of authors $sql = "SELECT id, name FROM author"; $result = mysqli_query($link, $sql); if (!$result) { $error = 'Error fetching list of authors.'; include 'error.html.php'; exit(); } while ($row = mysqli_fetch_array($result)) { $authors[] = array('id' => $row['id'], 'name' => $row['name']); } // Build the list of categories $sql = "SELECT id, name FROM category"; $result = mysqli_query($link, $sql); if (!$result) { $error = 'Error fetching list of categories.'; include 'error.html.php'; exit(); } while ($row = mysqli_fetch_array($result)) { $categories[] = array( 'id' => $row['id'], 'name' => $row['name'], 'selected' => FALSE); } include 'form.html.php'; exit(); } if (isset($_GET['addform'])) { include $_SERVER['DOCUMENT_ROOT'] . '/includes/db.inc.php'; $text = mysqli_real_escape_string($link, $_POST['text']); $author = mysqli_real_escape_string($link, $_POST['author']); if ($author == '') { $error = 'You must choose an author for this job. Click ‘back’ and try again.'; include 'error.html.php'; exit(); } $sql = "INSERT INTO job SET jobtext='$text', jobdate=CURDATE(), authorid='$author'"; if (!mysqli_query($link, $sql)) { $error = 'Error adding submitted job.'; include 'error.html.php'; exit(); } $jobid = mysqli_insert_id($link); if (isset($_POST['categories'])) { foreach ($_POST['categories'] as $category) { $categoryid = mysqli_real_escape_string($link, $category); $sql = "INSERT INTO jobcategory SET jobid='$jobid', categoryid='$categoryid'"; if (!mysqli_query($link, $sql)) { $error = 'Error inserting job into selected category.'; include 'error.html.php'; exit(); } } } header('Location: .'); exit(); } Form.html.php = <?php include_once $_SERVER['DOCUMENT_ROOT'] . '/includes/helpers.inc.php'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title><?php htmlout($pagetitle); ?></title> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <style type="text/css"> textarea { display: block; width: 100%; } </style> </head> <body> <?php session_start(); ?> <h1><?php htmlout($pagetitle); ?></h1> <form action="?<?php htmlout($action); ?>" method="post"> <div> <label for="text">Type your job he </label> <textarea id="text" name="text" rows="3" cols="40"><?php htmlout($text); ?></textarea> </div> <div> <label for="author">Author:</label> <select name="author" id="author"> <option value="">Select one</option> <?php foreach ($authors as $author):?> <option value="<?php htmlout($author['id']); ?>"<?php if ($author['id'] == $authorid) echo ' selected="selected"'; ?>><?php htmlout($author['name']); ?></option> <?php endforeach; ?> </select> </div> <fieldset> <legend>Categories:</legend> <?php foreach ($categories as $category): ?> <div><label for="category<?php htmlout($category['id']); ?>"><input type="checkbox" name="categories[]" id="category<?php htmlout($category['id']); ?>" value="<?php htmlout($category['id']); ?>"<?php if ($category['selected']) { echo ' checked="checked"'; } ?>/><?php htmlout($category['name']); ?></label></div> <?php endforeach; ?> </fieldset> <div> <input type="hidden" name="id" value="<?php htmlout($id); ?>"/> <input type="submit" value="<?php htmlout($button); ?>"/> </div> </form> </body> </html> Right now, under authors, it displays all the authors in the database. I want it to just show/submit the authorid of the logged in user. This topic has been moved to Application Frameworks. http://www.phpfreaks.com/forums/index.php?topic=355562.0 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 Hey Guys. I am working with a form that shows the grand total on the checkout page. The value of the grand total is inside a hidden field. When click on submit, the _POST array doesn't get back the last value of the grand total. I need to hit the button twice to get the last value. The weird thing is when I echo the value of the grand total it display the latest value, but not with the POST array
For example. If the grand total is $10.00 and I click on submit. It will show the POST['grand_total'] as empty. If I click on submit again it will show the grand total of $10.00.
Below is my code that I am working with. Any help would be really appreciated.
if(isset($_POST['submit'])) { /* Doesn't show if i put it after if($_POST['submit'] */ if(isset($_POST['grand_total'])) { echo $_POST['grand_total']; } } //A bunch of other html/php code. Another class calculates the subtotal assigns it the variable $subtotal $cart_totals = new cartTotals($subtotal, $discounted_amount,$post_values->tip); // Cart class is shown below /* Doesn't show if i put it before if($_POST['submit'] */ if(isset($_POST['grand_total'])) { echo $_POST['grand_total']; } echo "<input name='grand_total' type='hidden' value='$cart_totals->grand_total' />"; // Shows the grand total after second from submission echo "$cart_totals->grand_total"; // Shows grand total after the first submissionCart Totals Class class cartTotals { public $subtotal; public $sales_tax; public $tip; public $grand_total; public $discount_amount; public $href_page; public $invalidCouponMessage; const TEST_ENVIORMENT = FALSE; /** * [ Function gets constructed in the order summary where the [$discount_amount= ""] arg does need to be passed. * But does get passed in when called on the checkout.php page. Therefore we set the default value to an empty string.] * @param [float] $subtotal [subtotal get passed in from the parent class coreCartFunction] * @param string $discount_amount [The class checkCouponCode calculates this discount amount based on the * subtotal and the discount amount. It gets instantiated on the clients side and passed is this construction function. * This is all done on the checkout page.] */ /*The way the construct function works is by invoking all the methods the passed arguments When the methods get invoked the do all the work and set the properties its values. The properties then get echoed out on the client side. */ function __construct($subtotal="", $discount_amount= "", $tip=""){ $this->subTotal($subtotal, $discount_amount);//SubTotal method takes the discount amount and subtracts it from the subtotal. $this->salesTax($subtotal, $discount_amount); $this->tip = $tip; $this->grandTotal(); } private function subTotal($subtotal,$discount_amount) { $rounded_subtotal = round($subtotal-$discount_amount,2); $money_format_subtotal = money_format('%i',$rounded_subtotal); $this->subtotal = $money_format_subtotal; } private function salesTax($subtotal, $discount_amount =""){ $sales_tax = (STORE_SALES_TAX)?(float)STORE_SALES_TAX:8.875; $sales_tax =(($this->subtotal)*$sales_tax)/100; $sales_tax = round($sales_tax,2); $this->sales_tax = $sales_tax; } public function Tip() { //global $post_values; //$last_tip_selected = $post_values->tip > 0 ? $post_values->tip : "" ; $tip_output = "<select id='tip' name='tip'>"; for($tip=0.00; $tip<=11.75; $tip+=0.25){ if( $tip == "2") {$selected = " selected";} else {$selected ="";} $formatted_tip = money_format('%i',$tip); $tip_output .= "<option {$selected} id='selected_tip' value='$formatted_tip'>"."$".$formatted_tip ."</option>".PHP_EOL; } $tip_output .= "</select>"; return $tip_output; } private function grandTotal(){ $grand_total = round($this->sales_tax+$this->subtotal+$this->tip,2); $grand_total_formatted = money_format('%i',$grand_total); $this->grand_total = $grand_total_formatted; } $post='{"cart_items":[{"configuration":{"price":100,"recharge_number":"9999999999"},"product_id":"999","qty":1}]}';i try this n reslut was :There are no valid items in cart: help me plz Edited by ShivaGupta, 30 November 2014 - 01:11 AM. Hi, Â I have a series of post to post connections. In one function, the output is a list of the linked post to posts. Here is an example: function countryJob(){ global $post;
   $echo = f_print(array(    echo '<div class="country-job-text">'.$echo.'</div>';  job, location and city are all post types that can be connected.  I want to create the same as above to create a list of the cites connected to a location (locations are the name for posts which are countries)  How do I discover the connection type and post type needed to create this output? I'm learning PHP, and in the course of this, I'm writing a little app which posts to the same php file. HOWEVER, when I run the app again, the POST values remain. I can use unset() but, is there another way to clear POST data? RON ok i want to be able to delete the post only if there the one who posted aka blabbed here is the script , please help. if im not clear please tell me! Code: [Select] <?php // Start_session, check if user is logged in or not, and connect to the database all in one included file include_once("scripts/checkuserlog.php"); if (!$_SESSION['idx']) { $msgToUser = '<br /><br /><font color="#FF0000">Sorry but you must be logged in to view this page!</font><p><br><div align="right"><a href="register.php">Join Here</a></div><form id="signinform" action="login.php" method="post" enctype="multipart/form-data" name="signinform"> <fieldset> <legend>Log in</legend> <label for="login">Email</label> <input type="text" id="email" name="email" /> <div class="clear"></div> <label for="password">Password</label> <input type="password" id="password" name="pass" /> <div class="clear"></div> <label for="remember_me" style="padding: 0;">Remember me?</label> <input type="checkbox" id="remember" style="position: relative; top: 3px; margin: 0; " name="remember"/ value="yes" checked="checked"> <div class="clear"></div> <br /> <input type="submit" style="margin: -20px 0 0 287px;" class="button" name="commit" value="Sign In"/> </fieldset> </form></p>'; include_once 'msgToUser.php'; exit(); } else if ($logOptions_id != $_SESSION['id']) { $msgToUser = '<br /><br /><font color="#FF0000">Only site members can do that</font><p><a href="register.php">Join Here</a></p>'; include_once 'msgToUser.php'; exit(); } // Include the class files for auto making links out of full URLs and for Time Ago date formatting include_once("wi_class_files/autoMakeLinks.php"); include_once ("wi_class_files/agoTimeFormat.php"); // Create the two new objects before we can use them below in this script $activeLinkObject = new autoActiveLink; $myObject = new convertToAgo; ?> <?php // ------- INITIALIZE SOME VARIABLES --------- // they must be initialized in some server environments or else errors will get thrown $id = ""; $username = ""; $firstname = ""; $lastname = ""; $mainNameLine = ""; $country = ""; $state = ""; $city = ""; $zip = ""; $bio_body = ""; $website = ""; $youtube = ""; $facebook = ""; $twitter = ""; $twitterWidget = ""; $locationInfo = ""; $user_pic = ""; $blabberDisplayList = ""; $interactionBox = ""; $cacheBuster = rand(999999999,9999999999999); // Put on an image URL will help always show new when changed // ------- END INITIALIZE SOME VARIABLES --------- // ------- ESTABLISH THE PAGE ID ACCORDING TO CONDITIONS --------- if (isset($_GET['id'])) { $id = preg_replace('#[^0-9]#i', '', $_GET['id']); // filter everything but numbers } else if (isset($_SESSION['idx'])) { $id = $logOptions_id; } else { header("location: index.php"); exit(); } // ------- END ESTABLISH THE PAGE ID ACCORDING TO CONDITIONS --------- // ------- FILTER THE ID AND QUERY THE DATABASE -------- $id = preg_replace('#[^0-9]#i', '', $id); // filter everything but numbers on the ID just in case $sql = mysql_query("SELECT * FROM myMembers WHERE id='$id' LIMIT 1"); // query the member // ------- FILTER THE ID AND QUERY THE DATABASE -------- // ------- MAKE SURE PERSON EXISTS IN DATABASE --------- $existCount = mysql_num_rows($sql); // count the row nums if ($existCount == 0) { // evaluate the count header("location: index.php?msg=user_does_not_exist"); exit(); } // ------- END MAKE SURE PERSON EXISTS IN DATABASE --------- // ------- WHILE LOOP FOR GETTING THE MEMBER DATA --------- while($row = mysql_fetch_array($sql)){ $username = $row["username"]; $firstname = $row["firstname"]; $lastname = $row["lastname"]; $country = $row["country"]; $state = $row["state"]; $city = $row["city"]; $sign_up_date = $row["sign_up_date"]; $sign_up_date = strftime("%b %d, %Y", strtotime($sign_up_date)); $last_log_date = $row["last_log_date"]; $last_log_date = strftime("%b %d, %Y", strtotime($last_log_date)); $bio_body = $row["bio_body"]; $bio_body = str_replace("'", "'", $bio_body); $bio_body = stripslashes($bio_body); $website = $row["website"]; $youtube = $row["youtube"]; $facebook = $row["facebook"]; $twitter = $row["twitter"]; $friend_array = $row["friend_array"]; /////// Mechanism to Display Pic. See if they have uploaded a pic or not ////////////////////////// $check_pic = "members/$id/image01.jpg"; $default_pic = "members/0/image01.jpg"; if (file_exists($check_pic)) { $user_pic = "<img src=\"$check_pic?$cacheBuster\" width=\"218px\" />"; } else { $user_pic = "<img src=\"$default_pic\" width=\"218px\" />"; } /////// Mechanism to Display Real Name Next to Username - real name(username) ////////////////////////// if ($firstname != "") { $mainNameLine = "$firstname $lastname ($username)"; $username = $firstname; } else { $mainNameLine = $username; } /////// Mechanism to Display Youtube channel link or not ////////////////////////// if ($youtube == "") { $youtube = ""; } else { $youtube = '<br /><br /><img src="images/youtubeIcon.jpg" width="18" height="12" alt="Youtube Channel for ' . $username . '" /> <strong>YouTube Channel:</strong><br /><a href="http://www.youtube.com/user/' . $youtube . '" target="_blank">youtube.com/' . $youtube . '</a>'; } /////// Mechanism to Display Facebook Profile link or not ////////////////////////// if ($facebook == "") { $facebook = ""; } else { $facebook = '<br /><br /><img src="images/facebookIcon.jpg" width="18" height="12" alt="Facebook Profile for ' . $username . '" /> <strong>Facebook Profile:</strong><br /><a href="http://www.facebook.com/profile.php?id=' . $facebook . '" target="_blank">profile.php?id=' . $facebook . '</a>'; } /////// Mechanism to Display Twitter Tweet Widget or not ////////////////////////// if ($twitter == "") { $twitterWidget = ""; } else { $twitterWidget = "<script src=\"http://widgets.twimg.com/j/2/widget.js\"></script> <script> new TWTR.Widget({ version: 2, type: 'profile', rpp: 5, interval: 6000, width: 218, height: 160, theme: { shell: { background: '#BDF', color: '#000000' }, tweets: { background: '#ffffff', color: '#000000', links: '#0066FF', } }, features: { scrollbar: true, loop: false, live: false, hashtags: true, timestamp: true, avatars: false, behavior: 'all' } }).render().setUser('$twitter').start(); </script>"; } /////// Mechanism to Display Website URL or not ////////////////////////// if ($website == "") { $website = ""; } else { $website = '<br /><br /><img src="images/websiteIcon.jpg" width="18" height="12" alt="Website URL for ' . $username . '" /> <strong>Website:</strong><br /><a href="http://' . $website . '" target="_blank">' . $website . '</a>'; } /////// Mechanism to Display About me text or not ////////////////////////// if ($bio_body == "") { $bio_body = ""; } else { $bio_body = '<div class="infoBody">' . $bio_body . '</div>'; } /////// Mechanism to Display Location Info or not ////////////////////////// if ($country == "" && $state == "" && $city == "") { $locationInfo = ""; } else { $locationInfo = "$city · $state<br />$country ".'<a href="#" onclick="return false" onmousedown="javascript:toggleViewMap(\'google_map\');">view map</a>'; } } // close while loop // ------- END WHILE LOOP FOR GETTING THE MEMBER DATA --------- // ------- POST NEW BLAB TO DATABASE --------- $blab_outout_msg = ""; if (isset($_POST['blab_field']) && $_POST['blab_field'] != "" && $_POST['blab_field'] != " "){ $blabWipit = $_POST['blabWipit']; $sessWipit = base64_decode($_SESSION['wipit']); if (!isset($_SESSION['wipit'])) { } else if ($blabWipit == $sessWipit) { // Delete any blabs over 50 for this member $sqlDeleteBlabs = mysql_query("SELECT * FROM blabbing WHERE mem_id='$id' ORDER BY blab_date DESC LIMIT 50"); $bi = 1; while ($row = mysql_fetch_array($sqlDeleteBlabs)) { $blad_id = $row["id"]; if ($bi > 20) { $deleteBlabs = mysql_query("DELETE FROM blabbing WHERE id='$blad_id'"); } $bi++; } // End Delete any blabs over 20 for this member $blab_field = $_POST['blab_field']; $blab_field = stripslashes($blab_field); $blab_field = strip_tags($blab_field); $blab_field = mysql_real_escape_string($blab_field); $blab_field = str_replace("'", "'", $blab_field); $sql = mysql_query("INSERT INTO blabbing (mem_id, the_blab, blab_date) VALUES('$id','$blab_field', now())") or die (mysql_error()); $blab_outout_msg = ""; } } // ------- END POST NEW BLAB TO DATABASE --------- // ------- MEMBER BLABS OUTPUT CONSTRUCTION --------- /////// Mechanism to Display Pic if (file_exists($check_pic)) { $blab_pic = '<div style="overflow:hidden; height:40px;"><a href="profile.php?id=' . $id . '"><img src="' . $check_pic . '" width="40px" border="0" /></a></div>'; } else { $blab_pic = '<div style="overflow:hidden; height:40px;"><a href="profile.php?id=' . $id . '"><img src="' . $default_pic . '" width="40px" border="0" /></a></div>'; } /////// END Mechanism to Display Pic $sql_blabs = mysql_query("SELECT id, mem_id, the_blab, blab_date FROM blabbing WHERE mem_id='$id' ORDER BY blab_date DESC LIMIT 20"); while($row = mysql_fetch_array($sql_blabs)){ $blabid = $row["id"]; $uid = $row["mem_id"]; $the_blab = $row["the_blab"]; $the_blab = ($activeLinkObject -> makeActiveLink($the_blab)); $blab_date = $row["blab_date"]; $convertedTime = ($myObject -> convert_datetime($blab_date)); $whenBlab = ($myObject -> makeAgo($convertedTime)); $blabberDisplayList .= ' <table style="background-color:#FFF; border:#999 1px solid; border-top:none;" cellpadding="5" width="100%"> <tr> <td width="10%" valign="top">' . $blab_pic . '</td> <td width="90%" valign="top" style="line-height:1.5em;"><span class="greenColor textsize10">' . $whenBlab . ' <a href="profile.php?id=' . $uid . '">' . $username . '</a> said:</span><br /> ' . $the_blab . '</td> </tr></table>'; } // ------- END MEMBER BLABS OUTPUT CONSTRUCTION --------- // ------- ESTABLISH THE PROFILE INTERACTION TOKEN --------- $thisRandNum = rand(9999999999999,999999999999999999); $_SESSION['wipit'] = base64_encode($thisRandNum); // Will always overwrite itself each time this script runs // ------- END ESTABLISH THE PROFILE INTERACTION TOKEN --------- // ------- EVALUATE WHAT CONTENT TO PLACE IN THE MEMBER INTERACTION BOX ------------------- // initialize some output variables $friendLink = ""; $the_blab_form = ""; if (isset($_SESSION['idx']) && $logOptions_id != $id) { // If SESSION idx is set, AND it does not equal the profile owner's ID // SQL Query the friend array for the logged in viewer of this profile if not the owner $sqlArray = mysql_query("SELECT friend_array FROM myMembers WHERE id='" . $logOptions_id ."' LIMIT 1"); while($row=mysql_fetch_array($sqlArray)) { $iFriend_array = $row["friend_array"]; } $iFriend_array = explode(",", $iFriend_array); if (in_array($id, $iFriend_array)) { $friendLink = '<a href="#" onclick="return false" onmousedown="javascript:toggleInteractContainers(\'remove_friend\');">Remove Friend</a>'; } else { $friendLink = '<a href="#" onclick="return false" onmousedown="javascript:toggleInteractContainers(\'add_friend\');">Add as Friend</a>'; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $interactionBox = '<br /><br /><div class="interactionLinksDiv"> ' . $friendLink . ' <a href="#" onclick="return false" onmousedown="javascript:toggleInteractContainers(\'private_message\');">Private Message</a> </div><br />'; $the_blab_form = '<div style="background-color:#BDF; border:#999 1px solid; padding:8px;"> <textarea name="blab_field" rows="3" style="width:99%;"></textarea> <strong>Write on ' . $username . '\'s Board (coming soon)</strong> </div>'; } else if (isset($_SESSION['idx']) && $logOptions_id == $id) { // If SESSION idx is set, AND it does equal the profile owner's ID $interactionBox = '<br /><br /><div class="interactionLinksDiv"> <a href="#" onclick="return false" onmousedown="javascript:toggleInteractContainers(\'friend_requests\');">Friend Requests</a> </div><br />'; $the_blab_form = ' ' . $blab_outout_msg . ' <div style="background-color:#BDF; border:#999 1px solid; padding:8px;"> <form action="profile.php" method="post" enctype="multipart/form-data" name="blab_from"> <textarea name="blab_field" rows="3" style="width:99%;"></textarea> <input name="blabWipit" type="hidden" value="' . $thisRandNum . '" /> <strong>Blab away ' . $username . '</strong> (220 char max) <input name="submit" type="submit" value="Blab" /> <div align="right"> </form></div>'; } else { // If no SESSION id is set, which means we have a person who is not logged in $interactionBox = '<div style="border:#CCC 1px solid; padding:5px; background-color:#E4E4E4; color:#999; font-size:11px;"> <a href="register.php">Sign Up</a> or <a href="login.php">Log In</a> to interact with ' . $username . ' </div>'; $the_blab_form = '<div style="background-color:#BDF; border:#999 1px solid; padding:8px;"> <textarea name="blab_field" rows="3" style="width:99%;"></textarea> <a href="register.php">Sign Up</a> or <a href="login.php">Log In</a> to write on ' . $username . '\'s Board </div>'; } // ------- END EVALUATE WHAT CONTENT TO PLACE IN THE MEMBER INTERACTION BOX ------------------- // ------- POPULATE FRIEND DISPLAY LISTS IF THEY HAVE AT LEAST ONE FRIEND ------------------- $friendList = ""; $friendPopBoxList = ""; if ($friend_array != "") { // ASSEMBLE FRIEND LIST AND LINKS TO VIEW UP TO 6 ON PROFILE $friendArray = explode(",", $friend_array); $friendCount = count($friendArray); $friendArray6 = array_slice($friendArray, 0, 6); $friendList .= '<div class="infoHeader">' . $username . '\'s Friends (<a href="#" onclick="return false" onmousedown="javascript:toggleViewAllFriends(\'view_all_friends\');">' . $friendCount . '</a>)</div>'; $i = 0; // create a varible that will tell us how many items we looped over $friendList .= '<div class="infoBody" style="border-bottom:#666 1px solid;"><table id="friendTable" align="center" cellspacing="4"></tr>'; foreach ($friendArray6 as $key => $value) { $i++; // increment $i by one each loop pass $check_pic = 'members/' . $value . '/image01.jpg'; if (file_exists($check_pic)) { $frnd_pic = '<a href="profile.php?id=' . $value . '"><img src="' . $check_pic . '" width="54px" border="1"/></a>'; } else { $frnd_pic = '<a href="profile.php?id=' . $value . '"><img src="members/0/image01.jpg" width="54px" border="1"/></a> '; } $sqlName = mysql_query("SELECT username, firstname FROM myMembers WHERE id='$value' LIMIT 1") or die ("Sorry we had a mysql error!"); while ($row = mysql_fetch_array($sqlName)) { $friendUserName = substr($row["username"],0,12); $friendFirstName = substr($row["firstname"],0,12);} if (!$friendUserName) {$friendUserName = $friendFirstName;} // If username is blank use the firstname... programming changes in v1.32 call for this if ($i % 6 == 4){ $friendList .= '<tr><td><div style="width:56px; height:68px; overflow:hidden;" title="' . $friendUserName . '"> <a href="profile.php?id=' . $value . '">' . $friendUserName . '</a><br />' . $frnd_pic . ' </div></td>'; } else { $friendList .= '<td><div style="width:56px; height:68px; overflow:hidden;" title="' . $friendUserName . '"> <a href="profile.php?id=' . $value . '">' . $friendUserName . '</a><br />' . $frnd_pic . ' </div></td>'; } } $friendList .= '</tr></table> <div align="right"><a href="#" onclick="return false" onmousedown="javascript:toggleViewAllFriends(\'view_all_friends\');">view all</a></div> </div>'; // END ASSEMBLE FRIEND LIST... TO VIEW UP TO 6 ON PROFILE // ASSEMBLE FRIEND LIST AND LINKS TO VIEW ALL(50 for now until we paginate the array) $i = 0; $friendArray50 = array_slice($friendArray, 0, 50); $friendPopBoxList = '<table id="friendPopBoxTable" width="100%" align="center" cellpadding="6" cellspacing="0">'; foreach ($friendArray50 as $key => $value) { $i++; // increment $i by one each loop pass $check_pic = 'members/' . $value . '/image01.jpg'; if (file_exists($check_pic)) { $frnd_pic = '<a href="profile.php?id=' . $value . '"><img src="' . $check_pic . '" width="54px" border="1"/></a>'; } else { $frnd_pic = '<a href="profile.php?id=' . $value . '"><img src="members/0/image01.jpg" width="54px" border="1"/></a> '; } $sqlName = mysql_query("SELECT username, firstname, country, state, city FROM myMembers WHERE id='$value' LIMIT 1") or die ("Sorry we had a mysql error!"); while ($row = mysql_fetch_array($sqlName)) { $funame = $row["username"]; $ffname = $row["firstname"]; $fcountry = $row["country"]; $fstate = $row["state"]; $fcity = $row["city"]; } if (!$funame) {$funame = $ffname;} // If username is blank use the firstname... programming changes in v1.32 call for this if ($i % 2) { $friendPopBoxList .= '<tr bgcolor="#F4F4F4"><td width="14%" valign="top"> <div style="width:56px; height:56px; overflow:hidden;" title="' . $funame . '">' . $frnd_pic . '</div></td> <td width="86%" valign="top"><a href="profile.php?id=' . $value . '">' . $funame . '</a><br /><font size="-2"><em>' . $fcity . '<br />' . $fstate . '<br />' . $fcountry . '</em></font></td> </tr>'; } else { $friendPopBoxList .= '<tr bgcolor="#E0E0E0"><td width="14%" valign="top"> <div style="width:56px; height:56px; overflow:hidden;" title="' . $funame . '">' . $frnd_pic . '</div></td> <td width="86%" valign="top"><a href="profile.php?id=' . $value . '">' . $funame . '</a><br /><font size="-2"><em>' . $fcity . '<br />' . $fstate . '<br />' . $fcountry . '</em></font></td> </tr>'; } } $friendPopBoxList .= '</table>'; // END ASSEMBLE FRIEND LIST AND LINKS TO VIEW ALL(50 for now until we paginate the array) } // ------- END POPULATE FRIEND DISPLAY LISTS IF THEY HAVE AT LEAST ONE FRIEND ------------------- ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="Description" content="Profile for <?php echo "$username"; ?>" /> <meta name="Keywords" content="<?php echo "$username, $city, $state, $country"; ?>" /> <meta name="rating" content="General" /> <meta name="ROBOTS" content="All" /> <title>Site Profile for <?php echo "$username"; ?></title> <link href="style/main.css" rel="stylesheet" type="text/css" /> <link rel="icon" href="favicon.png" type="image/x-icon" /> <link rel="shortcut icon" href="favicon.png" type="image/x-icon" /> <script src="js/jquery-1.4.2.js" type="text/javascript"></script> <style type="text/css"> <!-- .infoHeader { background-color: #BDF; font-size:11px; font-weight:bold; padding:8px; border: #999 1px solid; border-bottom:none; width:200px; } .infoBody{ background-color: #FFF; font-size:11px; padding:8px; border: #999 1px solid; border-bottom:none; width:200px; } /* ------- Interaction Links Class -------- */ .interactionLinksDiv a { border:#B9B9B9 1px solid; padding:5px; color:#060; font-size:11px; background-image:url(style/headerBtnsBG.jpg); text-decoration:none; } .interactionLinksDiv a:hover { border:#090 1px solid; padding:5px; color:#060; font-size:11px; background-image:url(style/headerBtnsBGover.jpg); } /* ------- Interaction Containers Class -------- */ .interactContainers { padding:8px; background-color:#BDF; border:#999 1px solid; display:none; } #add_friend_loader { display:none; } #remove_friend_loader { display:none; } #interactionResults { display:none; font-size:16px; padding:8px; } #friendTable td{ font-size:9px; } #friendTable td a{ color:#03C; text-decoration:none; } #view_all_friends { background-image:url(style/opaqueDark.png); width:270px; padding:20px; position:fixed; top:150px; display:none; z-index:100; margin-left:50px; } #google_map { background-image:url(style/opaqueDark.png); padding:20px; position:fixed; top:150px; display:none; z-index:100; margin-left:50px; } --> </style> <script language="javascript" type="text/javascript"> // jQuery functionality for toggling member interaction containers function toggleInteractContainers(x) { if ($('#'+x).is(":hidden")) { $('#'+x).slideDown(200); } else { $('#'+x).hide(); } $('.interactContainers').hide(); } function toggleViewAllFriends(x) { if ($('#'+x).is(":hidden")) { $('#'+x).fadeIn(200); } else { $('#'+x).fadeOut(200); } } function toggleViewMap(x) { if ($('#'+x).is(":hidden")) { $('#'+x).fadeIn(200); } else { $('#'+x).fadeOut(200); } } // Friend adding and accepting stuff var thisRandNum = "<?php echo $thisRandNum; ?>"; var friendRequestURL = "scripts_for_profile/request_as_friend.php"; function addAsFriend(a,b) { $("#add_friend_loader").show(); $.post(friendRequestURL,{ request: "requestFriendship", mem1: a, mem2: b, thisWipit: thisRandNum } ,function(data) { $("#add_friend").html(data).show().fadeOut(12000); }); } function acceptFriendRequest (x) { $.post(friendRequestURL,{ request: "acceptFriend", reqID: x, thisWipit: thisRandNum } ,function(data) { $("#req"+x).html(data).show(); }); } function denyFriendRequest (x) { $.post(friendRequestURL,{ request: "denyFriend", reqID: x, thisWipit: thisRandNum } ,function(data) { $("#req"+x).html(data).show(); }); } // End Friend adding and accepting stuff // Friend removal stuff function removeAsFriend(a,b) { $("#remove_friend_loader").show(); $.post(friendRequestURL,{ request: "removeFriendship", mem1: a, mem2: b, thisWipit: thisRandNum } ,function(data) { $("#remove_friend").html(data).show().fadeOut(12000); }); } // End Friend removal stuff // Start Private Messaging stuff $('#pmForm').submit(function(){$('input[type=submit]', this).attr('disabled', 'disabled');}); function sendPM ( ) { var pmSubject = $("#pmSubject"); var pmTextArea = $("#pmTextArea"); var sendername = $("#pm_sender_name"); var senderid = $("#pm_sender_id"); var recName = $("#pm_rec_name"); var recID = $("#pm_rec_id"); var pm_wipit = $("#pmWipit"); var url = "scripts_for_profile/private_msg_parse.php"; if (pmSubject.val() == "") { $("#interactionResults").html('<img src="images/round_error.png" alt="Error" width="31" height="30" /> Please type a subject.').show().fadeOut(6000); } else if (pmTextArea.val() == "") { $("#interactionResults").html('<img src="images/round_error.png" alt="Error" width="31" height="30" /> Please type in your message.').show().fadeOut(6000); } else { $("#pmFormProcessGif").show(); $.post(url,{ subject: pmSubject.val(), message: pmTextArea.val(), senderName: sendername.val(), senderID: senderid.val(), rcpntName: recName.val(), rcpntID: recID.val(), thisWipit: pm_wipit.val() } , function(data) { $('#private_message').slideUp("fast"); $("#interactionResults").html(data).show().fadeOut(10000); document.pmForm.pmTextArea.value=''; document.pmForm.pmSubject.value=''; $("#pmFormProcessGif").hide(); }); } } // End Private Messaging stuff </script> </head> <body> <?php include_once "header_template.php"; ?> <table class="mainBodyTable" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="738" valign="top"><br /> <table width="98%" border="0" align="center" cellpadding="6"> <tr> <td width="33%" valign="top"> <?php echo $user_pic; ?> <?php echo $bio_body; ?> <div class="infoHeader"><?php echo $username; ?>'s Information</div> <div class="infoBody"> <?php echo $locationInfo; ?> <?php echo $website; ?> <?php echo $youtube; ?> <?php echo $facebook; ?> </div> <?php echo $friendList; ?> <div id="view_all_friends"> <div align="right" style="padding:6px; background-color:#FFF; border-bottom:#666 1px solid;"> <div style="display:inline; font-size:14px; font-weight:bold; margin-right:150px;">All Friends</div> <a href="#" onclick="return false" onmousedown="javascript:toggleViewAllFriends('view_all_friends');">close </a> </div> <div style="background-color:#FFF; height:240px; overflow:auto;"> <?php echo $friendPopBoxList; ?> </div> <div style="padding:6px; background-color:#000; border-top:#666 1px solid; font-size:10px; color: #0F0;"> Temporary programming shows 50 maximum. Navigating through the full list is coming soon. </div> </div> <?php echo $twitterWidget; ?> <div class="infoBody" style="border-bottom:#999 1px solid;"><?php include_once("ad_200_square.php"); ?></div> </td> <td width="67%" valign="top"> <span style="font-size:16px; font-weight:800;"><?php echo $mainNameLine; ?></span> <?php echo $interactionBox; ?> <div class="interactContainers" id="add_friend"> <div align="right"><a href="#" onclick="return false" onmousedown="javascript:toggleInteractContainers('add_friend');">cancel</a> </div> Add <?php echo "$username"; ?> as a friend? <a href="#" onclick="return false" onmousedown="javascript:addAsFriend(<?php echo $logOptions_id; ?>, <?php echo $id; ?>);">Yes</a> <span id="add_friend_loader"><img src="images/loading.gif" width="28" height="10" alt="Loading" /></span> </div> <div class="interactContainers" id="remove_friend"> <div align="right"><a href="#" onclick="return false" onmousedown="javascript:toggleInteractContainers('remove_friend');">cancel</a> </div> Remove <?php echo "$username"; ?> from your friend list? <a href="#" onclick="return false" onmousedown="javascript:removeAsFriend(<?php echo $logOptions_id; ?>, <?php echo $id; ?>);">Yes</a> <span id="remove_friend_loader"><img src="images/loading.gif" width="28" height="10" alt="Loading" /></span> </div> <!-- START DIV that serves as an interaction status and results container that only appears when we instruct it to --> <div id="interactionResults" style="font-size:15px; padding:10px;"></div> <!-- END DIV that serves as an interaction status and results container that only appears when we instruct it to --> <!-- START DIV that contains the Private Message form --> <div class="interactContainers" id="private_message"> <form action="javascript:sendPM();" name="pmForm" id="pmForm" method="post"> <font size="+1">Sending Private Message to <strong><em><?php echo "$username"; ?></em></strong></font><br /><br /> Subject: <input name="pmSubject" id="pmSubject" type="text" maxlength="64" style="width:98%;" /> Message: <textarea name="pmTextArea" id="pmTextArea" rows="8" style="width:98%;"></textarea> <input name="pm_sender_id" id="pm_sender_id" type="hidden" value="<?php echo $_SESSION['id']; ?>" /> <input name="pm_sender_name" id="pm_sender_name" type="hidden" value="<?php echo $_SESSION['username']; ?>" /> <input name="pm_rec_id" id="pm_rec_id" type="hidden" value="<?php echo $id; ?>" /> <input name="pm_rec_name" id="pm_rec_name" type="hidden" value="<?php echo $username; ?>" /> <input name="pmWipit" id="pmWipit" type="hidden" value="<?php echo $thisRandNum; ?>" /> <span id="PMStatus" style="color:#F00;"></span> <br /><input name="pmSubmit" type="submit" value="Submit" /> or <a href="#" onclick="return false" onmousedown="javascript:toggleInteractContainers('private_message');">Close</a> <span id="pmFormProcessGif" style="display:none;"><img src="images/loading.gif" width="28" height="10" alt="Loading" /></span></form> </div> <!-- END DIV that contains the Private Message form --> &n 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. im trying to get a row color coded by a $var that is pulled from mysql. if $val = yes the <tr> = green else red im only concerned with the table row color atm. the rest of the code is still wip relavent section of code <tr bgcolor= <?php "$bgc"; ?>> // this is were i want the $var placed <td> <?php echo $rows['sku'] ; ?></td> <td> <?php echo $rows['rsku']; ?></td> <td> <?php echo $rows['make']; ?></td> <td> <?php echo $rows['model']; ?></td> <td> <?php echo $rows['comments']; ?></td> <td> <?php echo $rows['sound']; ?></td> <td> <?php echo $rows['gfx']; ?></td> <td> <?php echo $rows['recovery']; ?></td> <td> <?php echo $rows['date']; ?></td> <td> <?php echo $rows['valby']; ?></td> <td width="41" align="center"><a href="update.php?id=<?php echo $rows['id']; ?>">update</a></td> <td width="36" align="center"><a href="delete_ac.php?id=<?php echo $rows['id']; ?>">delete</a></td> </tr> <?php // table bg colour $choice = strtoupper($rows['gfx']); if($choice == "PASS"){ $bgc = "#7FFF00" ; }else{ $bgc = "#8B8989" ; } } ?> full code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Modify DataBase</title> </head> <body> <p align="center"> </p> <table width="400" border="1" align="center"> <tr> <td TD BGCOLOR="#FF9900"> <?php include("config.php"); // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $tbl_name="dsgi_serval"; // Retrieve data from database $search = trim($_POST['search']); if ($search == '' || $search == ' '){ echo "Search Field is Empty - Please Input an SKU Number!"; die; } else{ $sql="select * from $tbl_name WHERE sku LIKE '%$search%'"; $result=mysql_query($sql) or die (mysql_error()); } ?> </td> </tr> </table> <table width="800" height="72" border="1" align="center" cellpadding="3" cellspacing="0"> <tr> <td width="113" align="center"><strong>Orig SKU</strong></td> <td width="66" align="center"><strong>Recon SKU</strong></td> <td width="90" align="center"><strong>Make</strong></td> <td width="169" align="center"><strong>Model</strong></td> <td width="58" align="center"><strong>comments</strong></td> <td width="161" align="center"><strong>Sound</strong></td> <td width="66" align="center"><strong>Graphics</strong></td> <td width="90" align="center"><strong>Recovery</strong></td> <td width="169" align="center"><strong>Date</strong></td> <td width="58" align="center"><strong>Validated By</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr bgcolor= <?php "$bgc"; ?>> <td> <?php echo $rows['sku'] ; ?></td> <td> <?php echo $rows['rsku']; ?></td> <td> <?php echo $rows['make']; ?></td> <td> <?php echo $rows['model']; ?></td> <td> <?php echo $rows['comments']; ?></td> <td> <?php echo $rows['sound']; ?></td> <td> <?php echo $rows['gfx']; ?></td> <td> <?php echo $rows['recovery']; ?></td> <td> <?php echo $rows['date']; ?></td> <td> <?php echo $rows['valby']; ?></td> <td width="41" align="center"><a href="update.php?id=<?php echo $rows['id']; ?>">update</a></td> <td width="36" align="center"><a href="delete_ac.php?id=<?php echo $rows['id']; ?>">delete</a></td> </tr> <?php // table bg colour $choice = strtoupper($rows['gfx']); if($choice == "PASS"){ $bgc = "#7FFF00" ; }else{ $bgc = "#8B8989" ; } } ?> </table> <p> </p> </body> </html> |