Jump to content

lunac

Members
  • Posts

    33
  • Joined

  • Last visited

    Never

Contact Methods

  • AIM
    daradears
  • Website URL
    http://darasplace.com

Profile Information

  • Gender
    Not Telling
  • Location
    Dulles, VA

lunac's Achievements

Member

Member (2/5)

0

Reputation

  1. Your on the right path. The best way to learn PHP is to use it. Think of projects that you would like to create and create them. Here's a few ideas of common applications shoutbox photo gallery content management calendar Email / newsletter functionality In fact, with those 5 applications you can build most websites. Good luck.
  2. Hi All, I use this forum all the time to ask questions and get help. Well this time I'm sharing. I came up with a way to show a hidden div to give details on a calendar entry. Actually, it will work for any code that is looping where you need to show/hide multiple items with in the loop. Basically, the loop is serving back each entry. For each one I have a clickable link that will then show more hidden content. Basically to get it to work, you have to output the style at the same time you create the link and related div. it will read something like: //style $x = '<style> #add_pop-' . $i['id'] . ' { z-index: 15; position: absolute; display: none; text-align: left;}</style>'; //link $x .='<a href="javascript:toggleLayer(\'add_pop-' . $i['id'] . '\');">' . $i['label'] . '</a>'; //div $x .= '<div id="add_pop-' . $i['id'] . '">' . $i['description'] .'</div>'; Here is the javascript function to show hide layers /* this function toggles a layer and was created by http://www.netlobo.com/div_hiding.html */ function toggleLayer( whichLayer ) { var elem, vis; if( document.getElementById ) // this is the way the standards work elem = document.getElementById( whichLayer ); else if( document.all ) // this is the way old msie versions work elem = document.all[whichLayer]; else if( document.layers ) // this is the way nn4 works elem = document.layers[whichLayer]; vis = elem.style; // if the style.display value is blank we try to figure it out here if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined) vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none'; vis.display = (vis.display==''||vis.display=='block')?'none':'block'; } function toggleExpandLayer( whichLayer, whichimage, close, expand) { var elem, vis; if( document.getElementById ) // this is the way the standards work elem = document.getElementById( whichLayer ); else if( document.all ) // this is the way old msie versions work elem = document.all[whichLayer]; else if( document.layers ) // this is the way nn4 works elem = document.layers[whichLayer]; vis = elem.style; // if the style.display value is blank we try to figure it out here if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined) //vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none'; if(elem.offsetWidth!=0&&elem.offsetHeight!=0){ vis.display = 'block'; document.images[whichimage].src=close; } else { vis.display = 'none'; document.images[whichimage].src=expand; } //vis.display = (vis.display==''||vis.display=='block')?'none':'block'; if(vis.display==''||vis.display=='block'){ vis.display = 'none'; document.images[whichimage].src=expand; } else { vis.display = 'block'; document.images[whichimage].src=close; } Enjoy!
  3. Never mind -- the code is flawless. The problem turned out to be elsewhere. Thanks for all those who took a look.
  4. Ok, I have an application with a section to manage users. For some reason my routine for updating level permissions is not working. Can anyone figure out what I did wrong? Here's the code: $x = mysqlSelect($_tables['modules']); while($y = @mysql_fetch_assoc($x)){ $mods[] = $y; } foreach ($mods as $modu){ //check if module value exist otherwise add it $check = usr($modu['level'], $_POST['id']); if($check != ''){ lib_executeQuery("UPDATE " . $_tables['usersmeta'] . " set meta_value='" . $_POST[$modu['level']] ."' WHERE user_id='" . $_POST['id'] . "' AND meta_key='" . $modu['level'] . "'"); } else { $post['user_id'] = $_POST['id']; $post['meta_key'] = $modu['level']; $post['meta_value'] = $_POST[$modu['level']]; mysqlInsert($post,$_tables['usersmeta']); } Here are the supporting functions: function mysqlInsert($array,$table){ unset($array['Submit']); $keys = array_keys ($array); $values = array_values ($array); $kquery = join("','",$keys); $kquery = str_replace("'","",$kquery); $vquery = join("','",$values); $query = "insert into $table (" . $kquery . ") values ('" . $vquery . "')"; lib_executeQuery($query) or die(mysql_error()); } function lib_executeQuery($query,$dbLink=""){ // Execute an SQL query passed to this function if($dbLink){ $link = $dbLink; } else { $link = lib_databaseConnect(); } $dbResult = mysql_query($query, $link) or die ("Database Class: MySQL Error: " . mysql_error() ); return $dbResult; }
  5. HAHAHA That was exactly the problem -- the date was entering into the query wrong, so I caught it on the front end. SOLUTION: $gm = strlen($month); $month =($gm == 1)? "0" . $month : $month; $currentDay =($gm == 1)? "0" . $currentDay : $currentDay; $date = "$year-$month-$currentDay"; $e = mysqlSelect($_tables['squirrel_post'], "*", "WHERE date= '" . $date . "'");
  6. sorry -- just updated the post above.
  7. Hi, I'm trying to pass some values into a calendar I'm making. I have the calendar itself working fine, now I'm trying to put the event titles on to it. But I'm have problems getting items for a particular date. My date field is a timestamp in mysql. Any help would be appreciated. here's my code: $e = mysqlSelect($_tables['squirrel_post'], "post_slug, title, date", "WHERE date = $date"); if I take the date out -- it works, but then I'm getting all the post rather than just the post of that day. Also, I know that it's passing the date as 2008-7-6 -- which isn't right either. by the way.. here's the code for my mysqlSelect function --- which is complete function (lol) function mysqlSelect($from, $what="*", $conditions=""){ $query = "SELECT $what from $from $conditions"; $r = lib_executeQuery($query) or die(mysql_error()); return $r; } function lib_executeQuery($query,$dbLink=""){ // Execute an SQL query passed to this function if($dbLink){ $link = $dbLink; } else { $link = lib_databaseConnect(); } $dbResult = mysql_query($query, $link) or die ("Database Class: MySQL Error: " . mysql_error() ); return $dbResult; }
  8. Ok.... I figured it out, but here's the answer for anyone else getting stuck on this issue ------- please not mysqlSelect is a custom function for rewiting a query statement ---------------- $a = mysqlSelect($_tables['directory']); while($k = mysql_fetch_assoc($a)){ // check members dues $z = mysqlSelect($_tables['member_dues'], "dues_id", "WHERE directory_id = " . $k['directory_id']); $count = mysql_num_rows($z); if($count == 0){ echo $x . $k['lname'] . "<br />"; } }
  9. Ok, here's an odd situation that I just can't figure out. I have to tables. A directory table and a dues table. The dues table contains a payment for any member that has paid with the id of their associated record in the directory tables. IE. payment 2007 for id 2 -- id 2 is Bob. If I do a join function I can easily find all the members that have paid for the year. NOW.... how do I find the members that haven't paid? I know it's something like if the id doesn't exist in dues then show it as a record from directory. But how dow I do that exactly? tables: dues --> dues_id, directory_id, amount, year, check_num directory --> directory_id, fname, lname
  10. interesting... I just saw I had a typo too. It does work as I wrote it (typo fixed) -- but I don't know if that is proper coding. So I'll stick with the call_user_func(). Thanks again.
  11. I'm trying to condense some of my code. I have some very similar functions that I want to make into 1 main function. Basically what it does is query the db then spit out a list of content which is formatted by another function called in the where loop: ex: function list_instructor_widget(){ // list of instructor_widget() global $_tables; $l = ""; $q = mysqlSelect($_tables['cminstructors'], 'id', "ORDER BY instructor ASC"); while($i = @mysql_fetch_assoc($q)){ $l .= instructor_widget($i['id']); } return $l; } Some have more complicated queries, but the thought is that I can pass the query into the function. The only problem is how to change the inner function? I tried this, but it didn't work: function list_widget($table, $queryitem, $widget, $conditions=""){ // creates a list out of individual widgets global $_tables; $l = ""; $q = mysqlSelect$table, $queryitem, $conditions); while($i = @mysql_fetch_assoc($q)){ $l .= $widget($queryitem); } return $l; } echo list_widget($_tables['cminstructors'], "id", "instructor_widget", "ORDER BY instructor ASC"); Any ideas? Is this even doable?
  12. yeah -- I think that's what I'm looking for But I should have mentioned that not everything happens on the index page. For example: /home/ and /about_us/ are both currently at index.php?page=home & index.php?page=about_us However, /classes/ and /schedule/ are located on their own pages /classmanager/index.php & /classmanager/schedule.php Is this going to make a difference?
  13. Hi All, I'm trying to make my code more "multiple" server friendly , because I'm finding I have to hack at it anytime I use it for a new client and whatever server configuration they have. SOOO... I want to be able to create links on the fly. I would have some config some where that would state whether to use conventional links or friendly links. If I'm using friendly links, I want to pass this off to be figured out within the php rather than in the .htaccess file. Basically, I want to do what WordPress has done so well. Does anyone know how they did this, or has any tutorials about going about this? Thanks.
×
×
  • 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.