PHP - Putting Links Into Table
i'm back again and i am not very good with tables as the <tr> and <td> tags confuse me
i need to put 2 sets of links into 2 columns in the table and they come out jumbled up. Code: [Select] <table> <tr> <th>column 1</th> <th>column 2</th> </tr> <?php $sites = array_map('trim',file('websites.txt')); //read the whole file into an array & trim the newline character from the end of each line foreach ($sites as $link) { echo "<tr><td><a href='$link'>$link</a></td>"; } $sites = array_map('trim',file('websites2.txt')); //read the whole file into an array & trim the newline character from the end of each line foreach ($sites as $link) { echo "<td><a href='$link'>$link</a></td></tr>"; } ?> </table> Similar TutorialsI have a table like this: http://empirebuildingsestate.com/company.html How can I separate the table values into variables so I can insert them into my mySQL database? I have been trying DOMDocument but i need some help. I have a dropdown menu <td width="148" height="35" valign="top"><b>Type: </b> </td> <td><select name ="tabledrop"> <option value="goggles">goggles</option> <option value="headbands">headbands</option> <input type='hidden' id='tabledrop' name='tabledrop' value = ''/> </select> </td> those 2 options are actually names of my tables. I tried this and got some syntax error. $type = $_POST['tabledrop']; $item = $_POST['goggles_name']; $price = $_POST['goggles_price']; $file = $_FILES['goggles_image']['name']; $query = "INSERT into $type SET [$type]_name = '$item' , [$type]_price = '$price' , [$type]_image = '$file'"; Hi Everyone, I'm trying to figure out a way to put my MySql data into a table. I'm close to getting this completed by I'm having some trouble. The data I'm inserting isn't being put into the correct tables. I'm not quite sure what I'm doing wrong. Any help? http://whatsmyowncarworth.com/practice/table.php Code: [Select] <?php include('init.php'); $result = mysql_query("SELECT * FROM info") or die(mysql_error()); echo "<table border='1'>"; echo "<tr> <th>Name</th> <th>Last Name</th> <th>Address</th> <th>City</th> </tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['first_name']; echo "</td><td>"; echo $row['last_name']; echo "</td></tr>"; echo "<tr><td>"; echo $row['address']; echo "</td><td>"; echo $row['city']; echo "</td></tr>"; } echo "</table>"; ?> //First I'm assigning a $variable ($emailzipmatch) to query a database table called(repzipcodes) and having it pull and display 1 to 3 records based on matching up a customer's zip code (RepZipCode = $CustomerZipMatch) with 1 to 3 other people (GROUP BY RepId HAVING COUNT(1) <= 3") that want that customer's information from that particular zip code. <This code works fine> // CODE WORKS BELOW Code: [Select] <?php $emailzipmatch = mysql_query("SELECT * FROM repzipcodes WHERE RepZipCode = $CustomerZipMatch GROUP BY RepId HAVING COUNT(1) <= 3") or die(mysql_error()); $recipients = array(); while($row = mysql_fetch_array($emailzipmatch)) { $recipients[] = $row['RepEmail']; echo "Agent's Email Address: "; echo 'font color="#FF7600"',$row['RepEmail'], '/font'; echo '<br />'; echo "Rep's ID: "; echo '<br />'; echo 'font color="#FF7600"',$row['RepId'], '/font'; echo '<br />'; echo 'hr align="left" width="50%" size="2" /'; } //MY PROBLEM BELOW // For the NEXT step of the process above I would take $row['RepEmail'] and $row['RepId'] which can have 1 to 3 results and assign the 1 to 3 results a new $variable so it can be inserted into a different db table so I can track the results of the query ($emailzipmatch = ) from the top of the page: ie.. <New Variable> <Listed from above> $SentRepId 0 = RepId (results from above echo area) $SentRepId 1 = RepId (results from above echo area) $SentRepId 2 = RepId (results from above echo area) // Below I'd like to insert the above results into a new database $?Variable??? = mysql_query("INSERT INTO sentemail (SentRepId0, SentRepId1, SentRepId2,SentDateTime ) VALUES ( '$_SESSION[RepId]', // ????? '$_SESSION[RepId]', // ????? '$_SESSION[RepId]', // ????? NOW() )") or die(mysql_error()); Thank ahead of time for any help you guys can give me. Please respond with ANY question if my coding or request isn't clear or if I've been confusing due to my lack of experience with PHP and MySQL. MOD EDIT: code tags added. Hi Everyone, I have a problem displaying some information from an array (selected from my database). The array is below. Array ( [0] => Array ( [ssc_skill_categories] => Web [sc_skill_categories] => Programming ) [1] => Array ( [ssc_skill_categories] => Actionscript [sc_skill_categories] => Programming ) [2] => Array ( [ssc_skill_categories] => C# [sc_skill_categories] => Programming ) [3] => Array ( [ssc_skill_categories] => CSS [sc_skill_categories] => Programming ) [4] => Array ( [ssc_skill_categories] => Graphic [sc_skill_categories] => Designers ) [5] => Array ( [ssc_skill_categories] => Logo [sc_skill_categories] => Designers ) [6] => Array ( [ssc_skill_categories] => Illistration [sc_skill_categories] => Designers ) [7] => Array ( [ssc_skill_categories] => Animation [sc_skill_categories] => Designers ) ) What i would like to to is display this information in a table like so: <html> <body> <table> <tr> <td>Programming</td><td>Web</td><td>Actionscript</td><td>C#</td><td>CSS</td> <tr> <tr> <td>Designers</td><td>Graphic</td><td>Logo</td><td>Illistration</td><td>Animation</td> <tr> <table> </body> </html> I have been trying and failing all day to do this. Posting my "progress" will clog up the thread, so for now i wont post it. Does anyone have an idea how i would achieve this? Regards, -Ben This is what i have.. I basicly need to take the Make and Model And Year Not the TYPE that needs to be left out and combine them into a drop down list. So example below would be like this Yamaha WR450F 2003-2006 Yamaha YZ450F 2003-2005 Code: [Select] <table> <tr> <th>Type</th> <th>Make</th> <th>Model</th> <th class='tar'>Year</th> </tr> <tr class='even'> <td>Offroad</td> <td>Yamaha</td> <td>WR450F</td> <td class='tar'>2003-2006</td> </tr> <tr class='odd'> <td>Offroad</td> <td>Yamaha</td> <td>YZ450F</td> <td class='tar'>2003-2005</td> </tr> </table> Hi again all, Why does the foreach loop im doing, put the array values from collection, into seperate table rows rather than 1 row per whole array? <?php class registration{ public $fields = array("username", "email", "password"); public $data = array(); public $table = "users"; public $dateTime = ""; public $datePos = 0; public $dateEntryName = "date"; public $connection; function timeStamp(){ return($this->dateTime = date("Y-m-d H:i:s")); } function insertRow($collection){ //HERE foreach($this->fields as $row => $value){ mysql_query("INSERT INTO $this->table ($value) VALUES ('$collection[$row]')"); } mysql_close($this->connection->connectData); } function validateFields(){ $this->connection = new connection(); $this->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); } } $registration = new registration(); $registration->validateFields(); ?> I end up with 3 rows row 1: username row 2: email row 3 : password rather than row 1:username email password. for starters, i am a complete beginner at PHP, so i know almost nothing.
so, the basic outline is that i am required to create a table with 2 columns, and use PHP where i can
so the first set of code lays down the table and the ability to type in text of "name" and "surname". ----i think this "input" is HTML, yes?? is there a way to enter it as PHP?
<table border=\"2\"> <tr><th><b>Requirements</b></th><th><b>Selections</b></th></tr> <tr><td>Name</td><td><input type="text" name="name"/></td></tr> <tr><td>Surname</td><td><input type="text" name="surname"/></td></tr>so, for this next section, adding on is the part for "age". i want this to appear as a dropdown selection. i've written PHP where possible, however this does not work when opening the file in a browser. it simply leaves a blank dropdown menu with no options. ???? <tr><td>Age</td><td><select> <?php for ($num=11; $num<=22; $num++){ echo '<option>' .$num. '</option>'; } ?> </select>lastly, i have the part for "activity choice". this again i believe i wrote the radio buttons in HTML??? am i able to write this as PHP???? <tr><td>Activity Choice</td><td><input type="radio" name="activityChoice" value "music"/> Music ($30.00)<br> <input type="radio" name="activityChoice" value "swimming"/> Swimming ($25.50)<br> <input type="radio" name="activityChoice" value "tennis"/> Tennis ($20.00)<br> <input type="radio" name="activityChoice" value "basketball"/> Basketball ($15.50)<br> <input type="radio" name="activityChoice" value "netball"/> Netball ($15.50)<br> <input type="radio" name="activityChoice" value "dance"/> Dance ($10.50)<br> <input type="radio" name="activityChoice" value "communityService"/> Community Service (No Charge)</td></tr> Hello everyone, Sorry if this has been answered but if it has I can't find it anywhere. So, from the begining then. Lets say I had a member table and in it I wanted to store what their top 3 interests are. Their$ row has all the usual things to identify them userID and password etc.. and I had a further 3 columns which were labled top3_1 top3_2 & top3_3 to put each of their interests in from a post form. If instead I wanted to store this data as a PHP Array instead (using 1 column instead of 3) is there a way to store it as readable data when you open the PHPmyadmin? At the moment all it says is array and when I call it back to the browser (say on a page where they could review and update their interests) it displays 'a' as top3_01 'r' as top3_02 and 'r' as top3_03 (in each putting what would be 'array' as it appears in the table if there were 5 results. Does anyone know what I mean? For example - If we had a form which collected the top 3 interests to put in a table called users, Code: [Select] <form action="back_to_same_page_for_processing.php" method="post" enctype="multipart/form-data"> <input name="top3_01" type="text" value="enter interest number 1 here" /> <input name="top3_02" type="text" value="enter interest number 2 here" /> <input name="top3_03" type="text" value="enter interest number 3 here" /> <input type="submit" name="update_button" value=" Save and Update! " /> </form> // If my quick code example for this form is not correct dont worry its not the point im getting at :) And they put 'bowling' in top3_01, 'running' in top3_02 and 'diving' in top3_03 and we catch that on the same page with some PHP at the top --> Code: [Select] if (isset($_POST)['update_button']) { $top3_01 = $_POST['top3_01']; // i.e, 'bowling' changing POST vars to local vars $top3_02 = $_POST['top3_02']; // i.e, 'running' $top3_03 = $_POST['top3_03']; // i.e, 'diving' With me so far? If I had a table which had 3 columns (1 for each interest) I could put something like - Code: [Select] include('connect_msql.php'); mysql_query("Select * FROM users WHERE id='$id' AND blah blah blah"); mysql_query("UPDATE users SET top3_01='$top3_01', top3_02='$top3_02', top3_03='$top3_03' WHERE id='$id'"); And hopefully if ive got it right, it will put them each in their own little column. Easy enough huh? But heres the thing, I want to put all these into an array to be stored in the 1 column (say called 'top3') and whats more have them clearly readable in PHPmyadmin and editable from there yet still be able to be called back an rendered on page when requested. Continuing the example then, assuming ive changed the table for the 'top3' column instead of individual colums, I could put something like this - Code: [Select] if (isset($_POST)['update_button']) { $top3_01 = $_POST['top3_01']; // i.e, 'bowling' changing POST vars to local vars $top3_02 = $_POST['top3_02']; // i.e, 'running' $top3_03 = $_POST['top3_03']; // i.e, 'diving' $top3_array = array($top3_01,$top3_02,$top3_03); include('connect_msql.php'); mysql_query("UPDATE members SET top3='$top3_array' WHERE id='$id' AND blah blah blah"); But it will appear in the column as 'Array' and when its called for using a query it will render the literal string. a r r in each field instead. Now I know you can use the 'serialize()' & 'unserialize()' funtcions but it makes the entry in the database practically unreadable. Is there a way to make it readable and editable without having to create a content management system? If so please let me know and I'll be your friend forever, lol, ok maybe not but I'd really appreciate the help anyways. The other thing is, If you can do this or something like it, how am I to add entries to that array to go back into the data base? I hope ive explained myself enough here, but if not say so and I'll have another go. Thanks very much people, L-PLate (P.s if I sort this out on my own ill post it all here) I have a table and one column has links that point to index.php?id= but I want it to display the info of that row of my database. On the index.php page i have this code Code: [Select] <?php include "dbaptsConfig.php"; // test id, you need to replace this with whatever id you want the result from $id = "1"; // what you want to ask the db $query = "SELECT * FROM `apartments` WHERE `id` = ".$id; // actually asking the db $res = mysql_query($query, $ms); // recieving the answer from the db (you can only use this line if there is always only one result, otherwise will give error) $result = mysql_fetch_assoc($res); // if you uncomment the next line it prints out the whole result as an array (prints out the image as weird characters) // print_r($result); // print out specific information (not the whole array) echo "id: ".$result['id']."<br />"; echo "username: ".$result['username']."<br />"; echo "type: ".$result['type']."<br />"; echo "title: ".$result['title']."<br />"; echo "description: ".$result['description']."<br />"; echo "county: ".$result['county']."<br />"; echo "town: ".$result['town']."<br />"; echo "phone: ".$result['phone']."<br />"; echo "rooms: ".$result['rooms']."<br />"; echo "bath: ".$result['bath']."<br />"; echo "squa ".$result['square']."<br />"; echo "rent: ".$result['rent']."<br />"; echo "time: ".$result['time']."<br />"; ?>I know there is something wrong with this cause I always get the same info no matter which apartment I click. Do I use the $_GET function and how do I implement this? I have two tables categories and subcategories and what I want do is display them but here I ran into problem displaying the subcategories. Here's the code that doesn't work, all it does it displays categories. $query = "SELECT ID,name FROM `categores`"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { echo $row['name']; $id_main=$row['ID']; $query2 ="SELECT name_subcategory FROM subcategories WHERE id_main_category=".$row['ID']; $result2 = mysql_query($query2) or die(mysql_error()); while ($row2=mysql_fetch_array($result2)); { echo $row2['name_subcategory']; } echo "<br />"; } Display should be -category --subcategory --subcategory -another category --subcategory of "another category" . . . Hello to all phpfreaks out there I need help with sorting some database columns. I ve been searching all day but i didnt found something nice to implement (or my mind is too tired to think right at this specific time) I have a table and inside it i display a picture and some other data.Above the table i inserted a div and inside it i have 5 links which when clicking on them i want to change the display order of the data being displayed in the table, and if clicked again to change again the state for ASC to DESC and so on... Is there any short solution that do the trick? With an array maybe? PS:I have also a pagination which i would like to keep the sorted order from the above table so not to mess around with the results. Thanks in advance Hi there I'm trying to work out how I'd go about searching my database for URLs that have been submitted by users that are duplicates. Now this isn't as simple as http://www.example.com/something.php and http://www.example.com/something.php oh no! People have entered links such as http://www.example.com//something.php or http://www.example.com///something.php The script (I didn't write it) currently see's these links as unique, but they're not. They function exactly the same way. Anyone have any advice on how to weed these out? I was thinking maybe a straight forward LIKE '%//%' in the mySQL syntax, but this will bring all URLs up due to the http:// aspect of the link Any feedback would be appreciated! Hi.. been a while since I have touched php and need some help. What I am trying to do is have my links pull text from separate php files, and load them into main table. Here is my old php code..used to work.. I had my index.php with my website template on it. In the table I want my info to appear i put this code. <?php /* START MAIN AREA HERE */ if($news) include("news.php"); elseif($bio) include("bio.php"); elseif($draw) include("draw.php"); elseif($pic) include("pic.php"); else include("news.php"); /* END HERE */?> My link looks like this. <A HREF="?news=x" ONMOUSEOVER="changeImages('home', 'images/home-over.gif'); return true;" ONMOUSEOUT="changeImages('home', 'images/home.gif'); return true;"> <IMG NAME="home" SRC="images/home.gif" WIDTH=69 HEIGHT=31 BORDER=0 ALT=""></A> Any help much appreciated! <html> <?php $id = $_GET['id']; $dbusername="web148-matt"; $dbpassword="matt"; $dbdatabase="web148-matt"; mysql_connect(localhost,$dbusername,$dbpassword); @mysql_select_db($dbdatabase) or die( "Unable to select database"); mysql_query("UPDATE count SET clicks=clicks+1 WHERE id='$id'"); $sql = mysql_query("SELECT link FROM count WHERE id='$id'"); $fetch = mysql_fetch_row($sql); $result = mysql_query("SELECT * FROM count"); while($row = mysql_fetch_array($result)) { echo "<a href=" .$row['link']. ">Link</a>"; } ?> <a href='http://www.google.com'>Google</a> <a href='/index.php?id=2'>link2</a> </html> Ok so for some reasons on my register and edit profile page when i hit submit it says that i have not filled in all the info i need.. Even after i fill all of them in.. but heres the code for the register form.. Code: [Select] <?php require("top.php"); ?> <div id='homeright'> <?php echo "<font size='6'>Sign up</font>"; echo "<hr width='75%' align='left'/>"; $form = "<form action='index.php' method='post'> <table cellspacing='5px'> <tr> <td>First Name:</td> <td class='register'><input type='text' name='firstname' class='textbox' size='35'></td> </tr> <tr> <td>Last Name:</td> <td><input type='text' name='lastname' class='textbox' size='35'></td> </tr> <tr> <td>Username:</td> <td><input type='text' name='username' class='textbox' size='35'></td> </tr> <tr> <td>E-mail:</td> <td><input type='text' name='email' class='textbox' size='35'></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='password' class='textbox' size='35'></td> </tr> <tr> <td>Confirm Password:</td> <td><input type='password' name='repassword' class='textbox' size='35'></td> </tr> <tr> <td></td> <td><input type='submit' name='submitbtn' value='Register' class='button'></td> </tr> </table> </form>"; if ($_POST['submitbtn']){ $firstname = fixtext($_POST['firstname']); $lastname = fixtext($_POST['lastname']); $username = fixtext($_POST['username']); $email = fixtext($_POST['email']); $password = fixtext($_POST['password']); $repassword = fixtext($_POST['repassword']); $website = fixtext($_POST['website']); $youtube = fixtext($_POST['youtube']); $bio = fixtext($_POST['bio']); $name = $_FILES['avatar'] ['name']; $type = $_FILES['avatar'] ['type']; $size = $_FILES['avatar'] ['size']; $tmpname = $_FILES['avatar']['tmpname']; $ext = substr($name, strrpos($name, '.')); if ($firstname && $lastname && $username && $email && $password && $repassword){ if ($password == $repassword){ if (strstr($email, "@") && strstr($email, ".") && strlen($email) >= 6){ require("scripts/connect.php"); /*$query = mysql_query("SELECT * FROM users WHERE username='$username' ");*/ $query=mysql_query("SELECT * FROM users WHERE username='$username' ") or die(mysql_error()); $numrows = mysql_num_rows($query); if ($numrows == 0){ /*$query=mysql_query("SELECT * FROM users WHERE email='$email' ");*/ $query=mysql_query("SELECT * FROM users WHERE email='$email' ") or die(mysql_error()); $numrows=mysql_num_rows($query); if ($numrows == 0){ $pass = md5(md5($password)); $date = date("F d, Y"); if($name){ move_uploaded_file($tmpname, "avatars/$username.$ext"); $avatar = "$username.$ext"; } else $avatar = "/avatars/default_avatar.png"; $code = substr (md5(rand(11111111111, 999999999999999)), 2, 25); mysql_query("INSERT INTO users (`first_name`,`last_name`,`username`,`email`,`password`,`avatar`,`bio`,`website`,`youtube`,`last_login`,`active`,`code`,`locked`,`date`) VALUES ( '$firstname', '$lastname', '$username', '$email', '$pass', '$avatar', '$bio', '$website', '$youtube', '', '0', '$code', '0', '$date')"); /*mysql_query("INSERT INTO users (Field, Type) VALUES ('', '$firstname', '$lastname', '$username', '$email', 'pass', '$avatar', '$bio', '$website', '$youtube', '', '0', '$code', '0', '$date')");*/ $webmaster = "Admin@trucksite.com"; $subject = "Activate Your Account!"; $headers = "From: Admin <$webmaster>"; $message = "Hello $firstname.\n\nWelcome to trucksite below is a link for you to activate your account!.\n http://tprofiletesting.net23.net/activate.php?code=$code"; mail($email, $subject, $message, $headers); echo "Your activation email has been sent to <b>$email</b>."; } else echo "That email is currently in use."; } else echo "That username is currently in use."; } else echo "You did not enter a vaild email."; } else echo "Your passwords did not match."; } else echo"You did not fill in all the required fields."; } echo "$form"; ?> </div> <div id='homeleft'> <center><font size='6'>Create! Showoff! Educate!</font></center> <hr /> </div> </body> </html> Howdy All i currently have Code: [Select] <? echo $guild ['name'];?> and i want to put <> around what is shown from the $guild ['name'] , but where ever i try the <> it cancels out and just doesnt show the name any more - currently its making us do the following <-<? echo $guild ['name'];?>-> as even if we try an echo with jsut the < and > it cancels it out Any specific way in which i can do this thanks Hello! I was working on a simple url generator, but than i though to myself, why not put everything in the root. I've heard thats not a good idea, but i'm ot sure why. I can immagine it gets really messy when you have a lot of files, but its also easy, if you ask me. I was just wondering what your view on this is. What are the pros and what are the cons? Thanks Guys/Gals; This below block outputs a very simple progress bar, i'm curious if anyone would see a solution to perform a task when this bar reaches the end as you can see it's set to countinue until width<400 when that 400 is true I and in essence the process is done (even though nothing in reality) i want to display countinue but only when it's done echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' bgcolor='#666666'><tr><td width='506' height='52' valign='top'><script type='text/javascript'>function progress(){if(document.images['bar'].width<400){document.images['bar'].width+=5;document.images['bar'].height=5; }else{clearInterval(ID);}}var ID;window.onload=function(){ID=setInterval('progress();',$cpuspeed);}</script><img src='images/white.gif' name='bar'/><br /><font color='#ffffff'>Cracking....</font></td></tr></table>"; any dideas OK so i am having a little trouble putting guilds in my game, everything shows up but when you go to create a new guild it say can not update player stats, but it shows up that the guild has been created in the top guild list, it just doesnt let you use it here is the script could someone tell me if they see a problem Code: [Select] <?php require 'connect.php'; include 'header.php'; include 'headin.php'; ?> <script type="text/javascript"> function stats() { var no=document.getElementById("Name") var option=no.options[no.selectedIndex].value var y="guild.php?stats=1&&guild="+option window.open(y,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=400, height=500") } function redirect() { window.location="./guild.php" } </script> <?php if(!isset($_COOKIE['member_id'])) die('Not logged in, please <a href=login.php>login</a>'); $Player=$_COOKIE['member_id']; $Option=$_POST['option']; $Create=$_POST['create']; $Join=$_POST['join']; $Submit=$_POST['submit']; $Tax=$_POST['tax']; $Guild=$_GET['guild']; $Deny=$_GET['deny']; $Add=$_GET['add']; $Stats=$_GET['stats']; $Kick=$_GET['kick']; $Kickname=$_GET['kickname']; $Addname=$_GET['addname']; $Abandon=$_POST['abandon']; $Coleader=$_GET['coleader']; if(isset($Abandon)) $Option="Abandon"; if($Option=="") $Option=$_GET['option']; if(isset($Option)) { if($Option=='Create a guild') { ?> <p>It costs 1,000,000 gold to create a Guild.<br /><br /></p> <form method="post" action="guild.php"> Name:<input class="text" type="text" name="name" /> <input class="button" name="create" type="submit" value="submit" /> </form> <?php } elseif($Option=='Join a guild') { print "<form class=\"form\" action='guild.php' method='post'>"; print "<select class=\"select\" name='Name' id='Name' length='20' id='blah'>"; $Guild="SELECT * from Guilds order by ID asc"; $Guild2=mysql_query($Guild) or die("Could not select Guilds"); while ($Guild3=mysql_fetch_array($Guild2)) { $Name=str_replace(" ","%20",$Guild3['Name']); print "<option value=\"$Name\">$Guild3[Name]</option>"; } print "</select><br />"; print "<input class=\"button\" type='Submit' name='join' value='Join' /> "; ?><input class=button type="button" onclick="stats()" value="Stats" /></form> <?php } elseif($Option=='Raise your guilds tax') { $Query="SELECT * from Users where ID='$Player'"; $Query2=mysql_query($Query) or die("Could not get user stats"); $User=mysql_fetch_array($Query2); $Name=$User['Guild']; $Guild1="SELECT * from Guilds where Name='$Name'"; $Guild2=mysql_query($Guild1) or die("Could not select Guilds"); $Guild=mysql_fetch_array($Guild2); if($Guild['Tax']>90){ mysql_query("UPDATE Guilds SET Tax='90' WHERE Name='$Name'"); } if($Guild['Owner']==$User['Playername'] || $Guild['Coleader']==$User['Playername']){ print "<form class=\"form\" action='guild.php' method='post'>"; print "Amount: <input type=text class=\"select\" name='tax' id='tax' length='3' id='tax'>"; print "<br /><br>"; print "<input class=\"button\" type='Submit' name='submit' value='Raise' /></form> "; }else{ echo"You may not edit your Guild Tax, since you are not a leader or co-leader."; exit; } } elseif($Option=='Guild stats') { $Query="SELECT * from Users where ID='$Player'"; $Query2=mysql_query($Query) or die("Could not get user stats"); $User=mysql_fetch_array($Query2); $Guild1="SELECT * from Guilds where Name='$User[Guild]'"; $Guild2=mysql_query($Guild1) or die("Could not select Guilds"); $Guild=mysql_fetch_array($Guild2); $Query="SELECT * from Users where Guild='$Guild[Name]' order by Level desc"; $Query2=mysql_query($Query) or die("Could not get user stats"); if($Guild['Name']!="") { print "<table class=\"table\" align=\"center\"><tr><td>"; $AttackPower=number_format(pow($Guild['AttackPower']+10, 5)); $DefenceStance=number_format(pow($Guild['DefenceStance']+10, 5)); $Agility=number_format(pow($Guild['Agility']+10, 5)); $Gold=pow($Guild['Gold']+12,3)*4; $Gold=number_format($Gold); $Exp=pow($Guild['Exp']+9, 4)+500; $Exp=number_format($Exp); $Itemfind=number_format(pow($Guild['Itemfind']+10, 5)); $Itemquality=number_format(pow($Guild['Itemquality']+10, 5)); print "Guild Name: $Guild[Name]<br />Guild Owner: $Guild[Owner]<br />Guild Co-Owner: $Guild[Coleader]<br />Guild Bank: $Guild[Bank]<br />Guild Tax: $Guild[Tax]%<br />Last Guild Battle: $Guild[LastFight]<br />Battles won: $Guild[Won]<br />Battles Lost: $Guild[Lost]<br />"; if($Guild['Owner']==$User['Playername'] || $Guild['Coleader']==$User['Playername'] || $User['Admin']==1){ echo "<form class=\"form\" method=\"post\" action=\"guildbonus.php\">"; echo "Attack Power:".$Guild['AttackPower']."% <input class=\"button\" type='Submit' name='AttackPower' value='Increase' /> $AttackPower gold<br />"; echo "Defence Stance:".$Guild['DefenceStance']."% <input class=\"button\" type='Submit' name='DefenceStance' value='Increase' /> $DefenceStance gold<br />"; echo "Agility:".$Guild['Agility']."% <input class=\"button\" type='Submit' name='Agility' value='Increase' /> $Agility gold<br />"; echo"Exp:".$Guild['Exp']."% <input class=\"button\" type='Submit' name='Exp' value='Increase' /> $Exp gold<br />"; echo "Gold:".$Guild['Gold']."% <input class=\"button\" type='Submit' name='Gold' value='Increase' /> $Gold gold<br />"; echo "Item Find:".$Guild['Itemfind']."% <input class=\"button\" type='Submit' name='Itemfind' value='Increase' /> $Itemfind gold<br />"; echo "Item Quality:".$Guild['Itemquality']."% <input class=\"button\" type='Submit' name='Itemquality' value='Increase' /> $Itemquality gold<br />"; }else{ echo "<form class=\"form\" method=\"post\" action=\"guildbonus.php\">"; echo "Attack Power:".$Guild['AttackPower']."% <br />"; echo "Defence Stance:".$Guild['DefenceStance']."% <br />"; echo "Agility:".$Guild['Agility']."% <br />"; echo "Experience".$Guild['Exp']."% <br />"; echo "Gold:".$Guild['Gold']."% <br />"; echo "Item Find:".$Guild['Itemfind']."% <br />"; echo "Item Quality:".$Guild['Itemquality']."% <br />"; } print "Donate:<input class=\"text\" type=\"text\" name=\"Amount\" value=\"$User[Gold]\" /><input class=\"button\" type='Submit' name='Donate' value='Donate' /></form><br />"; if($User['Playername']==$Guild['Owner']||$User['Playername']==$Guild['Coleader']||$Player=="1"){ print"<a href=\"attackguild.php\">Attack Other Guilds</a><br><br>"; } if($User['Playername']==$Guild['Owner']||$User['Playername']==$Guild['Coleader']||$Player=="1") { $Name=str_replace(" ","%20",$Guild['Name']); echo "<a href=\"guild.php?coleader=1&&Guild=$Name\">Assign coleader</a><br />"; } print "</td></tr></table>"; } else echo "You are not in a guild, below is a listing of all people not in a guild."; print "<table class=\"table\" align=\"right\"><tr><td>"; print "<form class=\"form\" action='guild.php' method='post'>"; print "<table><tr><td>"; print "Members:<br />To kick a member out the guild must pay half of what the User has donated.<br><br><table id=\"table\"><tr><td>Player</td><td>Level</td><td>Donated</td>"; if($User['Playername']==$Guild['Owner']||$User['Playername']==$Guild['Coleader']||$Player=="1"){ print "<td>Kick</td>"; } print "</tr>"; while($topplayer3=mysql_fetch_array($Query2)) { print "<tr><td>$topplayer3[Playername]</td><td>$topplayer3[Level]</td><td>$topplayer3[GuildDonate]</td>"; if($User['Playername']==$Guild['Owner']||$User['Playername']==$Guild['Coleader']||$Player=="1"){ print "<td><a href=\"guild.php?kick=$topplayer3[ID]&&kickname=$Guild[ID]\">Kick</a></td>"; } print "</tr>"; } print "</table></form></td><td></td><td>"; if($User['Playername']==$Guild['Owner']||$User['Playername']==$Guild['Coleader']||$Player=="1") { $Name = $Guild['Name']; $Guild['Name' ]= str_replace(" ","%20",$Guild['Name']); $Query = mysql_query("select * from Users where Applied='$Name'"); print "Requests:<br /><table id=\"table\"><tr><td>Name</td><td>Level</td><td>Accept?</td><td>Deny?</td></tr>"; while($joinee = mysql_fetch_array($Query)) { echo "<tr><td>$joinee[Playername]</td>"; echo "<td>$joinee[Level]</td>"; echo "<td><a href=\"guild.php?add=$joinee[ID]&&addname=$Guild[Name]\">Accept</a></td><td><a href=\"guild.php?deny=$joinee[ID]\">Deny</a></td></tr>"; } print "</table>"; print "</td></tr></table>"; } print "</td></tr></table><br />"; } elseif($Option=='Leave guild') { $Query="SELECT * from Users where ID='$Player'"; $Query2=mysql_query($Query) or die("Could not get user stats"); $User=mysql_fetch_array($Query2); $Name=$User['Guild']; $Guild1="SELECT * from Guilds where Name='$Name'"; $Guild2=mysql_query($Guild1) or die("Could not select Guilds"); $Guild=mysql_fetch_array($Guild2); if($Guild['Owner']==$User['Playername']) { echo "Are you sure you want to abandon and delete your guild?"; echo "<form action=\"guild.php\" method=\"post\"><input type=\"hidden\" value=\"$Guild[Name]\" name=\"Guild\" /><input class=\"button\" type=\"submit\" name=\"abandon\" value=\"yes\" /><input class=\"button\" type=\"button\" value=\"no\" onclick=\"redirect()\" /></form>"; } else { mysql_query("UPDATE Users SET GuildDonate='0' WHERE ID='$Player'"); mysql_query("Update Users set Guild='' where ID='$Player'") or die("Could not update player stats"); mysql_query("update Guilds set Members=Members-'1' where Name='$Guild[Name]'") or die("Could not decrease number of members"); print "You have left the guild."; } } elseif($Option=="Abandon") { $Guild=$_POST['Guild']; $Query="Select * from Users where Guild='$Guild'"; $Query2=mysql_query($Query) or die("Zomg"); while($User=mysql_fetch_array($Query2)) { $ID=$User['ID']; $Update="Update Users set Guild='' where ID='$ID'"; mysql_query($Update) or die("No clan update."); } $Query="Delete from Guilds where Name='$Guild'"; mysql_query($Query) or die("Can't delete guild."); echo "Clan deleted."; } } elseif(isset($Kick)) { $Query="SELECT * from Users where ID='$Player'"; $Query2=mysql_query($Query) or die("Could not get user stats"); $User=mysql_fetch_array($Query2); $Querty="SELECT * from Users where ID='$Kick'"; $Querty2=mysql_query($Querty) or die("Could not get user stats"); $Kicking=mysql_fetch_array($Querty2); $Name=$User['Guild']; $Guild1="SELECT * from Guilds where Name='$Name'"; $Guild2=mysql_query($Guild1) or die("Could not select Guilds"); $Guild=mysql_fetch_array($Guild2); $KickAmount=$Kicking['GuildDonate']/2; if($User['Playername']!=$Guild['Owner'] AND $User['Playername']!=$Guild['Coleader'] AND $User['Admin']!=1){ echo"You cannot kick users because you are not the leader or coleader of this guild!"; exit; } elseif($Kicking['Playername']==$Guild['Owner']){ echo"You may not kick out the creator of this guild!"; exit; } elseif($KickAmount>$Guild['Bank']){ echo"You do not have enough gold to kick this player out. To kick out a member you must be able to pay half of what they have donated."; exit; } else{ mysql_query("UPDATE Guilds SET Bank=Bank-'$KickAmount' WHERE ID='$Kickname'"); mysql_query("UPDATE Guilds SET Members=Members-'1' WHERE Name='$Guild[Name]'"); mysql_query("UPDATE Users SET Gold=Gold'$KickAmount' WHERE ID='$Kick'"); mysql_query("UPDATE Users SET GuildDonate='0' WHERE ID='$Kick'"); mysql_query("UPDATE Users SET Guild='' WHERE ID='$Kick'"); echo"Player kicked from your guild! <a href='guild.php'>Back</a>"; } } elseif(isset($Submit)) { $Query="SELECT * from Users where ID='$Player'"; $Query2=mysql_query($Query) or die("Could not get user stats"); $User=mysql_fetch_array($Query2); $Name=$User['Guild']; $Guild1="SELECT * from Guilds where Name='$Name'"; $Guild2=mysql_query($Guild1) or die("Could not select Guilds"); $Guild=mysql_fetch_array($Guild2); if($Tax<0 || $Tax>90){ echo"Do you want people leaving your guild?"; exit; }else{ mysql_query("Update Guilds set Tax='$Tax' where Name='$Name'"); echo "Tax set to $Tax!"; } } elseif(isset($Create)) { if(isset($_POST['name'])) { $Name=$_POST['name']; $Player=$_COOKIE['member_id']; $Query=mysql_query("select * from Users where ID='$Player'") or die("Could not query Users"); $User=mysql_fetch_array($Query); $check="SELECT * from Guilds where Name='$Name'"; $check2=mysql_query($check) or die("Could not query guilds"); while($check3=mysql_fetch_array($check2)) { $Clan=$check3['Name']; } if($Clan) print "Sorry there is already a guild of that name."; elseif($User['Guild'] != "") echo "You have to leave your clan before you can create your own."; elseif($User['Gold']>=1000000) { $Query="INSERT into Guilds(Name, Owner) VALUES ('$Name', '$User[Playername]')"; mysql_query($Query) or die("could not create clan"); $Update="Update Users set Guild='$Name', Applied='', Gold=Gold-'1000000' where ID='$Player'"; mysql_query($Update) or die("Could not update player stats"); print "Clan created."; } else print "You do not have enough gold."; } } elseif(isset($Join)) { if(isset($_POST['Name'])) { $Name=$_POST['Name']; $Player=$_COOKIE['member_id']; $Name=str_replace("%20"," ",$Name); $Query=mysql_query("SELECT * FROM Guilds where Name='$Name'") or die("Could not fetch guild stats"); $Guild=mysql_fetch_array($Query); $Query=mysql_query("Select * from Users where ID='$Player'"); $User=mysql_fetch_array($Query); if($User['Guild'] != "") echo "Leave your other guild first before you join a new one.<br /><a href=\"guild.php\">Go back</a>"; elseif($Guild[Members]==15){ echo "Guild is full, sorry, go pick another. <a href=fight.php>Go</a>"; }else { mysql_query("update Users set Applied='$Name' where ID='$Player'"); if($Guild['Members'] >= 15) echo "You are accepted, but the guild is currently full. you may have to wait an extended amount of time before you are accepted."; else echo "You applied for the clan. Now wait until either the owner or the coleader accepts you."; } } } elseif(isset($Deny)){ $Query="SELECT * from Users where ID='$Player'"; $Query2=mysql_query($Query) or die("Could not get user stats"); $User=mysql_fetch_array($Query2); $Name=$User['Guild']; $Guild1="SELECT * from Guilds where Name='$Name'"; $Guild2=mysql_query($Guild1) or die("Could not select Guilds"); $Guild=mysql_fetch_array($Guild2); if($User['Playername']!=$Guild['Owner'] AND $User['Playername']!=$Guild['Coleader'] AND $User['Admin']!=1){ echo"You cannot deny users because you are not the leader or coleader of this guild!"; exit; }else{ $Update="Update Users set Applied='' where ID='$Deny'"; mysql_query($Update) or die("Could not update player stats"); print "Player denied.<br /><a href=\"guild.php\">Go back</a>"; } } elseif(isset($Add)) { $Query="SELECT * from Users where ID='$Player'"; $Query2=mysql_query($Query) or die("Could not get user stats"); $User=mysql_fetch_array($Query2); $Name=$User['Guild']; $Guild1="SELECT * from Guilds where Name='$Name'"; $Guild2=mysql_query($Guild1) or die("Could not select Guilds"); $Guild=mysql_fetch_array($Guild2); if($User['Playername']!=$Guild['Owner'] AND $User['Playername']!=$Guild['Coleader'] AND $User['Admin']!=1){ echo"You cannot add users because you are not the leader or coleader of this guild!"; exit; }else{ $Addname=str_replace("%20"," ",$Addname); $Query=mysql_query("SELECT * from Guilds where Name='$Addname'") or die("Could not get guild stats"); $Guild=mysql_fetch_array($Query); if($Guild['Members'] <= 15) { $Query2=mysql_query("SELECT * FROM Users where ID='$Add'") or die("Could not get player stats"); $User=mysql_fetch_array($Query2); mysql_query("Update Guilds set Members=Members+'1' where Name='$Addname'") or die("Could not update guilds"); $Update="Update Users set Guild='$Addname', Applied='' where ID='$Add'"; mysql_query($Update) or die("Could not update player stats"); print "Player accepted.<br /><a href=\"guild.php?option=Guild%20stats\">Go back</a>"; } else print "Clan is full, cannot accept player.<br /><a href=\"guild.php?option=Guild%20stats\">Go back</a>"; } } elseif(isset($Guild)) { $Query="SELECT * from Guilds where Name='$Guild'"; $Query2=mysql_query($Query) or die("Could not get guild stats"); $Guild=mysql_fetch_array($Query2); $Query3="SELECT * from Users where Guild='$Guild[Name]'"; $Query4=mysql_query($Query3) or die("Could not get user stats"); print "Guild name: $Guild[Name]<br />Guild Owner: $Guild[Owner]<br />Clan bank: $Guild[Bank]<br />"; echo "Exp:".number_format($Guild['Exp'])."%<br />"; echo "Gold:".number_format($Guild['Gold'])."%<br />"; print "Members:<br /><table id=\"table\"><tr><td>Player</td><td>Level</td></tr>"; while($topplayer3=mysql_fetch_array($Query4)) { print "<tr><td>$topplayer3[Playername]</td><td>$topplayer3[Level]</td></tr>"; } print "</table>"; } elseif($Coleader==1) { $Guild=str_replace("%20"," ",$_GET['Guild']); $Query="SELECT * from Users where Guild='$Guild' order by Level desc"; $Query2=mysql_query($Query) or die("Could not get user stats"); $Guild1="SELECT * from Guilds where Name='$Guild'"; $Guild2=mysql_query($Guild1) or die("Could not select Guilds"); $Guild=mysql_fetch_array($Guild2); print "<table><tr><td>"; print "Members:<br /><table id=\"table\"><tr><td>Player</td><td>Level</td></tr>"; while($Member=mysql_fetch_array($Query2)) { if($Member['Playername']!=$Guild['Owner']) { $Name=str_replace(" ","%20",$Member['Playername']); $Guild=str_replace(" ","%20",$_GET['Guild']); print "<tr><td><a href=\"guild.php?coleader=$Name&&Guild=$Guild\">$Member[Playername]<a></td><td>$Member[Level]</td></tr>"; } } print "</table><br /><a href=\"guild.php?option=Guild%20stats\">Go back</a>"; } elseif($Coleader) { $Name=str_replace("%20"," ",$Coleader); $Guild=$_GET['Guild']; $Query="Update Guilds set Coleader='$Name' where Name='$Guild'"; mysql_query($Query) or die("Could not set coleader."); echo "Coleader assigned. <a href=\"guild.php?option=Guild%20stats\">Go back</a>"; } else { $Query="SELECT * from Users where ID='$Player'"; $Query2=mysql_query($Query) or die("Could not get user stats"); $User=mysql_fetch_array($Query2); $Guild1="SELECT * from Guilds where Name='$User[Guild]'"; $Guild2=mysql_query($Guild1) or die("Could not select Guilds"); $Guild=mysql_fetch_array($Guild2); print"<form method=\"post\" action=\"guild.php\">"; print"<select class=\"select\" name=\"option\">"; if($Guild['Name']!=""){ print"<option>Guild stats</option>"; print"<option>Raise your guilds tax</option>"; print"<option>Leave guild</option>"; }else{ print"<option>Create a guild</option>"; print"<option>Join a guild</option>"; } print"</select>"; print"<input class=\"button\" type=\"submit\" value=\"submit\" name=\"guild\">"; print"</form>"; print"</body>"; } ?> |