Jump to content

dannyo101

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

dannyo101's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. sorry, please disregard that last post. everything is working as expected. thanks for your time and help with this issue.
  2. yes, thanks that seems to work; however, how do I assign the key in the array to be the id of the database record? In my example, the ids are sequential 1,2,3,4 so everything works fine.. But what if I have 4 rows, with ids 1, 5, 7, and 8 and want to assign the values of the array to those keys?
  3. I changed the code to use $_POST['suid'] instead of $_POST['id'], but something still isn't right... Here is how the _POST is formatted: Array ( [submit_e] => Apply [suid] => Array ( [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 ) [uname] => Array ( [1] => gen.us3r! [2] => admin!2009 [3] => wfgc [4] => shelterharbor [5] => concordcc ) [desc] => Array ( [1] => User Login1 [2] => Administrator Login [3] => User Login [4] => User Login [5] => User Login ) [nw_role] => Array ( [1] => user [2] => admin [3] => user [4] => user [5] => user ) [df_start_dt] => Array ( [1] => 10/20/2009 [2] => 10/20/2009 [3] => 01/11/2010 [4] => 01/10/2010 [5] => 01/11/2010 ) [df_end_dt] => Array ( [1] => 11/30/2010 [2] => 10/20/2010 [3] => 01/11/2011 [4] => 03/01/2010 [5] => 03/01/2010 ) ) When I print each value of the array, it seems to be breaking up the word into separate elements. For example: echo $uname[1] produces 'o' echo $uname[2] produces 'n' echo $uname[3] produces 'c' echo $uname[4] produces 'o' The code works fine in PHP4 for me, which is why I'm having some trouble figuring this out.
  4. thanks...here's the form blow. the var_dump produces NULL: <?php echo ' <form name="users" method="post" action="'.$_SERVER['PHP_SELF'].'"> <table width="100%" border="0"> <tr>'; if ($pgaction=='add') { echo '<td><input type="submit" name="submit_a" value="Add Record" style="height: 25px; width: 100px"> <input type="submit" name="reset" value="Cancel" style="height: 25px; width: 100px"></td>'; } if ($pgaction=='edit') { echo '<td><input type="submit" name="submit_e" value="Apply" style="height: 25px; width: 100px"> <input type="submit" name="reset" value="Cancel" style="height: 25px; width: 100px"></td>'; } if (($pgaction<>'add')&&($pgaction<>'edit')) { echo ' <td> <input type="submit" name="add" value="Add" style="height: 25px; width: 100px"> <input type="submit" name="edit" value="Edit" style="height: 25px; width: 100px"> <input type="submit" name="reset" value="Cancel" style="height: 25px; width: 100px"> </td>'; } echo' <td> </td> <td align="right"> <input type="submit" name="rpt" value="View History" style="height: 25px; width: 100px"> <input type="submit" name="clear_hist" value="Clear History" style="height: 25px; width: 100px"></td> </tr> <tr> <td colspan="3">'; if ($_POST['rpt']||$rpt==1) { echo '<table id="user_rpt" class="zebra-sm"> <thead> <tr> <th>User/Password</th> <th>Login Date</th> </tr> </thead> <tbody>'; while ($row_b = mysql_fetch_assoc($sql_b)) { echo '<tr><td>'; echo $row_b['username']; echo '</td><td>'; echo $row_b['access_date']; echo '</td></tr>'; } } else { echo '<table id="user_sum" class="zebra"> <thead> <tr> <th>User/Password</th> <th>Description</th> <th>Role</th> <th>Start Date</th> <th>End Date</th> <th>Last Login</th> <th>Status</th> </tr> </thead> <tbody>'; while ($row_a = mysql_fetch_assoc($sql_a)) { $id=$row_a['suid']; echo '<tr><td><input type="hidden" name="suid['.$id.']" value="'.$id.'">'; if ($pgaction=='edit') { echo '<input type="text" size="25" name="uname['.$id.']" value="'.$row_a['username'].'" style="padding: 0;">'; } else { echo $row_a['username']; } echo '</td><td>'; if ($pgaction=='edit') { echo '<input type="text" size="30" name="desc['.$id.']" value="'.$row_a['description'].'" style="padding: 0;">'; } else { echo $row_a['description']; } echo '</td><td>'; if ($pgaction=='edit') { if ($row_a['role']=="admin") { $opt='<option value="admin" selected>admin</option> <option value="user">user</option>'; } else { $opt='<option value="admin">admin</option> <option value="user" selected>user</option>'; } echo '<select name="nw_role['.$id.']" style="padding: 0; height: 20px" > '.$opt.' </select>'; } else { echo $row_a['role']; } echo '</td><td>'; if ($pgaction=='edit') { echo '<input style="padding: 0;" class="start_dt" type="text" name="df_start_dt['.$id.']" size="10" value="'.$row_a['start_date'].'" /> </td><td> <input style="padding: 0;" class="end_dt" type="text" name="df_end_dt['.$id.']" size="10" value="'.$row_a['end_date'].'" /> </td><td>'; } else { echo $row_a['start_date']; echo '</td><td>'; echo $row_a['end_date']; echo '</td><td>'; } echo $row_a['last_login'].' '; echo '</td><td>'; echo $row_a['status']; echo '</td></tr>'; } if ($pgaction=='add') { echo $rec_add; } echo '</tbody> </table> </td> </tr> <tr> <td colspan="3">'.$error_msg.'</td> </tr>'; } echo '</table></form>'; } ?>
  5. I have some code running on PHP4 that I moved to a new hosting account running PHP5. I'm having an issue posting the values of my arrays after moving to PHP5. This is the part of my code that isn't working anymore: foreach($_POST['id'] as $t_id){ $suid=$_POST['suid'][$t_id]; $uname=$_POST['uname'][$t_id]; $desc=$_POST['desc'][$t_id]; $nw_role=$_POST['nw_role'][$t_id]; $df_start_dt=$_POST['df_start_dt'][$t_id]; $df_end_dt=$_POST['df_end_dt'][$t_id]; } If I try to output one of the variables, I'm not seeing any values. echo $uname[1];
  6. Yes, that is what should be displayed. That is what I see when I view the page in IE or Chrome, but there is no "sample" image when I view it in Firefox.
  7. I'm having a lot of issues displaying a background image in Firefox (I'm using version 3.5.2). Firefox is reading the CSS file but it is not locating the image to use for the background. I've been at this for a while now so I created a very simple html page to test this. Here is the code I have to test this. Here is the CSS: body { background: url(../images/sample.jpg) repeat-x #005367; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; } Here is my HTML: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>test version</title> <link rel="stylesheet" href="styles/jj_test.css" type="text/css"> </head> <body> <div id="master">this is a test</div> </body> </html> I've also tried various paths in the CSS file, including the full path but I can't get the image to display in Firefox. The page works fine in IE and Chrome - http://dananddonna.com/joedicke/jj/ Any help would be appreciated. I realize I'm probably missing something very obvious but I'm just not seeing it. Thanks!
  8. Even when I set the value attribute for each radio button to be different, the value is duplicated in my results. I set the radio button to this: echo '<input type="radio" name="captain" id="captain" value="'.$id.'">'; In my results, the same number is duplicated. I think the problem is with how I'm handling the $_POST. Any thoughts?
  9. I have a registration form for a tournament. A user must input a persons name & age and indicate if that person is the captian. The form will list 3 lines, 1 for each person. I want to use a radio button to indicate if the person is a captain. There can only be one captain. I the way I have it now, the value is copied for every person. Here is my code: for ( $id = 1; $id <= 5; $id += 1) { echo '<tr><td>'; echo '<input type="hidden" name="p_id['.$id.']" value="'.$id.'">'.$id; echo '</td><td>'; echo '<input name="fname['.$id.']" type="text" maxlength="20" id="fname['.$id.']" size="20">'; echo '</td><td>'; echo '<input name="lname['.$id.']" type="text" maxlength="20" id="lname['.$id.']" size="20">'; echo '</td><td>'; echo '<input type="radio" name="captain" id="captain['.$id.']" value="Y">'; echo '</td></tr>'; } Here is how I'm posting the variables: foreach($_POST['id'] as $f_id){ $p_id=$_POST['p_id'][$f_id]; $fname=$_POST['fname'][$f_id]; $lname=$_POST['lname'][$f_id]; } $cpt=$_POST['captain']; for ($i = 1; $i <= count($p_id); ++$i){ echo '<tr><td>'; echo $i; echo '</td><td>'; echo $fname[$i]; echo '</td><td>'; echo $lname[$i]; echo '</td><td>'; echo $cpt; echo '</td></tr>'; }
  10. I actually have another way that work as well. I'm going to use curdate() instead of now() which will give me the date only (minus the time). I'll rewrite my case statement to return tuesday instead of monday then substract 1 second from it. Something like this: curdate()-INTERVAL 1 second I tested my code for every day of the week and its working... <? include 'db.php'; $test_date = '2007-08-25'; $sql = mysql_query("select now(), case when DAYOFWEEK('$test_date')=2 then (DATE_ADD('$test_date', INTERVAL 1 DAY))-INTERVAL 1 second when DAYOFWEEK('$test_date')=1 then (DATE_ADD('$test_date', INTERVAL 2 DAY))-INTERVAL 1 second else (DATE_ADD('$test_date', INTERVAL 10-DAYOFWEEK('$test_date') DAY))-INTERVAL 1 second end from sv_schedule") or die (mysql_error()); $row = mysql_fetch_row($sql); echo "Current date and time: $row[0]<br />"; echo "Test date: $test_date<br />"; echo "Monday's date: $row[1]<br />"; ?> Thanks anyways!
  11. Hi - I have some code that calculates the next monday date based on the current date. I'm trying to set the monday date to disregard the time in the current date and default to 11:59 PM. I almost have it but getting stuck on the time part. <? include 'db.php'; $test_date = '2007-11-26 23:59:59'; $sql = mysql_query("select now(), case when DAYOFWEEK('$test_date')=2 then '$test_date' when DAYOFWEEK('$test_date')=1 then DATE_ADD('$test_date', INTERVAL 1 DAY) else DATE_ADD('$test_date', INTERVAL 9-DAYOFWEEK('$test_date') DAY) end from sv_schedule") or die (mysql_error()); $row = mysql_fetch_row($sql); echo "Current date and time: $row[0]<br />"; echo "Test date and time: $test_date<br />"; echo "Monday's date: $row[1]<br />"; ?> I want to be able to use any date and time in $test_date and have the monday date always be at 11:59 PM. Any help would be appreciated.
  12. I've been trying to get the Date() function working in my script but haven't been able to. I finally realized that the version of mySQL doesn't suport it.  I'm running on MySQL 4.0.18 I did clean up my algorithm with DAYOFWEEK() but I'm still having problems getting just the date and concatenating the time of 23:59:59 [code] $test_date = '2006-08-08 13:09:59'; $result = mysql_query("SELECT case when DAYOFWEEK('$test_date') > 1 then DATE_ADD('$test_date', INTERVAL 8-DAYOFWEEK('$test_date') DAY) when DAYOFWEEK('$test_date') = 0 then DATE_ADD('$test_date', INTERVAL 1 DAY) else '$test_date' end"); [/code] Any other ideas?  I appreciate the help.
  13. I've created a case statement that will look at a date and return the next Monday.  If the date is a Monday, it will return that date.  What I'm trying to do is return the Monday date and have the time always set to 23:59:59, and this is where I'm running into problems. [code] $test_date = '2006-08-08 13:09:59'; select case when date_format('$test_date', '%w') > 1 then DATE_ADD('$test_date', INTERVAL 8-date_format('$test_date', '%w') DAY) when date_format('$test_date', '%w') = 0 then DATE_ADD('$test_date', INTERVAL 1 DAY) else '$test_date' end [/code] With the code above, a datetime value of 2006-08-14 13:09:59 will be returned.  I would like a datetime value of 2006-08-14 23:59:59 returned. I'm thinking I can setup a variable with the value of 23:59:59 and only use the date part in my CASE statement. Then I could put the 2 values together...not sure if this is the best way to go about it.  Just looking for a little help.  Thanks!
  14. Thanks for your help. I went with the second example you listed and it works for what I need. I appreciate it!
  15. I'm running MySQL version 4.0.18 and PHP version 4.4.1 I've been struggling with this for most of the day and just figured out that the version of MySQL I'm running does not support subqueries, so I'm trying to come up with a workaround to use in my PHP/MySQL script. This is the subquery I have: [code] $list=mysql_query("SELECT t.name FROM team t WHERE t.team_id not in (SELECT p.team_id from sv_pick p WHERE p.entry_id = 1)") or die("SELECT //Error: ".mysql_error()); echo "Available Teams<br>"; while ($tlist=mysql_fetch_row($list)) { echo $tlist[0]."<br>"; } [/code] Can anyone help me come up with a way around using a subquery. I'm still pretty new to PHP and would appreciate any help. 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.