Jump to content

erdem

Members
  • Posts

    33
  • Joined

  • Last visited

    Never

Everything posted by erdem

  1. what do you mean enough information? I gave you my entire codes:)) I gave you the database structure. what else would you like to know?
  2. al of these shows me mysql codding I'm asking that how do I display with php? for example -Comment 1 -Replay 1 for Comment 1 -Replay 2 for Comment 1 -Replay 1 for Replay 2 -Comment 2 and so on.....
  3. Hi everyone, I hope I can explain. Please help me for this. any idea or help can safe my life. thanks. I have 3 mysql table (users and categories the others. total is 5). contents, comments, votes. so I pull the content and then comments of the content and then votes for the comments. What I would like to do is answering system for the comments. similar to reddit or youtube comments. my comment table is this CommentsID - ContentsID - UserID - Comment - Time - Parent - WriteIP - Active -TotalVotes - VoteSum Parent come from CommentsID So, this is Hierarchical Data. But i cannot figure out how can I display this. this is my query $Where = array( "ct.ContentsID = '" . $Contents['ContentsID'] . "'" ); if ( $_SESSION['UserID'] == 0 ) $Where[] = "ct.Active = '1'"; else if ( $_SESSION['Level'] < 3 ) $Where[] = "(ct.Active = '1' OR ct.UserID = '" . $_SESSION['UserID'] . "')"; else { $THEME->loadJS( 'Ajax.js' ); $THEME->loadJS( 'Moderate.js' ); } $sql = mysql_query( "SELECT ct.*, ut.*, vt.UserID UserVote FROM comments ct INNER JOIN users ut ON ut.UserID = ct.UserID LEFT JOIN voters vt ON ( vt.CommentsID = ct.CommentsID AND vt.UserID = '" . $_SESSION['UserID'] . "' ) LEFT JOIN comments cp ON ( ct.Parent = cp.CommentsID ) WHERE " . implode( ' AND ', $Where ) . " ORDER BY Time DESC" ); and this is how I display everything if ( !$sql ) echo mysql_error(); if ( mysql_num_rows( $sql ) ) { $Contents = array(); $Count = 0; $LoadVoteJS = false; while ( $ROW = mysql_fetch_array( $sql ) ) { $Status = ''; $WriteTime = $ROW['Time'] > 0 ? date( 'd.m.Y H:i:s', $ROW['Time'] ) : ''; $Content = preg_replace( '/tag:&#8220;([^&]+)&#822[01];/ie', "'<a href=\"/tag/'.tagPointer('\\1').'.html\">\\1</a>'", $ROW['Comment'] ); $Vote = ""; if ( $ROW['Active'] == '0' ) $Status = $_SESSION['Level'] >= 3 ? '<a onClick="MsgOnayla(\'' . $ROW['CommentID'] . '\',this);" style="cursor:pointer">Onayla!</a> <a onClick="MsgSil(\'' . $ROW['CommentID'] . '\',this);" style="cursor:pointer">Sil!</a>' : 'Onay Bekliyor!'; else if ( $_SESSION['Level'] >= 1 ) { if ( is_null( $ROW['UserVote'] ) AND $ROW['UserID'] != $_SESSION['UserID'] ) { $LoadVoteJS = true; $Status = '<span id="voteContent-' . $ROW['CommentID'] . '">[ <a onClick="MsgOyla(\'' . $ROW['CommentID'] . '\',\'1\');" style="cursor:pointer">?yi!</a> | <a onClick="MsgOyla(\'' . $ROW['ContentID'] . '\',\'0\');" style="cursor:pointer">Kötü!</a> ]</span> '; } else if ( $ROW['TotalVotes'] > 0 ) $Vote = "%" . intval( 100 * ( $ROW['VoteSum'] / $ROW['TotalVotes'] ) ); } if ($ROW['Active'] == '1') $Oparation = $_SESSION['Level'] >= 3 ? '<a onClick="MsgSil(\'' . $ROW['CommentID'] . '\',this);" style="cursor:pointer"><img src="/Themes/Standart/Image/delete_content.gif"></a>' : ''; if ($_SESSION['UserID'] != $ROW['UserID']) $Message = $_SESSION['Level'] >= 1 ? '<a href="/Message/?senduser='.$ROW['UserID'].'">Mesaj</a>' : ''; $Name = '<a href="/User/profile.php?id='.$ROW['UserID'].'">'.$ROW['Username'].'</a>'; $Contents[] = t_ContentBox( $Content, $Name, $WriteTime, $Status, $Vote, $Message, $Oparation ); if ( $Count++ == 0 AND $_SESSION['Level'] < 3 ) $Contents[] = t_ContentBanner(); } if ( $LoadVoteJS ) { $THEME->loadJS( 'Ajax.js' ); $THEME->loadJS( 'Vote.js' ); } $_PAGE .= t_commentinfo(mysql_num_rows($sql)); $_PAGE .= t_Contents( implode( t_ContentSeperator(), $Contents ), $CommentForm, $Title ); }
  4. this also very helpful but it won't work in my coding structure. it will but I need to change it. <THEME Name={MenuWrap} VAR={ROW, CONTENT}> <div id="menuwrap"> <div class="menu_section_ac" > <div class="menulevel1hover"> <h2 class="menu"><div id="vegi"> <VAR>ROW['Title']</VAR> </div></h2> </div> <h3 class="menu"><VAR>ROW['Description']</VAR></h3> </div> <div class="menu_container"> <div class="shadow-menu"> </div> <div class="menu-content"> <ul> <VAR>CONTENT</VAR> </ul> </div><!-- #menu-content --> </div> <!-- #menu-container --> </div> <!-- #menuwrap --> </THEME> <THEME Name={MenuContent} Var={ROW,LICLASS}> <li class="<VAR>LICLASS</VAR>"> <h4 class="menu-content"><VAR>ROW['Title']</VAR></h4> <span class="menu-price"><VAR>ROW['Price']</VAR></span> <div style="clear:both; height:0px;"></div> <div class="menu-item-desc"> <p><VAR>ROW['Detail']</VAR></p><br /> </div> </li> </THEME> <?php $sql = mysql_query("SELECT * FROM category WHERE Active='2'"); while($ROW = mysql_fetch_array($sql)){ $_PAGE .= t_MenuWrap($ROW, GetMenuContent($ROW['CategoryID'])); } ?> <?php function GetMenuContent($id){ $sql = mysql_query("SELECT * FROM items WHERE Category = '".$id."' AND Active = '2'"); if(mysql_num_rows($sql)){ while($ROW = mysql_fetch_array($sql)){ $liclass = array('','ac_menu-item', 'menu-item-last'); $data .= t_MenuContent($ROW,$liclass[(((++$r)%2)+1)]); } }else{ $data = "This section is empty!"; } return $data; } ?>
  5. this just worked perfect. thanks so much. I hope one day I can understand these loop stuff and match stuff very well in php. I was trying to figure out this from the morning. also thanks for understanding my terrible English. Thanks so much. so the code is like this <?php function GetMenuContent($id){ $sql = mysql_query("SELECT * FROM items WHERE Category = '".$id."' AND Active = '2'"); if(mysql_num_rows($sql)){ while($ROW = mysql_fetch_array($sql)){ $liclass = array('','ac_menu-item', 'menu-item-last'); $data .= t_MenuContent($ROW,$liclass[(((++$r)%2)+1)]); } }else{ $data = "This section is empty!"; } return $data; } ?>
  6. hi thanks for replay $numrows there cos I tried for loop for my problem but I deleted the loop after I could not figure out. okay I have a CSS design which is restourant menu. the menu itmes come from database. there is a design issue that I need to have dynamic CSS CLASS name <li class="classtop">Item1</li> <li class="classbottom">Item2</li> <li class="classtop">Item3</li> <li class="classbottom">Item4</li> in this example I pull items from database so I have a line which is this <li class="????">$ROW['ItemName']</li> here is class name hast to be "classtop" one time and has to be "classbottom" it should be like this when it turns out to html <li class="classtop">Item1</li> <li class="classbottom">Item2</li> <li class="classtop">Item3</li> <li class="classbottom">Item4</li>
  7. Hi, I have a two different css class needs to be in loop. its <li class="top">Item1</li> <li class="bottom">Item2</li> <li class="top">Item3</li> <li class="bottom">Item4</li> I just can't do this with php. Let's say I have 15 items they goes into this html tags with php using while loop from database. $sql = mysql_query("SELECT * FROM items WHERE Category = '".$id."' AND Active = '2'"); if($numrows = mysql_num_rows($sql)){ while($ROW = mysql_fetch_array($sql)){ $liclass = array('ac_menu-item', 'menu-item-last'); $data .= t_MenuContent($ROW,$liclass); } could you please help me how can I loop these two variables?
  8. Hi everyone. I live in London and I'm making a web site for local kebab shop. people will be able to order online but they want to allow some places in london there are post codes like N1, N2 for zones, then like N12 7AT for the address. a costumer have to give the post code before ordering and I want to calculate distance if is not far away. how is this possible?
  9. hi guys. I hope I can explain. I'm uploading file and I'm inserting some info from the file into mysql. I want to rename the file grater then my latest file ID. so i did this. mysql_query("INSERT INTO replay (ReplayID, Version, Map, GameLenght, TeamSize, Realm, PlayedTime, Location, Uploaded) VALUES (NULL, '".$Version."', '".$Map."', '".$GameLenght."', '".$TeamSize."', '".$Realm."', '".$PlayedTime."', '".$FileName."','".time()."')")or mysql_error(); $FileName = mysql_insert_id().'.SC2Replay'; move_uploaded_file($tmpname,"Replays/" . $FileName); as you can understand in the database Location is empty. how can I do this?
  10. no it comes from a file. Star Craft 2 file. it goes to an array. the replay parsing. http://code.google.com/p/phpsc2replay/wiki/Parseables
  11. Hi, I'm trying to insert some data to mysql database. but I don't know what the MySQL structure should be and how to write it. this is html output. thanks so much. Player name - Race Color - Team - Average APM - Winner? Mike Zerg Red Team 1 156 1 (win) WinD Zerg Blue Team 2 163 0 (lose) and this is the code. $obsString = ""; $obsCount = 0; echo "<table border=\"1\"><tr><th>Player name</th><th>Race</th><th>Color</th><th>Team</th><th>Average APM<br />(experimental)</th><th>Winner?</th></tr>\n"; foreach($players as $value) { if ($value['isObs']) { if ($obsString == "") $obsString = $value['name']; else $obsString .= ', '.$value['name']; $obsCount++; continue; } if ($b->isWinnerKnown()) $wincolor = (isset($value['won']) && $value['won'] == 1)?0x00FF00:0xFF0000; else $wincolor = 0xFFFFFF; if ($value['isComp'] && $b->getTeamSize() !== null) $difficultyString = sprintf(" (%s)",SC2Replay::$difficultyLevels[$value['difficulty']]); else $difficultyString = ""; echo sprintf("<tr><td>%s</td><td>%s</td><td><font color=\"#%s\">%s</font></td><td>%s</td><td style=\"text-align: center\">%d</td><td style=\"background-color: #%06X; text-align: center\">%d</td></tr>\n", $value['name'].$difficultyString, $value['race'], $value['color'], $value['sColor'], ($value['team'] > 0)?"Team ".$value['team']:"-", ($value['team'] > 0)?(round($value['apmtotal'] / ($b->getGameLength() / 60))):0, ((isset($value['won']))?$wincolor:0xFFFFFF), (isset($value['won']))?$value['won']($value['team'] > 0)?"Unknown":"-") ); } echo "</table><br />"; if ($obsCount > 0) { echo "Observers ($obsCount): $obsString<br />\n"; }
  12. form.php <form name="form1" method="post" action="p.php"> <p><input type="submit" value="Enter" /></p> <input name="username" type="text" id="username" size="15" maxlength="35" value="<?php echo $username1; ?>" /> </form> p.php <?php // take the username from the form. $Username = mysql_real_escape_string($_POST['username']); //check if is form sent empty if(!empty($Username)){ // if is not check database if there username tehere $sql = mysql_query("SELECT * FROM users WHERE username='".$Username."'")or mysql_error(); if(mysql_num_rows($sql)){ //if its there delete it $delete = mysql_query("DELETE from users WHERE username='".$Username."'")or mysql_error(); echo "Deleted"; }else{ echo "I can't find the username - ". $Username; } }else{ echo "Form was empty"; } ?> if you want to check the number just put this AND number = '".$Number."'
  13. can you share your database tables and put somewhere mysql_error(); then we may see if mysql gives an error.
  14. Hi everyone. There are two nice script which are advanced for me to understand. There is a Knockout tournament scheduler class that makes image of the bracket. and there is a code that makes html of the bracket with jquery. I want to use the class with jquery. but I don't know how to do that and where to start. the class below needs to implement to this http://whileonefork.blogspot.com/2010/10/jquery-json-to-draw-elimination-single.html I attached the php script. please help me! <?php class KnockoutGD extends Knockout { private $im = null; // GD-lib image resource. private $tc = 0; // Text color. public function getImage($tourName = '') { /* Returns a GD-lib image resource */ // Initial testing. if (empty($this->roundsInfo)) return null; // Dimensional parameters. $fh = imagefontheight(FONT); $fw = imagefontwidth(FONT); $lpad = 30; // Line (branch) padding before and after competitor names and after scores. $hpad = 20; // Outer horizontal image padding. $vpad = 60; // Outer vertical image padding. $lw = $this->getStrLen()*$fw + 3*$lpad; // Line (branch) width. Where getStrLen() gets the length of the longest string used in the image. // Initial calls. $dimensions = $this->getDimens($fh, $lw, $hpad, $vpad); $this->im = imagecreate($dimensions['x'], $dimensions['y']); $bg = imagecolorallocate($this->im, 255, 255, 255); // Set background color. $this->tc = imagecolorallocate($this->im, 0, 0, 0); // Text color. $this->mkStr($dimensions['x'] - $hpad - imagefontwidth(LFONT)*strlen($tourName), $dimensions['y'] - $vpad/2, $tourName, LFONT); // Print tournament name. // Initial positioning values from which drawing begins. $rx = $hpad; // Round X-position. $ry = $vpad; // Round Y-position. $depth = 1; // Branch depth. // Start drawing the tournament bracket/tree. foreach ($this->roundsInfo as $r => $info) { $n = $info[1]; // Number of expected players in round $r. // If a match is no yet created, then a placeholder is made so that the bracket structure is still printable. for ($m = 0; $m <= $n/2 - 1; $m++) { if (!$this->isMatchCreated($m, $r)) { $this->bracket[$r][$m]['c1'] = $this->bracket[$r][$m]['c2'] = null; $this->bracket[$r][$m]['s1'] = $this->bracket[$r][$m]['s2'] = -1; } } // Now we generate round branches. $x = $rx; $y = $ry; $bheight = pow(2, $depth) * $fh; // This is the height of a match-branch, which increases as the tree depth increases. ksort($this->bracket[$r]); foreach ($this->bracket[$r] as $m) { for ($i = 1; $i <= 2; $i++, $y += $bheight) { $this->mkStr($x+$lpad, $y, $m['s'.$i] == -1 ? 'Undecided' : $m['c'.$i]); $this->mkStr($x+$lw-$lpad, $y, $m['s'.$i] == -1 ? '?' : $m['s'.$i]); $this->mkLine($x, $y+$fh, $x+$lw, $y+$fh); } $this->mkLine($x+$lw, ($y+$fh)-$bheight, $x+$lw, ($y+$fh)-2*$bheight); } // Get ready for next loop. $rx += $lw; $ry += $bheight/2; $depth++; } // Add final branch/line for the tournament winner $fr = end(array_keys($this->roundsInfo)); // Final round. $s1 = $this->bracket[$fr][0]['s1']; $s2 = $this->bracket[$fr][0]['s2']; $winner = (!array_key_exists(0, $this->bracket[$fr]) || $s1 == -1 || $s2 == -1 || $s1 === $s2) ? '?' : (($s1 > $s2) ? $this->bracket[$fr][0]['c1'] : $this->bracket[$fr][0]['c2']); $this->mkStr($rx+$lpad, $ry, 'Winner: ' . $winner); $this->mkLine($rx, $ry+$fh, $rx+$lw, $ry+$fh); // Now, we print the round titles. array_push($this->roundsInfo, array('Champion', 1)); // Add fictitious round for printing purposes only. foreach (array_reverse($this->roundsInfo) as $r) { $this->mkStr($rx+$lpad, $vpad/3, $r[0], LFONT); $rx -= $lw; // Move back one round/column. } array_pop($this->roundsInfo); // Remove fictitious round entry again. return $this->im; } private function mkLine($x0, $y0, $x, $y) { /* Wrapper for function that creates a line. */ imageline($this->im, $x0, $y0, $x, $y, $this->tc); } private function mkStr($x, $y, $str, $font = false) { /* Wrapper for function that writes a string. */ imagestring($this->im, $font ? $font : FONT, $x, $y, $str, $this->tc); } private function getDimens($fontHeight, $lineWidth, $horizPad, $vertPad) { /* Returns image dimensions based on the tournament bracket. */ /* Vertically: Each match-branch is outputted like this: Team A ----------- Padding Team B ----------- Padding ... where "Padding" and "Team X" are of height $fontHeight, and "------" are branch lines with approximately no height. Horizontally: Each branch is outputted like this: ----- Team A ------ | ----- Team C ------ | ----- Team B ------ ... where "Team X" branch has an absolute length of $lineWidth. The above therefore illustrates a length of 2*$lineWidth. The image length, $x, must be: $horizPad + number_of_rounds * $lineWidth + $horizPad And the image height, $y, must be: $vertPad + number_of_matches_in_first_round * 4*$fontHeight + $vertPad ... since the first round contains the most matches. */ $frGames = count($this->bracket[1]); // Number of games in the first round. $playInExists = !empty($this->bracket[0]) ? true : false; /* The y-size of the image must be calculated accordingly to the above description. Though, if a play-in round exists, then the play-in round is potentially the round which requires the most vertical space to draw. In this case we scale the image as if the play-in round was the first round. Due to the nature of the tournament bracket, this means that there are twice as many games in that round. */ $y = 2*$vertPad + ($playInExists ? $frGames*2 : $frGames) * 4*$fontHeight; /* The x-size of the image is proportional to the number of rounds in the tournament, where the proportionality constant is the length of a branch, $lineWidth, ie. the width of a round. Since the number of players in the first round is equal to 2^R, where R is a whole number, and denotes the number of rounds required in the tournament, then R = log(players, 2), where "players" also can be found by 2 * matches_in_first_round (2 players pr. match). Like above, if a play-in round exists the x-size of the image must be changed. In this case, we merely add the length of a branch to the total x-size, since all branches are equal in length. Besides that, we add another whole branch length for the Winner/Champion branch, which technically is not a part of the tournament bracket, but is shown anyway. */ $x = 2*$horizPad + (log($frGames*2, 2) + ($playInExists ? 1 : 0) + 1) * $lineWidth; return array('x' => $x, 'y' => $y); } private function getStrLen() { /* Returns the length of longest string used in either rounds. This is done by looking in both play-in round and first round, since all competitors are to be found there. */ $len = 0; foreach (array_merge(array_key_exists(0, $this->bracket) ? $this->bracket[0] : array(), $this->bracket[1]) as $m) { if (($newlen = strlen($m['c1'])) > $len) $len = $newlen; if (($newlen = strlen($m['c2'])) > $len) $len = $newlen; } foreach ($this->roundsInfo as $arr) { if (($newlen = strlen($arr[0])) > $len) $len = $newlen; } return $len; } } ?> 17358_.php 17359_.php
  15. because I like these games and I play them. I need to have some information for making web site about them. step by step, while I develop the web site I may add more games.
  16. yes but this going to be for couple of games. starcraft, fifa, mortal combat, COD but I only have information about starcraft so the web site is going to be for starcraft at first.
  17. hi laffin, Thanks for your help. It helped a lot!! It works. I just want to ask you something. I didn't change your code and I add my mysql codes. How can I change winner. It should come from database. Shouldn't it? How can I change it using a database record? Is there anything you could you say to this. If any suggestion from you. it would be helpful also. Thanks again and happy new year. £ <?php sql = mysql_query("SELECT * FROM tournamenttree WHERE Tournamet = '1'"); $teams = array(); while($ROW = mysql_fetch_assoc($sql)){ $data[]=get_username($ROW['UserID']).','; } $teams = ($data); define('MY_EOL','<br .>'.PHP_EOL); $round=0; $participants=$teams; while(count($participants)>1) { $round++; // Increment our round Echo 'Round '. $round. MY_EOL; $tables=array(); // Clear our tables $index=0; while(count($tables) < floor(count($participants)/2)) // want an even amount of tables $tables[]=array($participants[$index++],$participants[$index++]); if($index<count($participants))// extra team, add to tables, but no opposing team $tables[]=array($participants[$index++],NULL); $participants=array(); // clear out next round participants foreach($tables as $idx=>$table) { $tbl=$idx+1; echo " Table #{$tbl}: "; if($table[1]===NULL) // extra team advances to next level automatically { echo "{$table[0]} Holdover"; $winner=0; } else { echo "{$table[0]} vs. {$table[1]}"; $winner=rand(0,1); // Generate a winner } echo " - Winner {$table[$winner]}". MY_EOL; $participants[]=$table[$winner]; // Add WInnerto next round } } ?>
  18. like a gb for sc2? what do you mean by gb?
  19. i play everyday 2 hours. and I'm making a web site for it. tournaments and ladders and stuff...
  20. dude use cuffon font. these are problems. http://www.cufonfonts.com/
  21. http://php.net/manual/en/language.operators.comparison.php
  22. erdem

    Hello

    make the database structure first. you need to have a users database table than others. then we may help you if you can write some php for that.
  23. this code was an idea. if you have a value and you want to control it you can do like this. just google and find how you can control those strings
×
×
  • Create New...

Important Information

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