Jump to content

menator

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Male
  • Location
    Blountsville, Alabama

menator's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Had to change the tuple to a list to get it to work names = c.fetchall() Mylist = [] for name in names: Mylist.append("%s" % (name)) for pet in Mylist: print pet.capitalize()
  2. I seem to be having trouble figuring out where to use the capitalize function in my code; any help would be great! import MySQLdb # Connect to the database try: db = MySQLdb.connect(host="xxxxx", db="xxxxx", user="xxxxx", passwd="xxxxx") except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit(1) def mycats(alive=""): c = db.cursor() if(alive != "a" and alive != "d"): c.execute("select name from cats") else: if(alive == "a"): alive = "yes" if(alive == "d"): alive = "no" c.execute("select name from cats where alive = \"%s\"" % (alive)) names = c.fetchall() for name in names: print "%s" % (name) alive = "" while alive != "e": print "To view cats:\n \ a = alive, d = dead, and all = all.\n \ To exit type in e" alive = raw_input(": ") if(alive != "a" and alive != "d" and alive != "all" and alive != "e"): print"" print"" print "Only valid entries are\n a = \"alive\" \n d = \"deceased\" \n all = \"all\" \n e = \"exit\"" print "" continue if(alive =="e"): print "Goodbye!" break else: print "" if(alive == "a"): print "My cats that are alive\n" elif(alive == "d"): print "My cats that are deceased\n" else: print "This is all of my cats that are alive and dead\n" mycats(alive) print "" print""
  3. Here is a function I found with a search function WordLimiter($text,$limit=20){ $explode = explode(' ',$text); $string = ''; $dots = '...'; if(count($explode) <= $limit){ $dots = ''; } for($i=0;$i<$limit;$i++){ $string .= $explode[$i]." "; } if ($dots) { $string = substr($string, 0, strlen($string)); } return $string.$dots; } // Usage $str = 'This is a long string. Could be longer too.'; echo WordLimiter($str,4);
  4. Let mysqls' RAND() function do the work. No need to worry if rows have been deleted or not. http://www.mustap.com/databasezone_post_141_mysql-rand-function
  5. $_GET, $_POST, & $_REQUEST will have all of your inputs. Should be able to use them however you need them.
  6. Are you using a local server. Some ISP's block port 25 to help prevent spam
  7. Here is something for you to work with. <?php $file = "http://feeds.bbc.co.uk/weather/forecast/2818/Next3DaysRSS.xml"; $xml = simplexml_load_file($file); $temps_array = $xml->xpath('channel/item/description'); $temp = explode(',',$temps_array[0]); echo $temp[0] . '<br />' . $temp[1]; ?>
  8. It would help if you could post the code you have
  9. <title> <? if (isset($_GET['id'])) { if($_GET['id'] == '1') { echo "LBT Services Page"; } else if($_GET['id'] == '2') { echo "About LBT"; } else if($_GET['id'] == '3') { echo "Contact LBT"; } else if($_GET['id'] == '4') { echo "Your Message to LBT has been Submitted"; } else if($_GET['id'] == '5') { echo "LBT Links Page"; } else if($_GET['id'] == '6') { echo "LBT Back-UP Plans"; } else { echo "LBT Home page"; } }//first if else { echo 'LBT Home Page'; } ?> </title>
  10. your first if is asking what to do if id is set. Not what to do if id is not set not.
  11. Is there any reason that you are using two loops instaed of one? I don't know the fields of your table but, my example is: $query = mysql_query("select * from employee_details"); while($row = mysql_fetch_array($query)) { echo '<td>' . $row['field'] . '</td>'; }
×
×
  • 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.