Jump to content

piznac

Members
  • Posts

    261
  • Joined

  • Last visited

Everything posted by piznac

  1. [!--quoteo(post=369276:date=Apr 27 2006, 12:38 PM:name=zachishi)--][div class=\'quotetop\']QUOTE(zachishi @ Apr 27 2006, 12:38 PM) [snapback]369276[/snapback][/div][div class=\'quotemain\'][!--quotec--] Please view this code and tell me if there is a way to duplicate the center section that is in red. <?php include_once("includes/startup.php"); $cat=$_GET['id']; $query="SELECT * FROM ".TABLE_PREFIX."categories WHERE cat_id='$cat'"; if(isset($_GET['pool']) && $_GET['pool']!='') [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]{ $qry1='AND with_pool=1 '; }else{ $qry1=''; }[!--colorc--][/span][!--/colorc--] $rs=$conn->Execute($query); $arr=$rs->fields; $query1="SELECT id,pname,sleep,type,thumb FROM ".TABLE_PREFIX."properties WHERE type='$cat' $qry1 order by q_id desc"; //print $query1; $rs1=$conn->Execute($query1); $test=$rs1; $image_count=$test->RecordCount(); ?> This section calls some information that is displayed in another page. I need to duplicate this on this page and let them co-exist. Is this possible. I have tryed every way i know how and cant get it to work. I am very new at this and am working off a site someone else created. Please help [/quote] Dont know if this is what you need. But you can typically just rename the variable and repeat the same if statement. i.e. if(isset($_GET['pool']) && $_GET['pool']!='') [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]{ $qry1='AND with_pool=1 '; }else{ $qry1=''; }[!--colorc--][/span][!--/colorc--] if(isset($_GET['pool']) && $_GET['pool']!='') [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]{ $qry2='AND with_pool=1 '; }else{ $qry2=''; }[!--colorc--][/span][!--/colorc--] then change the variable when it is called. Really need to see all the code. But this might work for you.
  2. first and foremost .. thank you for taking the time to do this. But I'm still confused. I have inserted my connection and query script. And it does diplay the queries. But how would I then make that query work? Maybe Im being dumb here but Ive been working on this all morning and cant figure it out. I assume that this script was never meant to work but just to help explain it to me. But now I dont know what to take from this script and apply it to make it work. Maybe that dosent make sense, it dosent to me! I dont think Im advanced enough to make this happen but alas,...I must. If you can maybe just explain this script with some comments,..it would help. I know this is asking alot and you have already helped some much.
  3. [!--quoteo(post=368146:date=Apr 24 2006, 04:47 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Apr 24 2006, 04:47 PM) [snapback]368146[/snapback][/div][div class=\'quotemain\'][!--quotec--] Why don't you use array references for the name which would make the you code to add it to the database quite easy. Plus the names of your text boxes would always be the same, so your Javascript wouldn't have to figure out what's the next number to add to the name. The names would be "$rm[]",$dm[],$store[],$pto[],$pda[] & $date[]" The form method really should be "post". In you code to process the data, you should have something like: [code]<?php $fields = array('rm','dm','store','pda','date'); for ($i=0;$i<count($_POST['rm'];$i++) {     $qtmp = array();     foreach($fields as $fld)          $qtmp[] = $fld . " = '" . mysql_real_escape_string(trim(stripslashes($_POST[$fld][$i]))) . "'";     $query = "insert into table_name set " . implode(', ',$qtmp);     $rs = mysql_query($query) or die('Problem with query(' . $i . '): ' . $query . '<br>' . mysql_error()); } ?>[/code] Ken [/quote] Ken, I guess I'm still a newbie with this stuff. Anyway can I talk you into explaining this with a little more detail.
  4. I have a form with 5 text boxes. I have a "add row" javascript applied to this form or rather the table itself. Now when "add row" is pressed it creates another row with the same text boxes but with a "marked up" name and id. somthing like this. text fields: rm,dm,store,pto,pda & date The resulting variables are:(these can be post or get) $rm1,$dm1,$store1,$pto1,$pda1 & $date1 Now when a row is added it looks like this: $rm2,$dm2,$store2,$pto2,$pda2 & $date2 $rm3,$dm3,$store3,$pto3,$pda3 & $date3 ...and so on... so my questions is how do I get these variables back to the database. I assumed I would have to write some sort of foreach or while loop. with the sql being the output $sql = "INSERT INTO tbl_name (rm,dm,store,pto,pda,date) VALUES($rm1,$dm1,$store1,$pto1,$pda1,$date1);" but I confused on how to write this loop statement, do I need an array? I really dont even know where to start...any help would be great.
  5. [!--quoteo(post=365661:date=Apr 17 2006, 04:24 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Apr 17 2006, 04:24 PM) [snapback]365661[/snapback][/div][div class=\'quotemain\'][!--quotec--] This will fix it: [code]<?php $accident_date = 'March 8, 2006'; $acc_ts = strtotime($accident_date); // Get UNIX Timestamp (number of seconds since 1/1/1970) $today = time(); // Get the UNIX timestamp for today $days = 0; for ($test = $acc_ts; $test <= $today; $test += 86400) { // 86400 = number of seconds in a day      $dy = date('l',$test); // Thats a lowercase L, not an uppercase i or number 1. Gives day of week      if ($dy != 'Saturday' &&  $dy != 'Sunday') $days++; // if the day isn't a Saturday or Sunday count it. } echo 'Days since last accident: ' . $days; ?>[/code] I had used the wrong function to get the UNIX timestamp for the accident_date and I left off the $ in the for loop. Ken [/quote] That is just awesome. Thanks so much!!
  6. [!--quoteo(post=365586:date=Apr 17 2006, 12:56 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Apr 17 2006, 12:56 PM) [snapback]365586[/snapback][/div][div class=\'quotemain\'][!--quotec--] The easiest way (may not be the most efficient) would be to convert the accident date to a UNIX timestamp and count from there until today, counting all days (excluding Saturdays & Sundays) For example: [code]<?php $accident_date = 'March 8, 2006'; $acc_ts = time($accident_date); // Get UNIX Timestamp (number of seconds since 1/1/1970) $today = time(); $days = 0; for ($test = acc_ts; $test <= $today; $test += 86400) { // 86400 = number of seconds in a day      $dy = date('l',$test); // Thats a lowercase L, not an uppercase i or number 1. Gives day of week      if ($dy != 'Saturday' &&  $dy != 'Sunday') $days++; } echo 'Days since last accident: ' . $days; ?>[/code] Note: this code hasn't been tested. Ken [/quote] Thanks for your help Ken. Ok I don't really understand this bit of code. Now I know you said it wasnt tested but its displaying 9468 days. How did it come to that conclusion? Im confused. Just a little more help please [!--quoteo(post=365649:date=Apr 17 2006, 03:56 PM:name=piznac)--][div class=\'quotetop\']QUOTE(piznac @ Apr 17 2006, 03:56 PM) [snapback]365649[/snapback][/div][div class=\'quotemain\'][!--quotec--] Thanks for your help Ken. Ok I don't really understand this bit of code. Now I know you said it wasnt tested but its displaying 9468 days. How did it come to that conclusion? Im confused. Just a little more help please [/quote]
  7. Ok,..little help needed. I need to have a script that will count up days from a specific date excluding weekends and holidays. And display the results on a webpage. Example: 30 days worked since last accident. I need this to work automatically and be able to reset it to the current date when an accident occurs (reset manually, with the click of a button would be best. I had thought about the date being stored in a mysql DB and using that as a variable, so you could update the date via web form and it would change the data. But not sure if that would work). I have no idea where to start on this one. I know a way to do it in VB coding, due to a co worker having to do the same thing on a spreadsheet. But that will not work here. Does anyone know of a php function that will do this? any help would be great from an entire script to a push in the right direction. Thanks
  8. Ok nevermind -- it seems to be working now -- I just took the isset out. Thanks
  9. Hi all you have been some much help in the past so I got a new one for you. How do I tell php that a form box has been checked. I have a check box on a form that gets sent to a php page that depending on wether or not it is checked it should send an email. Can someone tell me where i am going wrong. Here is my code: [code]if (isset($ce)){ mail($recipient,$msg,$subject); }[/code] where $ce being my varible for the check box sent via a url parameter Thanks
  10. Jamie, Thanks for the help...one more question. This statement has me a bit confused = Normally, you do not need to lock tables, because all single UPDATE statements are atomic; no other thread can interfere with any other currently executing SQL statement. does this mean I should not worry about locking table, because it does it by itself?
  11. Hey guys, I have a form that updates a mysql db. I will have multiple user updating it. I need a script that will some how lock the form from user a when user b is using the form...I found a tutorial for this but it was in .asp --- of course in need this in .php --- any help would be great Using - Dreamweaver 8 mysql php 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.