Jump to content

obsidian

Staff Alumni
  • Posts

    3,202
  • Joined

  • Last visited

Everything posted by obsidian

  1. no problem... take a look at this one, and see if you can grasp how the recurring code changes the color each time: [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--] [span style=\"color:#0000BB\"]<?php $sql [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_query[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"SELECT field1, AVG(field2) AS avg GROUP BY field1\"[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#FF8000\"]// run query [/span][span style=\"color:#0000BB\"]$color [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\'#ffffff\'[/span][span style=\"color:#007700\"]; [/span][span style=\"color:#FF8000\"]// set default color (white in this case) [/span][span style=\"color:#007700\"]echo [/span][span style=\"color:#DD0000\"]\"<table>\n\"[/span][span style=\"color:#007700\"]; while ([/span][span style=\"color:#0000BB\"]$row [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_fetch_array[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$sql[/span][span style=\"color:#007700\"])) { [/span][span style=\"color:#0000BB\"]$color [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$color [/span][span style=\"color:#007700\"]== [/span][span style=\"color:#DD0000\"]\'#ffffff\' [/span][span style=\"color:#007700\"]? [/span][span style=\"color:#DD0000\"]\'#f2f3f4\' [/span][span style=\"color:#007700\"]: [/span][span style=\"color:#DD0000\"]\'#ffffff\'[/span][span style=\"color:#007700\"]; [/span][span style=\"color:#FF8000\"]// ternary operator switching between white and pale blue for each row [/span][span style=\"color:#007700\"]echo [/span][span style=\"color:#DD0000\"]\"<tr style=\'background-color: $color;\'><td>$row[field1]</td><td>$row[avg]</td></tr>\n\"[/span][span style=\"color:#007700\"]; } echo [/span][span style=\"color:#DD0000\"]\"</table>\n\"[/span][span style=\"color:#007700\"]; [/span][span style=\"color:#0000BB\"]?> [/span] [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] good luck!
  2. all i've got to say about that is HA... show me proof. after much reading and checking out specs, i'd have to say i'm still drawn to nintendo. especially after they unveiled their new controller last week. i've always been a nintendo fan, and they are consistantly setting the bar. this time, they're not just setting the bar, they're defining an entirely new way to play. sure, it may flop, but kudos to them for trying, and it just looks so darn cool, too! as to the technical end of things, i've not been too impressed with XBox 360 (and definitely not with PS3), since they've basically just been showing more of the same with pumped up graphics. you've got to give me more than just eye candy to draw me to a system. and after saying all that, i'll also add that i do most of my gaming on PC, but i do have a GC at home, too. i could go on and on, but this is a PHP forum, not gaming... lol
  3. i've always believed that there's no such thing as a dumb question... some just take a little more thinking to answer than others here's how i'd echo in a table: [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--] [span style=\"color:#0000BB\"]<?php $sql [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_query[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"SELECT field1, AVG(field2) AS avg GROUP BY field1\"[/span][span style=\"color:#007700\"]); echo [/span][span style=\"color:#DD0000\"]\"<table>\n\"[/span][span style=\"color:#007700\"]; while ([/span][span style=\"color:#0000BB\"]$row [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_fetch_array[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$sql[/span][span style=\"color:#007700\"])) { echo [/span][span style=\"color:#DD0000\"]\"<tr><td>$row[field1]</td><td>$row[avg]</td></tr>\n\"[/span][span style=\"color:#007700\"]; } echo [/span][span style=\"color:#DD0000\"]\"</table>\n\"[/span][span style=\"color:#007700\"]; [/span][span style=\"color:#0000BB\"]?> [/span] [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] hope this works for you!
  4. the sql AVG() function should do the trick: [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--] [span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#FF8000\"]// for specific user [/span][span style=\"color:#0000BB\"]$sql [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_query[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"SELECT AVG(field2) AS avg WHERE field1 = \'joe\'\"[/span][span style=\"color:#007700\"]); echo [/span][span style=\"color:#0000BB\"]mysql_result[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$sql[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]0[/span][span style=\"color:#007700\"], [/span][span style=\"color:#DD0000\"]\'avg\'[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#FF8000\"]// for getting averages for all users: [/span][span style=\"color:#0000BB\"]$sql [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_query[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"SELECT field1, AVG(field2) AS avg GROUP BY field1\"[/span][span style=\"color:#007700\"]); while ([/span][span style=\"color:#0000BB\"]$row [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_fetch_array[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$sql[/span][span style=\"color:#007700\"])) { echo [/span][span style=\"color:#DD0000\"]\"$row[field1] - $row[avg]<br />\n\"[/span][span style=\"color:#007700\"]; } [/span][span style=\"color:#0000BB\"]?> [/span] [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] hope this helps!
  5. i agree... while i don't have the sigs turned off, i very seldom grace the signatures with a second glance. the big banner ones i usually block in firefox anyway, but as far as anything important being in the sigs: go ahead and do it, but i don't know how much response you'll really get from it.
  6. that's what we're here for! ;-) i'll mark this topic solved
  7. if you know how many fields there are, use for() instead of foreach(): [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--] [span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]for ([/span][span style=\"color:#0000BB\"]$i [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]1[/span][span style=\"color:#007700\"]; [/span][span style=\"color:#0000BB\"]$i [/span][span style=\"color:#007700\"]<= [/span][span style=\"color:#0000BB\"]10[/span][span style=\"color:#007700\"]; [/span][span style=\"color:#0000BB\"]$i[/span][span style=\"color:#007700\"]++) { echo [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\"Name$i\"[/span][span style=\"color:#007700\"]]; } [/span][span style=\"color:#0000BB\"]?> [/span] [/span][!--PHP-Foot--][/div][!--PHP-EFoot--]
  8. i'll add to that that most of the female programmers that i've met (those who have some experience) can usually produce more efficient and cleaner code than a lot of guys i know. they tend to not have the push that guys do to "just get the job done"... i know that i'd hire a female programmer any day! lol
  9. my name's Garth Henson. i'm 25, and, i've been doing PHP programming for a little over 2 years now. I am the lead web developer for a university in South Carolina. I do have a base in other languages, although, I pretty much have solely developed with PHP since I started with it. I'm also married, and I agree with ober: i'm glad she's not a programmer. i've also met a few female programmers, some of which are rather good, i might add. they definitely bring a new focus onto some of the issues.
  10. dreamweaver doesn't support database design. it is only for the coding or design aspect of the site. you need to figure out what type of SQL is running on your server (ie, MySQL or PostgreSQL). most will offer either MySQL or both. once you have that set, most hosts will also have a very nice web interface to help you create and populate your tables. if you have specific questions about queries or such, let us know! good luck
  11. well, with most guestbooks, you do need some version of SQL on your server. this is simply the database that you are going to store all your entries in to format and display them. as for the coding, you can do the entire guestbook separate from the SQL, but you'll have to create a database to store your results in to be able to display them.
  12. please refrain from double posting. it is against our forum guidelines. if you don't receive a response from someone at your first post after a little time, feel free to *bump* the post to get more recognition, but please try to avoid duplicate entries. i am closing this topic. please focus your attention on your other post.
  13. first off, welcome to the forums! easiest way is to create a "joining" table. basically, just a table that holds the ids of the related items, so, if i have a class->student many-many relationship, i would have a classes table, a students table, and a roll table. the roll table would only store two pieces of data: class_id and student_id. that way, i can easily see either all the classes a student is in or all the students in a particular class.
  14. one other problem is that when you have multiple php blocks, if you edit your post, the content from the first block with be in all of them: [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--] [span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#FF8000\"]// block one [/span][span style=\"color:#0000BB\"]$whatever [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\'yadda yadda\'[/span][span style=\"color:#007700\"]; [/span][span style=\"color:#0000BB\"]?> [/span] [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--] [span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#FF8000\"]// block two [/span][span style=\"color:#0000BB\"]$foo [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\'bar\'[/span][span style=\"color:#007700\"]; [/span][span style=\"color:#0000BB\"]?> [/span] [/span][!--PHP-Foot--][/div][!--PHP-EFoot--]
  15. it is against forum guidelines to post the same topic more than once. please be careful of double posting in the future. i am closing this topic. please refer to my response in your other thread.
  16. i'll have to disagree slightly with this approach. IMHO, any time you have any error of any sort, whether it be a notice or a parse error, it needs to be dealt with before you launch a site. notices are serious in the light that they are showing you areas in which your code is not up to standards. if you have a notice, you have an area of code where you are not using good coding practices. for instance, using the example given above, when you refer to a variable when it has not been declared yet, you get a notice (undefined string)... all you have to do to get rid of the notice is check to see whether the variable isset() or not. it's not hard to deal with, it just takes some time and commitment from the coder, and this is what separates the dedicated coders from the hobbyists.
  17. i would recommend simply following a pagination tutorial such as the one linked there, and instead of hard-coding the results per page, allow for a select box to populate that value. of course, you'll have to determine a default value, but if you're at all familiar with PHP, this should be a fairly easy modification. good luck!
  18. right: show us the code!!! lol. but, you may need to make sure that you are not trying to include a file with doctype and header information inside the body of another HTML page.
  19. well, since you're trying to call the variables the exact same name as the columns in the recordset, you're going to run into issues like that... you've said that siteID = 1 in the assigning of the variable, and then you try to select site.siteID which interprets to site.1 try to name your variables to something completely different that you know what they refer to. also, in your initial values, your default is being set to 1 and 1... make sure that you actually have a recordset with the cat value of 1 AND site value of 1
  20. just include a text field to enter their email address into (named 'email' or something like that), then do the following: [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--] [span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#FF8000\"]// change this line: [/span][span style=\"color:#0000BB\"]$to [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\'you@yourdomain.com\'[/span][span style=\"color:#007700\"]; [/span][span style=\"color:#FF8000\"]// to: [/span][span style=\"color:#0000BB\"]$to [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'email\'[/span][span style=\"color:#007700\"]]; [/span][span style=\"color:#0000BB\"]?> [/span] [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] that's it.
  21. sounds like you've got it! good luck!
  22. ok, here is the full code for a basic contact form page: [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--] [span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]if (isset([/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'submit\'[/span][span style=\"color:#007700\"]])) { [/span][span style=\"color:#0000BB\"]$to [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\'you@yourdomain.com\'[/span][span style=\"color:#007700\"]; [/span][span style=\"color:#FF8000\"]// replace your address here [/span][span style=\"color:#0000BB\"]$subject [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'subject\'[/span][span style=\"color:#007700\"]]; [/span][span style=\"color:#0000BB\"]$message [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'message\'[/span][span style=\"color:#007700\"]]; if ([/span][span style=\"color:#0000BB\"]mail[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$to[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$subject[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$message[/span][span style=\"color:#007700\"])) { [/span][span style=\"color:#0000BB\"]$message [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"Mail sent!\"[/span][span style=\"color:#007700\"]; } else { [/span][span style=\"color:#0000BB\"]$message [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"Couldn\'t send mail!\"[/span][span style=\"color:#007700\"]; } } echo (isset([/span][span style=\"color:#0000BB\"]$message[/span][span style=\"color:#007700\"])) ? [/span][span style=\"color:#0000BB\"]$message [/span][span style=\"color:#007700\"]: [/span][span style=\"color:#DD0000\"]\'\'[/span][span style=\"color:#007700\"]; [/span][span style=\"color:#0000BB\"]?> [/span] <form name=\'email\' method=\'post\' action=\'\'> Subject: <input type=\'text\' name=\'subject\' /><br /> Message: <br /> <textarea name=\'message\' cols=\'60\' rows=\'20\'></textarea><br /> <input type=\'submit\' name=\'submit\' value=\'Send It\' /> </form> [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] this saved with a ".php" extension should allow you to send basic emails through the form. hope this helps!
  23. that's going to be the easiest way... let me see if i can break it down for you: [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--] [span style=\"color:#0000BB\"]<?php $to [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\'you@yourdomain.com\'[/span][span style=\"color:#007700\"]; [/span][span style=\"color:#FF8000\"]// the recipient of the email [/span][span style=\"color:#0000BB\"]$subject [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\'Some Subject\'[/span][span style=\"color:#007700\"]; [/span][span style=\"color:#FF8000\"]// whatever you want to appear in the subject line [/span][span style=\"color:#0000BB\"]$message [/span][span style=\"color:#007700\"]= \'[/span][span style=\"color:#0000BB\"]Text for message goes here.\"; // message text mail($to, $subject, $message); ?> [/span] [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] that's all there is to it! you have lots of additional "optional" settings that you don't need to worry about at this stage, but to get it to work, all you have to do is provide a To: address, subject, and message. hope this helps some. good luck!
×
×
  • 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.