Jump to content

futrose

Members
  • Posts

    64
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

futrose's Achievements

Member

Member (2/5)

0

Reputation

  1. ahhhh... nice. Changing to str_replace took care of the the "[]" problem. Thanks a lot.
  2. thanks, I went with str_replace and it got rid of the errors. I now have this line $body=preg_replace("[date]",$showDateS,$body); on the output it is placing the "[" and "]" around my date. How do I make that go away?
  3. I have this bit of code that was originally ereg but needed changed to preg_match. I'm just not sure where to put the delimiter in these two lines. $ee[$i]=preg_match('-','/',$ee[$i]); and $es[$N]=preg_match('-','/',$es[$N]); thanks.
  4. I have these links where the value of $id is pulled from my database, <a href='javascript: window.document.Vids<?php echo $id; ?>.submit();'>Watch</a> and I would like it to open the video in a separate window. Any idea how to make that happen? Thanks
  5. thanks jcbones. Worked perfectly. I thought i might be something like that but wasn't sure how to implement it.
  6. I have three tables I am using to loop through and get results, ELDERS, ELDERCATEGORY, ELDERCAT. Elders has all the profile of the staff. Eldercat is just a list of staff positions. Eldercategory link the two together by their id's. Here is the whole code, I'll post the snippet in question below. <?php ini_set("display_errors", "1"); error_reporting(-1); $result = mysqli_query($link, 'SELECT * From eldercat'); if (!$result) { $error = 'Error getting elder categories: ' . mysqli_error($link); include 'error.php'; exit(); } while ($row = mysqli_fetch_array($result)){ $eldercat[] = array('id' => $row['id'], 'category' => $row['category']); } foreach ($eldercat as $cat): echo "<div style='font-weight:bold; clear:both'>"; echo $cat['category']; echo "</div>"; $result2 = mysqli_query($link, "Select * from elders inner join eldercategory on elders.id = elderid inner join eldercat on eldercatid = eldercat.id where eldercatid = " . $cat['id'] ." order by orderby"); if (!$result2) { $error = 'Error getting elders in the category: ' . mysqli_error($link); include 'error.php'; exit(); } while ($row2 = mysqli_fetch_array($result2)) { if (($row2['avail']) =='Y') { echo '<div class="smallelderblock">'; echo '<img src = "http://www.bbcpa.org/images/' . ($row2['image']) . '" alt="' . ($row2['LastName']) . ' elders photo" class="elderimg" />'; echo $row2['position'] . '<br />'; echo "<a href='javascript: window.document.LastName" . $row2['id'] . ".submit();'>" . $row2['HFirst']; if (($row2['HFirst'] !="") && ($row2['WFirst'] !="")) { echo ' &amp '; } echo $row2['WFirst'] . " " . $row2['LastName'] . "</a>"; echo "<form name='LastName" . $row2['id'] . "'" . " " . "action='staff-details.php' method='post'>"; echo "<input value='" . $row2['id'] . "'" . "type='hidden' name='ElderDetails' />"; echo "</form>"; echo '</div>'; } } endforeach; ?> $result2 = mysqli_query($link, "Select * from elders inner join eldercategory on elders.id = elderid inner join eldercat on eldercatid = eldercat.id where eldercatid = " . $cat['id'] ." order by orderby"); I am getting the output that I want except for the $row2['id'] lines are displaying the id from the wrong table. I need the id from the elders table but I am getting the id from the eldercat table instead. Any ideas?
  7. I got it to work... thanks for your help guys. I appreciated the examples. I just had to tweak them a bit but all is good for now. Maybe one day I'll have answers to post instead of just questions.
  8. I think I may have been a little confusing. Let me explain better. I have 2 files, index.php and elders_modify.php Here is the code from index.php as I have it right now. $result = mysqli_query($link, "Select * from eldercategory where elderid = '$id'"); if (!$result) { $error = 'Error fetching elder details ' . mysqli_error($link); include '../../includes/error.php'; exit(); } while ($row = mysqli_fetch_array($result)) { if($id != $row['elderid']) { $selected = '0'; } else { $selected[] = array('eldercatid' => $row['eldercatid']); } } the $id is pulled when an admin clicks on a staff member to edit this code tells the elders_modify.php file which categories in the drop down menu to mark as "selected". The code works fine when a staff member has a category assigned to them already. If a staff member does not have a category assigned yet than $selected is empty because $eldercatid is empty. here is the code from elders_modify.php ... <td>Staff Category:</td><td><select name="eldercatid[]" multiple> <?php foreach ($eldercat as $ec): ?> <option value="<?php echo $ec['id']; ?>" <?php if ($action == 'elder_edit') { foreach ($selected as $s); if ($ec['id'] == $s['eldercatid']) { echo 'selected = "yes"'; } } echo '>'; echo $ec['category']; ?></option> <?php endforeach; ?> </select> all I need to do is give $selected a value to carry over from index.php to elder_modify.php when a staff member has no category assigned yet. For some reason my $selected = '0'; isn't recognized.
  9. can you give me an example...? I understand the logic behind your answer but I'm not sure what the code would be to do it.
  10. I have been trying to fix this code snippet because I need to do something different if my variable is empty. $result = mysqli_query($link, "Select eldercatid from eldercategory where elderid = '$id'"); if (!$result) { $error = 'Error fetching elder details ' . mysqli_error($link); include '../../includes/error.php'; exit(); } while ($row = mysqli_fetch_array($result)) { $selected[] = array('eldercatid' => $row['eldercatid']); } here is the code being used on the page using the variable foreach ($selected as $s); if ($ec['id'] == $s['eldercatid']) { echo 'selected = "yes"'; } I need my $selected variable to be equal to anything if $row['eldercatid'] is blank or empty because on the next page I have a call to use $selected but I am getting an error that says undefined variable: selected. I have tried all kinds of lines using if empty and if ($row['eldercatid'] != '') among other stuff but haven't had any luck. I know this probably pretty basic stuff, I just don't know it well enough yet. Thanks for your help.
  11. Got it all sorted out. Code is working as it should. Thanks for your help mjdamato. Had to adjust the line of code to $result = mysqli_query($link, $deleteSql) or die(mysqli_error());
  12. Thanks for the help with this code. I'm pretty close to getting it. I had a question about this line... I think I am missing a '(' somewhere. Is that right? $result = mysql_query($insertSql) or die mysql_error()); also I am using mysqli so I changed the line to this $result = mysqli_query($insertSql) or die mysqli_error()); but I'm still not sure about the '(' issue.
  13. I took a look at the values that were created in the eldercategory table. The INSERT code that you suggested only creates 1 row with an elderid and an eldercatid. What I need it to do is if multiple options are selected create a row for each of the options selected, in the eldercategory table, set the elderid = the new elder id, and the eldercatid to one of the selected categories. So if a staff member is selected to be part of three categories (ie Pastor, Elder, Board member) then there should be 3 rows created like so elderid eldercatid 28 2 28 3 28 7 anyone know how to do that?
  14. Thanks mjdamato for that. Works great. Can you show me what the UPDATE version would be for the same code? I did something like this but it didn't work. //Process each value in the array into a complete UPDATE value $values = array(); foreach($_POST['eldercatid'] as $eldercatid) { $eldercatid = intval($eldercatid); $values[] = "('$eldercatid', '$id')"; } //Create the SQL statemetn using implode on the values $implodearray = implode(', ', $values); $sql = ("Update eldercategory where elderid = $id set $implodearray");
×
×
  • 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.