Jump to content

mdmartiny

Members
  • Content Count

    185
  • Joined

  • Last visited

Everything posted by mdmartiny

  1. I wrote this function and the query is returning a false every time. I am connected to the database. I ran the query in phpadmin to see if it was something that I wrote improperly and it runs just fine in there. I have looked it over and had rewritten it based on information that I had found while searching articles and other forums. Nothing is changing with the outcome. What am I doing wrong? what am I missing? function category($dbc, $type) { echo '<div class="form-group"> <label for="category">Category</label>'; $stmt = $dbc->prepare("SELECT * FROM `category` WHERE type = ?"); $stmt->bind_param("i", $type); $stmt->execute(); $stmt->store_result(); $result = $stmt->get_result(); echo '<select class="form-control" id="category" name="category">'; while ($row = $result->fetch_assoc()){ echo '<option value="'.$row['id'].'">'.$row['category'].'</option>'; } echo '</select>'; echo '</div>'; $stmt->free_results(); $stmt->close(); }
  2. I see what you are saying now by counter. I can figure out the rest on my own. Thank you
  3. How would I use a counter to do this?
  4. In a section of a script that I am writing I output the number of records for the person logged into the system. so it looks something like this. 13 of 5 (13 being the id and 5 being the total number of records). What I want to do is get something like this 1 of 5 It doesn't show the record id but the number of the record for that person. Would this be a pagination thing or is there another way of doing this?
  5. This is the code output from the server side <div class="row compose-form"> <div class='email-header' style='border-bottom: none; margin-bottom: 25px;'><P>cndjvnjvnjfenvjev</P></div> <div class="row"> <div class="col-md-12"> <div class="col-md-6"><span class="to"> <strong>Michael Martiny</strong></span></div> <div class="col-md-6"><span class="to pull-right"> <a href="#" class="show_hide" rel="#slidingDiv_0"><i class="fa fa-caret-square-o-down" aria-hidden="true"></i></a> 02-14-2017 (23 days ago)</span> </div> </div> </div> <div class = "slidingDiv" id="slidingDiv_0"> <div class="row"> <div class="col-md-12"> <div class="email-content"> <p>Bacon ipsum dolor amet pork loin pork belly short loin, ham capicola biltong meatball beef shoulder brisket. Short loin ball tip turkey turducken fatback filet mignon landjaeger frankfurter pork belly andouille flank, ham beef. Salami andouille strip steak biltong pancetta jerky sirloin shankle tail prosciutto ground round cow leberkas spare ribs venison. Sausage tail frankfurter burgdoggen fatback boudin ham. Short ribs alcatra t-bone picanha, pork chop prosciutto ham beef ribs chuck venison pastrami beef rump shankle meatball.</p> </div> </div> </div> </div> <hr class="mail-controls-divider"> <div class="col-md-12 reply-form"> <form role="form" class="form-horizontal" action="http://martinicms.dev/admin/mail//index.php?page=email&id=13" method="post" enctype="multipart/form-data"> <div class="form-group"> <input type="hidden" name="from" value="1"> <input type="hidden" name="for" value="1"> <input type="hidden" name="date" value="2017/03/09 08:09:10 pm"> <input type="hidden" name="subject" value="cndjvnjvnjfenvjev"> <input type="hidden" name="originalMessage" value="13"> </div> <div class="form-group"> <div class="col-md-12"> <textarea class="form-control" name="inputBody" id="inputBody" rows="5"></textarea> </div> </div> <div class="form-group"> <div class="col-sm-12"> <input type="reset" class="btn btn-warning" name="clear" id="clear" value="Clear"> <input type="submit" class="btn btn-primary" name="sent" id="sent" value="send"> </div> </div> </form> </div> <div class="row"> <div class="col-md-12"> <div class="col-md-6"><span class="to"> <strong>Michael Martiny</strong></span></div> <div class="col-md-6"><span class="to pull-right"> <a href="#" class="show_hide" rel="#slidingDiv_1"><i class="fa fa-caret-square-o-down" aria-hidden="true"></i></a> 02-17-2017 (20 days ago)</span> </div> </div> </div> <div class = "slidingDiv" id="slidingDiv_1"> <div class="row"> <div class="col-md-12"> <div class="email-content"> <p>Bacon ipsum dolor amet irure corned beef adipisicing turkey. Boudin cow short loin pancetta, duis shank cupim alcatra ribeye in laborum. Aliqua chuck cupim, capicola andouille duis commodo. Aliqua dolore jerky, exercitation reprehenderit sausage est brisket.</p> <p>Shoulder boudin officia, et elit cow voluptate. Swine incididunt dolore sed in pork kielbasa sirloin meatloaf qui shankle dolore boudin fugiat. Leberkas tail flank turducken eiusmod pancetta, burgdoggen ut. Turkey consectetur pork, drumstick strip steak ea velit porchetta anim. Ham hock cillum ipsum, turducken short ribs picanha landjaeger. Est burgdoggen kevin pancetta boudin. Short loin short ribs dolor picanha jowl.</p> </div> </div> </div> </div> <hr class="mail-controls-divider"> <div class="row"> <div class="col-md-12"> <div class="col-md-6"><span class="to"> <strong>Michael Martiny</strong></span></div> <div class="col-md-6"><span class="to pull-right"> <a href="#" class="show_hide" rel="#slidingDiv_2"><i class="fa fa-caret-square-o-down" aria-hidden="true"></i></a> 02-17-2017 (20 days ago)</span> </div> </div> </div> <div class = "slidingDiv" id="slidingDiv_2"> <div class="row"> <div class="col-md-12"> <div class="email-content"> <p>Is this working</p> </div> </div> </div> </div> <hr class="mail-controls-divider"> <div class="row"> <div class="col-md-12"> <div class="col-md-6"><span class="to"> <strong>Michael Martiny</strong></span></div> <div class="col-md-6"><span class="to pull-right"> <a href="#" class="show_hide" rel="#slidingDiv_3"><i class="fa fa-caret-square-o-down" aria-hidden="true"></i></a> 03-09-2017 (17 hours, 13 minutes ago)</span> </div> </div> </div> <div class = "slidingDiv" id="slidingDiv_3"> <div class="row"> <div class="col-md-12"> <div class="email-content"> <p>Bacon ipsum dolor amet alcatra shank fatback cupim pastrami picanha filet mignon. Short loin shank pig, porchetta capicola sausage short ribs alcatra ball tip venison landjaeger cow. Beef prosciutto shankle, kevin picanha leberkas drumstick cow spare ribs brisket short loin. Kevin ball tip boudin sausage, short ribs tenderloin bresaola picanha shoulder ground round pig corned beef capicola frankfurter. Kielbasa pancetta ball tip meatball tri-tip. Landjaeger andouille strip steak salami tongue. Drumstick pig porchetta, frankfurter kielbasa shoulder leberkas ribeye meatloaf jowl filet mignon tail.</p> <p>Hamburger ham hock jerky fatback, short loin shankle pork loin turducken tail sirloin turkey venison shank salami chicken. Boudin shoulder short loin porchetta tail pork belly shankle leberkas chicken flank jowl ground round brisket pork loin landjaeger. Shank spare ribs capicola pork bresaola swine meatball frankfurter shoulder pastrami pig pork chop kevin shankle. Pork belly turkey strip steak frankfurter corned beef shankle.</p> <p>T-bone burgdoggen picanha flank. Shoulder strip steak tri-tip pork chop, t-bone filet mignon tongue shank capicola pork landjaeger. Bacon jerky salami boudin bresaola meatloaf flank tail kevin picanha pastrami capicola. Venison ham hock pork belly ball tip, jowl drumstick bacon pork chop ground round pork t-bone capicola.</p> <p>Meatball ham boudin cow bacon ribeye tenderloin rump andouille cupim sausage pork belly chuck flank. Brisket ball tip ham beef ribs. Picanha shankle ribeye andouille. T-bone pork bresaola, capicola ground round cupim andouille frankfurter jerky. Burgdoggen tongue capicola corned beef, pork chop bacon pork. Turkey pig pork alcatra pastrami sausage boudin ham hock brisket picanha strip steak cow andouille tail.</p> <p>Prosciutto ground round alcatra burgdoggen. Turducken shank ball tip landjaeger, kevin bresaola doner ham hock burgdoggen. Capicola pancetta kielbasa sirloin turkey. Tri-tip pancetta short loin beef bresaola beef ribs kevin meatloaf flank landjaeger.</p> </div> </div> </div> </div> <hr class="mail-controls-divider"> </div>
  6. I have a script that creates numerous dynamic divs based on the information that it gets from the database. One of these divs I would like to be the last div in no matter how many divs there are. I am not an expert in CSS in any way. I do not know what I am doing wrong with the code that I am using. The div I want at the bottom gets moved but it also gets covered up with the previous div contents. This is the CSS that I am using .compose-form{ margin-left: auto; margin-right: auto; border-radius: 5px; padding: 20px; width: 90%; border: 1px solid #000; background-color: white; margin-bottom: 20px; min-height: 500px; position: relative; } .reply-form { position: absolute; bottom: 0; margin-bottom: 10px; } .email { background: white; border: 1px solid black; min-height:600px; } .email-header { font-size: 20px; line-height: 40px; height: 30px; margin-left: 2px; margin-bottom: 2px; font-weight: 600; padding-bottom: 40px; border-bottom: 1px solid black; } .to { font-size: 15px; ; line-height: 30px; } .email-content { margin-left: 16px; padding-top: 1px; } .slidingDiv { position: relative; display: none; } [class='slidingDiv']:last-of-type { display: block; } This is my HTML/PHP file <div class="row"> <div class="col-md-12"> <div class="col-md-6"><span class="to"> <strong><?php echo $message['to']; ?></strong></span></div> <div class="col-md-6"><span class="to pull-right"> <a href="#" class="show_hide" rel="#slidingDiv_<?php echo $counter; ?>"><i class="fa fa-caret-square-o-down" aria-hidden="true"></i></a> <?php echo date("m-d-Y", strtotime($message['sent']));?> (<?php echo getTimeSince($message['sent']).' ago'; ?>)</span> </div> </div> </div> <div class = "slidingDiv" id="slidingDiv_<?php echo $counter; ?>"> <div class="row"> <div class="col-md-12"> <div class="email-content"> <?php echo $message['body']; ?> </div> </div> </div> </div> <hr class="mail-controls-divider"> <?php if ($counter == 0) { ?> <div class="col-md-12 reply-form"> <form role="form" class="form-horizontal" action="<?php echo MAIL_URL; ?>/index.php?page=email&id=<?php echo $_GET['id']; ?>" method="post" enctype="multipart/form-data"> <div class="form-group"> <input type="hidden" name="from" value="<?php echo $user['id']; ?>"> <input type="hidden" name="for" value="<?php echo $message['sent_to']; ?>"> <input type="hidden" name="date" value="<?php echo date('Y/m/d h:i:s a', time()); ?>"> <input type="hidden" name="subject" value="<?php echo $message['subject']; ?>"> <input type="hidden" name="originalMessage" value="<?php echo $_GET['id']; ?>"> </div> <div class="form-group"> <div class="col-md-12"> <textarea class="form-control" name="inputBody" id="inputBody" rows="5"></textarea> </div> </div> <div class="form-group"> <div class="col-sm-12"> <input type="reset" class="btn btn-warning" name="clear" id="clear" value="Clear"> <input type="submit" class="btn btn-primary" name="sent" id="sent" value="send"> </div> </div> </form> </div> <?php } $counter++; } ?> I have even added a screenshot of what it looks like when it is rendered
  7. How else would I set it up differently? This is how I have always set up while loops.
  8. I am writing a script for a personal mail system in a CMS system. It produces multiple dynamic divs one the page listing out all of the messages. I have done this using a while loop. At the bottom of the page, I have placed a reply box. I need some of the information from the query in the while loop but I can't get the info outside of the while loop. This is the code that I have so far. I have tried using the counter == 0 on it and that does not work. I have tried doing a variable $message = '' on the outside of the loop but that does not work. Line 42 and 44 is where I am trying to place the variables. <div class="row compose-form"> <?php $id = $_GET['id']; $que = "SELECT mail.*, CONCAT(s_t.first, ' ', s_t.last) AS 'to', CONCAT(s_b.first, ' ', s_b.last) AS 'for' FROM mail INNER JOIN users AS s_t ON mail.sent_to = s_t.id INNER JOIN users AS s_b ON mail.sent_by = s_b.id WHERE mail.id = '$id' OR mail.replied_to = '$id' ORDER BY mail.sent DESC"; $res = mysqli_query($dbc, $que); $counter = 0; while ($message = mysqli_fetch_assoc($res)) { if($counter == 0) { echo "<div class='email-header' style='border-bottom: none; margin-bottom: 25px;'>"; echo "<P>".$message['subject']."</P>"; echo "</div>"; } $counter++; ?> <div class="row"> <div class="col-md-12"> <div class="col-md-6"><span class="to"> <strong><?php echo $message['to']; ?></strong></span></div> <div class="col-md-6"><span class="to pull-right"> <a href="#" class="show_hide" rel="#slidingDiv_<?php echo $counter; ?>"><i class="fa fa-caret-square-o-down" aria-hidden="true"></i></a> <?php echo date("m-d-Y", strtotime($message['sent']));?> (<?php echo getTimeSince($message['sent']).' ago'; ?>)</span> </div> </div> </div> <div class = "slidingDiv" id="slidingDiv_<?php echo $counter; ?>"> <div class="row"> <div class="col-md-12"> <div class="email-content"> <?php echo $message['body']; ?> </div> </div> </div> </div> <hr class="mail-controls-divider"> <?php } ?> <div class="col-md-12"> <form role="form" class="form-horizontal" action="<?php echo MAIL_URL; ?>/index.php?page=email&id=<?php echo $_GET['id']; ?>" method="post" enctype="multipart/form-data"> <div class="form-group"> <input type="hidden" name="from" value="<?php echo $user['id']; ?>"> <input type="hidden" name="for" value="<?php echo $message['sent_to']; ?>"> <input type="hidden" name="date" value="<?php echo date('Y/m/d h:i:s a', time()); ?>"> <input type="hidden" name="subject" value="<?php echo $message['subject']; ?>"> <input type="hidden" name="originalMessage" value="<?php echo $_GET['id']; ?>"> </div> <div class="form-group"> <div class="col-md-12"> <textarea class="form-control" name="inputBody" id="inputBody" rows="5"></textarea> </div> </div> <div class="form-group"> <div class="col-sm-12"> <input type="reset" class="btn btn-warning" name="clear" id="clear" value="Clear"> <input type="submit" class="btn btn-primary" name="sent" id="sent" value="send"> </div> </div> </form> </div> </div>
  9. Is there a way to force a div to automatically being placed at the bottom of other divs? I a PHP script that creates a bunch of dynamic divs and one, in particular, I would like to force to be at the bottom of all the other divs.
  10. If I echo out the $dir variable it has 'mail' in it.
  11. This is my file structure -htdocs - cms -admin - mail index.php Using $_SERVER['REQUEST_URI'] in the index page. My Url will look like this www.example.dev/admin/mail/index.php?page=inbox if the query string is not attached to the URL. It should automatically place the variable there based on the file being in the mail folder. I am trying to get a variable for the mail folder of the URI. ($dir = $path_parts[2]). If the directory equals mail. It opens the "inbox" portion of the page variable; if not it defaults to the "dashboard". When I run the script that I currently get a blank page. The page does not get the "inbox" variable.
  12. I am trying to write a small script to run a file based on the directory that it is in. I have tried several different ways of doing this and none of them are working? I do not know what I am doing wrong and I am going insane. $path_parts = pathinfo($_SERVER['REQUEST_URI']); $path_parts = explode('/', $path_parts['dirname']); $path_parts = array_filter($path_parts); $dir = $path_parts[2]; echo $dir; if (isset($_GET['page'])) { $page = $_GET['page']; } else if ($dir = 'mail') { $page = 'inbox'; } else { $page = 'dashboard'; } The above code is what I have come up with so far.
  13. The counter is only there to count the number of divs that I have in in the while loop. I moved the counter++; to the end and it worked perfectly. Thank You.
  14. I tried that and it did not work. It still iterates through every loop.
  15. Thanks I did not think of that. I was actually using the counter for something else but I will give that a try.
  16. I am in the process of writing a personal mail system for something that I am working on. I am setting the system up that when you open the message. It shows the original message and all messages associated with the original message. I am doing this with a while loop. I do not want to, however, show the message subject with every iteration of the while loop. How do I make it only show the subject once and run through the rest of the while loop? This is the code that I have so far. <div class="row compose-form"> <?php $id = $_GET['id']; $que = "SELECT mail.*, CONCAT(s_t.first, ' ', s_t.last) AS 'to', CONCAT(s_b.first, ' ', s_b.last) AS 'for' FROM mail INNER JOIN users AS s_t ON mail.sent_to = s_t.id INNER JOIN users AS s_b ON mail.sent_by = s_b.id WHERE mail.id = '$id' OR mail.replied_to = '$id' ORDER BY mail.sent DESC"; $res = mysqli_query($dbc, $que); $counter = 0; while ($message = mysqli_fetch_assoc($res)) { $counter++; ?> <div class="email-header"> <P><?php echo $subject['subject']; ?></P> </div> <div id="toggler-<?php echo $counter; ?>"> <div class="row"> <div class="col-md-12"> <div class="col-md-6"><span class="to"> <strong><?php echo $message['to']; ?></strong></span></div> <div class="col-md-6"><span class="to pull-right"> <?php echo date("m-d-Y", strtotime($message['sent']));?> (<?php echo getTimeSince($message['sent']).' ago'; ?>)</span> </div> </div> </div> <div class="toggler-hide-<?php echo $counter; ?>"> <div class="row"> <div class="col-md-12"> <div class="email-content"> <?php echo $message['body']; ?> </div> </div> </div> </div> </div> <hr class="mail-controls-divider"> <?php } ?>
  17. echo '<option value="'.$user_data['id'].'"'.if ($user_data['id'] == $opened['id']){"selected"}.'>'.$user_data['fullname'].'</option>'; Can someone please explain why this is not working properly? What am I doing wrong
×
×
  • 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.