-
Content Count
153 -
Joined
-
Last visited
Everything posted by hippiman
-
I'm not trying to put Xisto down, but I've been getting kind of overwhelmed with all of the topics Xisto has to offer.It's kind of a good thing, because you always have something to write about, so you can always get points; but it gets to be too much after a while.First of all, I can never figure out where to post anything. They have a tutorial section, but they have a completely different section for Photoshop tutorials. Once, I found a perfectly good tutorial (I don't remember what it was on), but I got in there, and it said it was moved, and it didn't say where to.Also, the search doesn't work for anything smaller than four characters. I never know if there is something else posted on PHP, because it doesn't let me do the search. I don't really want to look through hundreds of pages trying to figure out if someone has already posted a tutorial on PHP comment boxes, so I just posted one. I completely understand their reasoning for making the searches have to be at least four characters, but they could at least make it only search the title for anything smaller than that(That might be really hard, I know, but it's possible).Finally, I know it's probably just me, but when I'm going to post something, I have to read everything that everyone has posted before me to know I'm not copying someone else. It just seems wrong not to. It slows me down a lot. Am I the only one? I'm a pretty fast reader, but when there are 20 pages of people just trying to get points by typing a couple of words that don't have anything to do with the topic, it starts to wear on you. Like I said before, I'm not putting Xisto down; this is like my favorite site so far.I guess I'm just a complaining Jew (no offense to all the other Jews out there, it's supposed to be funny.)
-
I have just uploaded a working example of this put to use, at "hippi.trap17.com/comments/comments.php" This is my second tutorial on PHP. It's not as long as the last one, and I'm going to try and explain this one better to make sure you know exactly what's going on. I just figured this out today, so if it's missing any functionality, or there is anything wrong with it, let me know. It worked for me. This comment page isn't supposed to look good, it's just supposed to work, but you can change the HTML however you want to make it look better and change the overall layout. First of all, you need to make your config.php in the same directory as your comments page. $pre = 'com_'; //use any prefix you want, as long as nothing else could have it.(you don't really need this, it's just if you have // something else with a table named 'comments.') ?> linenums:0'><?$dbserver="localhost";$user="root";$passwd=""; //Enter your password here$connect=mysql_connect($dbserver,$user, $passwd);$db = 'forum'; //just a database I picked, use one you already have, or make another one if you really want to.$pre = 'com_'; //use any prefix you want, as long as nothing else could have it.(you don't really need this, it's just if you have // something else with a table named 'comments.')?>You might want to make it echo something, using "echo 'something';", after the connection to make sure it connected. You could also use the "or die('something')" on the line where it connects, but I've never really gotten that to work. Now, you need to have your comments.php. The HTML for it should have a form with the method as POST and a text input, a textArea, and a submit button. Make sure you name them 'name', and 'comment'. If you name them anything else, you'll have to change all of your code later to get it to work, so it's just easier to leave the names alone. <form method='post'><h3>Name:</h3><br><input type='text' name='name'><br><h3>Comment:</h3><textarea name='comment'rows="10" cols="50" wrap='hard'></textarea><input type='submit' value='submit'></form>I like "wrap='hard'" better than 'soft' and 'off'. It depends on what you want to do. There are HTML tutorials elsewhere that you could look at to see the difference. Now, you need to start making your functions. The first one you need should be a submitter function. mysql_query($sql, $connect); //Makes the table if it doesn't exist. The "." is the concatenation character for PHP $sql = 'INSERT INTO ' . $pre . 'comments (name, comment) VALUES ("' . $name . '", "' . $com . '");'; mysql_query($sql, $connect); //inserts your comment into the table. } linenums:0'>function submitComment($db, $pre, $name, $com, $connect) { //database, prefix, name, comment, connection mysql_select_db($db); $sql = 'CREATE TABLE IF NOT EXISTS ' . $pre . 'comments (id int auto_increment, name text, comment text, primary Key(id));'; mysql_query($sql, $connect); //Makes the table if it doesn't exist. The "." is the concatenation character for PHP $sql = 'INSERT INTO ' . $pre . 'comments (name, comment) VALUES ("' . $name . '", "' . $com . '");'; mysql_query($sql, $connect); //inserts your comment into the table.}The "exiter" function is something I made up to make it so there are no errors when you use quotes, apostrophes, or backslashes. I'm not sure if there are any other characters you would need it for, though. You will use it when you call the submitComment function later. $beg = substr($str, 0, $i); $end = substr($str, $i+1, strlen($str)); $str = $beg . chr(92) . $sub . $end; //chr(92) is the backslash $i++; } } return $str; } linenums:0'>function exiter($str) { //makes it so you can insert quotes for($i=0;$i<strlen($str);$i++) { //loops through every character $sub = substr($str, $i, 1); // character at the $i position if($sub=='"' || $sub=="'" || $sub==chr(92)) { //if it has a " or ' or \, it will add a \ before it so it won't think of it as that character. $beg = substr($str, 0, $i); $end = substr($str, $i+1, strlen($str)); $str = $beg . chr(92) . $sub . $end; //chr(92) is the backslash $i++; } } return $str;} Now that you have that, you can call your submitter function. if ($_POST['name'] && $_POST['comment']) submitComment($db, $pre, $_POST['name'], exiter($_POST['comment']), $connect); //if there is a name and a comment, it will put them in the database. Now, you need to display your comments from your table. The my showComments function does the trick. Later, though, you might want to change the appearance of the table. If you know anything about HTML, you should be able to do this easily. $sql = "select * from " . $pre . "comments order by id desc"; //Makes it so it shows the comments in reverse order, so it shows $result = mysql_query($sql, $connect); //the most recent at the top. $numrows = mysql_numrows($result); echo "<table>"; //starts the table, change it's properties however you want. for ($y=0;$y<$numrows;$y++) { //loops through every row echo "<tr>"; for ($x=0;$x<$numcols;$x++) { //loops through every column if($x) echo "<td>" . mysql_result($result, $y, $colnames[$x]) . "</td>"; //The "if" makes it so it doesn't show the row's ID } echo "</tr>"; } echo "</table>"; } linenums:0'>function showComments($db, $pre, $connect) { mysql_select_db($db); $numcols = 3; //id, name, comment $colnames=array(0=>'id',1=>'name',2=>'comment'); //creates an array to use later to read from the database. $sql = "select * from " . $pre . "comments order by id desc"; //Makes it so it shows the comments in reverse order, so it shows $result = mysql_query($sql, $connect); //the most recent at the top. $numrows = mysql_numrows($result); echo "<table>"; //starts the table, change it's properties however you want. for ($y=0;$y<$numrows;$y++) { //loops through every row echo "<tr>"; for ($x=0;$x<$numcols;$x++) { //loops through every column if($x) echo "<td>" . mysql_result($result, $y, $colnames[$x]) . "</td>"; //The "if" makes it so it doesn't show the row's ID } echo "</tr>"; } echo "</table>";}Don't worry, if you don't already have the table, it won't show anything. If it does for you, let me know. Now, you only need to call the function. showComments($db, $pre, $connect);You don't need an if statement for this, because it should show the previous comments no matter what. Here is the entire code: (not counting config.php) <form method='post'><h3>Name:</h3><br><input type='text' name='name'><br><h3>Comment:</h3><textarea name='comment'rows="10" cols="50" wrap='hard'></textarea><input type='submit' value='submit'></form><? require_once('config.php');function exiter($str) { //makes it so you can insert quotes for($i=0;$i<strlen($str);$i++) { $sub = substr($str, $i, 1); if($sub=='"' || $sub=="'" || $sub==chr(92)) { $beg = substr($str, 0, $i); $end = substr($str, $i+1, strlen($str)); $str = $beg . chr(92) . $sub . $end; //chr(92) is the backslash $i++; } } return $str;}function submitComment($db, $pre, $name, $com, $connect) { mysql_select_db($db); $sql = 'CREATE TABLE IF NOT EXISTS ' . $pre . 'comments (id int auto_increment, name text, comment text, primary Key(id));'; mysql_query($sql, $connect); $sql = 'INSERT INTO ' . $pre . 'comments (name, comment) VALUES ("' . $name . '", "' . $com . '");'; mysql_query($sql, $connect);}function showComments($db, $pre, $connect) { mysql_select_db($db); $numcols = 3; //id, name, comment $colnames=array(0=>'id',1=>'name',2=>'comment'); $sql = "select * from " . $pre . "comments order by id desc"; $result = mysql_query($sql, $connect); $numrows = mysql_numrows($result); echo "<table>"; for ($y=0;$y<$numrows;$y++) { echo "<tr>"; for ($x=0;$x<$numcols;$x++) { if($x) echo "<td>" . mysql_result($result, $y, $colnames[$x]) . "</td>"; } echo "</tr>"; } echo "</table>";}if ($_POST['name'] && $_POST['comment']) submitComment($db, $pre, $_POST['name'], exiter($_POST['comment']), $connect);showComments($db, $pre, $connect); //Whenever you want to delete the comments, just do a drop table on your PHPmyAdmin.//I'll probably figure out how to delete them depending on when they were submitted.?> If this script doesn't work, you might need to change the first "<?" to "<?php". I've configured my PHP to work either way. If you have any suggestions, or know a way to make it delete old comments, please let me know. Don't read past this if you don't care how I learned this(it's kind of boring, and I blabber(<--funny word ) a lot)... I'm new to PHP, HTML, and CSS, so if anyone knows of any good tutorials, please help. It took me around two hours to get this to work because I didn't know exactly what I was doing. I learned most of it as I made the page, like I just found out what an exitor was, so it took like 20 minutes to figure out why it wouldn't insert anything with quotes or anything; so when I found that out, I made up a function to get it to work anyway. Trying to get my "exiter" function to work is when I learned about PHP string handling. I also tried to make a version of this that works with text files, so I learned a lot about file handling, too; but I found out that it wasn't efficient enough that way, and you can end up with a lot of errors if there is more than one person at a time, and it's really slow. Sorry if I'm starting to annoy you. I'll just shut up.
-
Cool! My dad was trying to get some DVDs burned and we found this AVI to DVD converter and burned them, but we couldn't get two AVI's onto it. It's too late now, but it probably would have helped us a lot to have seen this tutorial before. I hope anyone that needs it finds this tutorial before they waste too much time trying to figure it out by themselves, like I did.
-
Would GLUT be good for programming games, or would it be too slow or anything...Or does anyone know what the best package for DevC++ would be for making games?
-
My dad tried learning Judo and some other martial arts from a book when he was a teenager. I don't really know how far he got into it, but I'm guessing he didn't learn too much because it's hard to learn something like that from a book. You need someone there to show you what you're doing wrong.
-
The main reason we need school is because most parents don't have the time to teach us everything about everything. It teaches you what you need to know about how to get on in life. If school wasn't required, the majority of Americans would be more than twice as dumb as they are now, because there are a lot of parents and kids that don't really care about education. If everyone already had a career planned for them, they wouldn't need to go to school, they could be taught by someone that already has that job; but the one of the main points of America is to be able to make your own decisions. They teach you general stuff that could be used in any job, or almost anything in life for that matter, and by the time you're out of the required part of it, you know enough to make your own decisions and hopefully start making a lot of money(the other main point of being American).It's a lot easier to get jobs with an education because people know you have some experience. If you haven't gone through school, you don't have anything to prove what you know, so you won't get hired anywhere(unless it's your own business, or they know you, or have heard of you).The government is only trying to help(hopefully).
-
My friend got the newest Archos a little while ago. It has a lot better video quality(from what I've seen) and a bigger screen. He sold his other one to one of my other friends. He's still finding new stuff out about it.(Maybe because he's slow) I know if I was rich I would probably go and buy one right away.They even get powered from USB now!!!!
-
No offense, but the IQ tests aren't really a good way to measure understanding. It's just a big test about what you already know, and being able to figure out patterns and analogies. I'm not saying you don't have understanding, because your other statements really need understanding to accomplish them. But from the IQ tests I've taken, it doesn't seem like they're trying to measure your understanding.But for me, glasses will work just fine.(I'm lazy) All I have to do is put them on in the morning, wipe them off when I can't see, and take them off at night. I don't think that's too much.
-
So, now that I know what an API is, does anyone know how to install one for Macromedia Flash MX? That's what I've been looking for on Google, but I haven't found anything very useful. I found some other API that had an installer for it, but I didn't really want that one, I just want the Wii one.
-
MyDatabus.com is one of the best internet storage places I could find. They give you 5 Gigs of space for free!!! It took me a while to figure out how to be able to see it from other sites, but if you click "make public" and then "make table", it will give you an html table with links to all of the stuff you've made public. The URL is kind of long, but you could make the main URL a PHP variable or something and just add the name of the file or whatever relative to that. I got my account like a year ago, and it's always worked so far.
-
I have Macromedia Flash MX, and I found this site, http://wiiflash.org/, where they give you an API so you can detect stuff from the WiiMote. I still have no idea what an API is, or how to install it, but I have a little background on actionscript. Some of my demos are at http://hippi.co.nr/flash, but the only completed one is WiiBall.swf, and it kind of sucks. It's pretty much just a mouse game. Does anyone know how to install API's with that version of Flash?
-
What Do You Think Of My Trap17 Picture?! A PS image I made.
hippiman replied to Damen's topic in Graphics, Design & Animation
I thought you said you didn't like yellow, Damen? The green is fine, to me, but I think you should have used some other color with it than the yellow. It's fine though, but I've seen you do better. -
My parents got a new vacuum a while ago, from some guy that sold the same kind to my grandma 20 years ago, and they've made a bunch of improvements on it. It also came with some extra thing that circulates the air and filters it, and it's really quiet when you set it on low, and when you leave, you can set it higher and it won't matter because you won't be there to hear it. It has a lot of extensions for different places. Personally, I don't like any vacuums, because the cords get really annoying. If they could get a cordless vacuum that wasn't really expensive and was easy to use, it would be perfect; except I don't really like to vacuum, because that means work.
-
There are way too many places like that out there. It's a good thing we all found Xisto before something really bad happened. The only thing that happened to me on my last host is I couldn't see any of my files from the internet, and they started putting ads on. I could still get into my cpanel and get all my stuff, though. You should always make sure to keep all of your files backed up, though.
-
I have like 2 Stephen King books, and 3 Dean Koontz books just laying around my room. My brother let me borrow them, but I'm a slow reader.There was this really good book by Dean Koontz that I can never remember the title. The main thing I can remember is at the beginning two people were fighting because one of them pissed on the other's lawn gnome, and the main guy was being framed for murder. Does anyone know what it was?
-
Do you need to add a .htaccess file to every directory, or just the ones that you're changing from index, or does it change the index file for all your directories? If it did it for every directory in the directory, unless you told it otherwise, that'd be great!I don't think I'll really use it that much, though. It's just easier for me to use index.Does it automatically accept index.php over index.html? I haven't checked that yet.
-
Wha... ??Their site is almost as bad as mine, and I'm not even 1/4 of the way done with mine, and I'm completely new to HTML, CSS, PHP, and JavaScript. They could at least have a NavBar. They just have a bunch of links scattered all over the page. Even I know not to do that. All they would have to do is look at a couple of tutorials(which are free), and look at some other sites for an example. They probably just haven't done anything to it since they came up with the idea. If you're trying to make money off of something, you should at least keep track of it. I don't even think anyone that works for them would use their service.Now I don't feel so bad about my site.
-
I just got my account, and I was wondering: do we really get 99 MySql databases? I've read a lot of the stuff about it, and it sounded like we only get one database, but my cPanel says that I have "0 / 99" databases. If it's lying, it's not really a problem, because I could always just prefix my tables, but I was just wondering why it would say that. If for some reason it was letting me get more than one database, and I wasn't supposed to, I don't want to get my account deleted. Does anyone know why it says that?
-
I just got my hosting account, and so far, Xisto is like infinity^2 times better than my last host. I had my-php.net before. They used some other host, I think it was free for them, and everything took forever. For some reason, they started putting ads on, and I couldn't get into one of my directories. All of my stuff was still there, because I downloaded it to put it on Xisto, but it wouldn't show up. I went to their site, and it still said it was free webhosting with no ads! They're friggin' liars. From what I've seen so far in this forum, and from what I've seen on my new account, this is the best webhost ever!!!!!
-
The last host I had was my-php.net. It sucked. I think they just found some way to use Byethost to make their own free webhost. Every time you try to do something, it would send you through like five different sites, includeing byethost, and it took forever to do anything with their old c-panel. All I know is it sucked!!!! ;)
-
My dad keeps saying something about how Easter came from a Pagan religion where every year people gathered around and sacrificed their children to some goddess named Esther or something, and painted eggs with their blood. My dad is really religious, so I would think he would know, but I'm not really sure. He says almost every holiday from the Christian belief is from some Pagan religion, though. It's all a conspiracy.
-
First of all, I'm letting you know that this is nowhere near as good as PHPMyAdmin. It's just a tutorial on how to view all your databases, tables, and what's in the tables, and be able to edit the tables. I haven't even put in a way to add databases, tables, or columns (yet). This was just a test thing I made up to see if I knew what I was doing with PHP and MySql. Feel free to ask any questions. That's why I'm here. If I don't know the answer, I'll be glad to look it up or ask someone that knows. I need credits!!! Now, as you've probably seen in other tutorials, you need to create a "config.php". It will have connect you to MySql. <?php $dbserver="localhost"; $user="root"; $passwd="password"; $connect=mysql_connect($dbserver,$user, $passwd);?>Once you have that, you need to make your "index.php", or whatever you want to call it. Put it in the same directory as your config file. Now, you need to have it show your databases. (If you don't have permission to do "SHOW DATABASES", then this part wont work.) echo "<center><h1>Databases:</h1>";$sql = "SHOW DATABASES;";$result = mysql_query($sql, $connect);?><form method='POST'><select name='dbselect' size='5'>"<?php //the select tag is a drop down list to select the database.for($i=0;$i<mysql_numrows($result);$i++) { $data = mysql_result($result,$i,"database"); if($data!="information_schema" && $data != "mysql") //Those two databases are MySql's, I don't want to mess with them. if($_POST['dbselect']==$data) echo "<option selected>" . $data . "</option>"; else echo "<option>" . $data . "</option>"; //If there's already a DB selected, it will stay selected when you reload.}echo "</select><input type='submit' value='USE DATABASE'></form>";//the input is the button to select the DBNext, if there is a DB selected(in the POST), then it will call our getTables function. if($_POST['dbselect']) getTables($_POST['dbselect'],$connect);function getTables($db, $connect) { mysql_select_db($db); //select the DB $sql="SHOW TABLES;"; $result=mysql_query($sql,$connect); echo "<h1>" . $db . ":</h1>"; //display the name of the DB echo "<form method='POST'><input name='dbselect' type='hidden' value='" . $db . "'><input name='tbselect' type='hidden' value='" . $_POST['tbselect'] . "'><select name='tbselect' size=5>"; //Makes sure when you select the table, the DB is selected for($i=0;$i<mysql_numrows($result);$i++) { $data= mysql_result($result, $i, "tables_in_" . $db); if($_POST['tbselect']==$data) echo "<option selected>" . $data . "</option>"; //keeps the table selected else echo "<option>" . $data . "</option>"; } echo "</select><input type='submit' value='SELECT * FROM'></from>"; //button to select everything from the table.}Once you've selected the table, you need to display the data. if($_POST['tbselect']) selectAll($_POST['dbselect'],$_POST['tbselect'],$connect);function selectAll($db, $tb, $connect) { mysql_select_db($db); $sql="SHOW COLUMNS FROM " . $tb . ";"; $result=mysql_query($sql,$connect); echo "<h1>" . $tb . ":</h1>"; //show the name of the selected table. echo "<form method='POST'><input name='dbselect' type='hidden' value='" . $db . "'><input name='edited' type='hidden' value='1'>"; //Keep the DB and table selected echo "<table border='1'><tr>"; for($i=0;$i<mysql_numrows($result);$i++) { //shows the names of the columns at the top of the table echo "<td>" . mysql_result($result, $i, "field") . "</td>"; $colnames[$i]=mysql_result($result, $i, "field"); } $numcols=$i; echo "</tr>"; $sql="SELECT * FROM " . $tb . ";"; $result=mysql_query($sql,$connect); $numrows=mysql_numrows($result); for($y=0;$y<$numrows;$y++) { //these loops make txtBoxes so you can change the data in the table. for($x=0;$x<$numcols;$x++) { if(!$x) echo "<td>" . mysql_result($result, $y, $colnames[$x]) . "</td>"; //echoes the ID without a txtBox. else echo "<td><input name='" . ($x + $y*$numcols) . "' type='text' value='" . mysql_result($result, $y, $colnames[$x]) . "'></td>"; //($x+$y*numcols) is which TD it is from left to right, then top to bottom(like reading) } echo "</tr>"; } echo "</form><form method='POST'><input type='hidden' name='newrow' value='asdf'><input type='hidden' name='dbselect' value='" . $db . "'><input type='hidden' name='tbselect' value='" . $tb . "'><tr>";//form to add a row for($x=0;$x<$numcols;$x++){ if($x) echo "<td><input type='text' name='" . $x . "'></td>"; else echo "<td><input type='Submit' value='Add New Row'</td>"; } //makes an extra row so you can add a row if you need to. echo "</form></table>"; echo "<form method='POST'>Delete row by id:<input type='text' name='delete'><input type='hidden' name='dbselect' value='" . $db . "'> <input type='hidden' name='tbselect' value='" . $tb . "'></form>"; //form that deletes a row }Next, you need to be able to Update the table. If they submit the update form, it will change the values in the DB. if($_POST['edited']) { updateTable($_POST['dbselect'], $_POST['tbselect'], $connect); echo "<br>Table Updated.";}function updateTable($db, $tb, $connect) { mysql_select_db($db); $sql="SHOW COLUMNS FROM " . $tb . ";"; $result=mysql_query($sql, $connect); $numcols=mysql_numrows($result); for($i=0;$i<$numcols;$i++) { $colname[$i]=mysql_result($result, $i, "field"); } //gets the names of the columns $sql="SELECT * FROM " . $tb . ";"; $result=mysql_query($sql, $connect); $numrows=mysql_numrows($result); for($y=0;$y<$numrows;$y++) { //these loops make the update string in the format "UPDATE table SET column = value WHERE //id=idOfRow (One for every row) $sql="UPDATE " . $tb . " SET "; for($x=0;$x<$numcols-1;$x++){//$numcols-1 because we're not changing the ID $sql .= $colname[$x+1] . "='" . $_POST[($x+$y*$numcols+1)] . "'"; if($x!=$numcols-2) $sql .= ","; //adds a comma if there's another column to add } $sql .= " WHERE id=" . ($y+1) . ";"; mysql_query($sql,$connect); }}Next, (we're almost done) you need to make a way to add a row. If they submitted the addRow form, it will add the row. if($_POST['newrow']) addRow($_POST['dbselect'],$_POST['tbselect'],$connect);function addRow($db, $tb, $connect) { mysql_select_db($db); $sql="SHOW COLUMNS FROM " . $tb . ";"; $result=mysql_query($sql, $connect); $numcols=mysql_numrows($result); for($i=0;$i<$numcols;$i++) { if(mysql_result($result, $i, "field")!="id") $colname[$i]=mysql_result($result, $i, "field"); } //gets the names of the columns $sql="INSERT INTO " . $tb . "("; for($x=0;$x<$numcols;$x++){ if($colname[$x]) $sql .= $colname[$x]; if($x!=$numcols-1 && $x) $sql .= ","; } //doesn't insert into the id column, it's auto_increment $sql .= ") VALUES ("; for($x=0;$x<$numcols;$x++){ if($x) $sql .= "'" . $_POST[$x] . "'"; if($x!=$numcols-1 && $x) $sql .= ","; } $sql .=");"; mysql_query($sql,$connect);}Finally, the last function. A function to delete a row by its ID. If they've submitted the delete form, it deletes the row they entered. if($_POST['delete']) { mysql_select_db($_POST['dbselect']); $sql="DELETE FROM " . $_POST['tbselect'] . " WHERE id=" . $_POST['delete'] . ";"; mysql_query($sql,$connect);} Here is my entire code: <head><title>LOCALHOST</title></head><center><a href='tradedvds'>Trade Dvds</a></center><center><a href='forum'>Forum</a></center><?require_once("config.php");echo "<center><h1>Databases:</h1>";$sql = "SHOW DATABASES;";$result = mysql_query($sql, $connect);?><form method='POST'><select name='dbselect' size='5'>"<?for($i=0;$i<mysql_numrows($result);$i++) { $data = mysql_result($result,$i,"database"); if($data!="information_schema" && $data != "mysql") if($_POST['dbselect']==$data) echo "<option selected>" . $data . "</option>"; else echo "<option>" . $data . "</option>";}echo "</select><input type='submit' value='USE DATABASE'></form>";function getTables($db, $connect) { mysql_select_db($db); $sql="SHOW TABLES;"; $result=mysql_query($sql,$connect); echo "<h1>" . $db . ":</h1>"; echo "<form method='POST'><input name='dbselect' type='hidden' value='" . $db . "'><input name='tbselect' type='hidden' value='" . $_POST['tbselect'] . "'><select name='tbselect' size=5>"; for($i=0;$i<mysql_numrows($result);$i++) { $data= mysql_result($result, $i, "tables_in_" . $db); if($_POST['tbselect']==$data) echo "<option selected>" . $data . "</option>"; else echo "<option>" . $data . "</option>"; } echo "</select><input type='submit' value='SELECT * FROM'></from>";}function selectAll($db, $tb, $connect) { mysql_select_db($db); $sql="SHOW COLUMNS FROM " . $tb . ";"; $result=mysql_query($sql,$connect); echo "<h1>" . $tb . ":</h1>"; echo "<form method='POST'><input name='dbselect' type='hidden' value='" . $db . "'><input name='edited' type='hidden' value='1'>"; echo "<table border='1'><tr>"; for($i=0;$i<mysql_numrows($result);$i++) { echo "<td>" . mysql_result($result, $i, "field") . "</td>"; $colnames[$i]=mysql_result($result, $i, "field"); } $numcols=$i; echo "</tr>"; $sql="SELECT * FROM " . $tb . ";"; $result=mysql_query($sql,$connect); $numrows=mysql_numrows($result); for($y=0;$y<$numrows;$y++) { for($x=0;$x<$numcols;$x++) { if(!$x) echo "<td>" . mysql_result($result, $y, $colnames[$x]) . "</td>"; else echo "<td><input name='" . ($x + $y*$numcols) . "' type='text' value='" . mysql_result($result, $y, $colnames[$x]) . "'></td>"; } echo "</tr>"; } echo "</form><form method='POST'><input type='hidden' name='newrow' value='asdf'><input type='hidden' name='dbselect' value='" . $db . "'><input type='hidden' name='tbselect' value='" . $tb . "'><tr>"; for($x=0;$x<$numcols;$x++){ if($x) echo "<td><input type='text' name='" . $x . "'></td>"; else echo "<td><input type='Submit' value='Add New Row'</td>"; } echo "</form></table>"; echo "<form method='POST'>Delete row by id:<input type='text' name='delete'><input type='hidden' name='dbselect' value='" . $db . "'> <input type='hidden' name='tbselect' value='" . $tb . "'></form>"; }function updateTable($db, $tb, $connect) { mysql_select_db($db); $sql="SHOW COLUMNS FROM " . $tb . ";"; $result=mysql_query($sql, $connect); $numcols=mysql_numrows($result); for($i=0;$i<$numcols;$i++) { $colname[$i]=mysql_result($result, $i, "field"); } $sql="SELECT * FROM " . $tb . ";"; $result=mysql_query($sql, $connect); $numrows=mysql_numrows($result); for($y=0;$y<$numrows;$y++) { $sql="UPDATE " . $tb . " SET "; for($x=0;$x<$numcols-1;$x++){ $sql .= $colname[$x+1] . "='" . $_POST[($x+$y*$numcols+1)] . "'"; if($x!=$numcols-2) $sql .= ","; } $sql .= " WHERE id=" . ($y+1) . ";"; mysql_query($sql,$connect); }} function addRow($db, $tb, $connect) { mysql_select_db($db); $sql="SHOW COLUMNS FROM " . $tb . ";"; $result=mysql_query($sql, $connect); $numcols=mysql_numrows($result); for($i=0;$i<$numcols;$i++) { if(mysql_result($result, $i, "field")!="id") $colname[$i]=mysql_result($result, $i, "field"); } $sql="INSERT INTO " . $tb . "("; for($x=0;$x<$numcols;$x++){ if($colname[$x]) $sql .= $colname[$x]; if($x!=$numcols-1 && $x) $sql .= ","; } $sql .= ") VALUES ("; for($x=0;$x<$numcols;$x++){ if($x) $sql .= "'" . $_POST[$x] . "'"; if($x!=$numcols-1 && $x) $sql .= ","; } $sql .=");"; mysql_query($sql,$connect);}if($_POST['dbselect']) getTables($_POST['dbselect'],$connect);if($_POST['edited']) { updateTable($_POST['dbselect'], $_POST['tbselect'], $connect); echo "<br>Table Updated.";}if($_POST['delete']) { mysql_select_db($_POST['dbselect']); $sql="DELETE FROM " . $_POST['tbselect'] . " WHERE id=" . $_POST['delete'] . ";"; mysql_query($sql,$connect);}if($_POST['newrow']) addRow($_POST['dbselect'],$_POST['tbselect'],$connect);if($_POST['tbselect']) selectAll($_POST['dbselect'],$_POST['tbselect'],$connect);mysql_close();?>You should just be able to copy it, but I don't know if the Code thing made stuff go onto other lines. It should still work though. You can change use this code however you want. It took me forever to figure out, but it works. If anyone has any suggestions on how to make my code any shorter, they're welcome, but this is as short as I could get it. I might add more functionality to it later. I hope it's helpful.
-
Php - Randomize Web Title using arrays and the random function
hippiman replied to Blessed's topic in General Discussion
If you want to make it change every month from when you start it, you could use mysql or a text file, and store the last date that it was changed, and if time() > (what's stored) + (30*24*60*60), then it would show a different title. I think there's also a way to use "date('Y-m-d', strtotime('+1 month'))" (I found this in another tutorial and it worked), but I'm not sure if the ">" sign would work for dates. There might be some other way to do it that's better, but I haven't really looked into it.