Jump to content

V

Members
  • Posts

    307
  • Joined

  • Last visited

    Never

Everything posted by V

  1. Hmm, the calendar returns the correct format but revises my own format. For example from 2010-07-11 to 07/11/2010 But how can I get that format in my site before using the calendar? Also I'm not sure how it would insert 07/11/2010 in the DB table because in there it uses the TIMEDATE format with the time as well and without the 99/99/9999 format
  2. I use DATETIME in my tables for new posts and via php I use INSERT with the now() function to send the current date and time into the DB whenever something new is posted. It works fine but now I'm trying to find out how to edit a post's date from a php admin page I made. The date appears as 2010-07-11 on the site. I'm using this code which was provided to me on the forum $post_date = substr($row['post_date'], 0, -9); .... echo $post_date; How would I change that to month, day, year? for example 07/11/10 Also in the admin page I use a jquery calendar to edit the dates. So 2010-07-11 changes to 07/14/2010 if I choose day 14 but how will I insert that in the DB using the mysql DATETIME format like this? 2010-14-11 11:56:46 Does anyone know please?
  3. V

    SELECT from more tables

    Very cool! That's much better than what I used to do THanks!
  4. Oooh! I see. Thanks for the support! The time seems to be the same using both methods.
  5. Is it possible to echo out data from 2 tables but without making 2 loops and queries? The code I use now is $sql = "SELECT * FROM posts ORDER BY post_id DESC"; Can I combine it with.. $sql = "SELECT * FROM categories ORDER BY cat_id DESC"; ..and define vars for both in one "while" loop?
  6. Thanks that's what I use but I'm trying to determien the best solution for editing the mysql data from my website.
  7. I reached the level in my project where I have to create an admin page where I can edit and delete mysqli data, more specifically posts and pages. I'm not sure how to approach this. Should I do it via forms or use a CRUD application (which I know little about) I saw a few online tutorials but they all vary so much and some are outdated. What is the best solution nowadays?
  8. Yes that works too Thanks!
  9. Will do! Thanks again!
  10. Hello! This forum has many experts, I however am sort of a noob but allow me to suggest something. First off have you considered using cURL? http://php.net/manual/en/book.curl.php I use cURL to download thumbnail images from Youtube but I use the .jpg extension. Also it might be easier if you retrive images from the website's slideshow image folder, if you have access to it via HTTP
  11. Thanks Thrope! It works perfectly now. Sometimes I consider JS way too compliocated and I overlook the minor errors..
  12. Thanks throbe I tried without clicks but again nothing happens. This is the page code I use <div id="slidedown">+ Add New Category</div> <div id="form"> <form action="#" method="post"> <input type="text" id="cat" name="cat" size="14" /> <br /> <input type="submit" name="submit" id="button" class="submit" value="Add Category"> </form> </div> It works fine just sliding down. Sliding back up is the issue..
  13. I agree use floats or tables. for example float:right or float:left
  14. I don't notice any issue. Perhaps it's visible if teh page takes long to load. Try adding a width to your products menu item so whether the arrow image (I assuem you're refering to that image) loads or not, the tab is the same size.
  15. JoePHP, I think he/she is refering to a contact form. I use this if($_POST) { .....your code... } else { echo "Access Denied!"; }
  16. Throbe, sorry it was a typo I made when posting. The code orginally has the # but doesn't work
  17. I have a text that when click a a HTML form slides down. I'm trying to slide it back up when you click on the text again. The code that works is <script type="text/javascript"> $(document).ready(function(){ $("#slidedown").click(function() { $("#form").slideDown("fast"); }); }); </script> and now to slide it back up on click I tried toggle. Nothing happens tho.. <script type="text/javascript"> $('#slidedown').toggle( click(function() { $('#form').slideDown("fast"); }), click(function() { $('#form').slideUp("fast"); }); ); </script> Please anyone have any suggestions?
  18. In one e-mail? Or is this a global limit that you can't send to more then 300 people? It's the number of people I can email at once, in a certain time-frame (hostmonster). But on emails like Yahoo or AOL I know that the limit is far less. I suppose that sites like Twitter have a lot of web server space reserved for sending emails :-\ I'm thinking that I may need a dedicated server if I plan to send a lot of emails. Unless there's another way to alert people of new posts. That's what I'm trying to figure out.
  19. Thanks for the code! The time varies. It's never the same number. It's 1278718880.3978 then 1278718902.5897
  20. Thanks for the reply. Yup it sounds simple but I'm uncertain about the emailing part. This may be farfetched but for example if I get 8000 subscribers to one category and I post a new article can an email service like yahoo or my host email handle that? I know that my hosting email can send to max 300 people.
  21. ChemicalBliss thanks for the addition and links!! They're very helpful. I have my DB connection in a header.php, I forgot to mention sorry
  22. Wow! Triple reply @ChemicalBliss, thank you for the detailed and clear explanation! I understand foreach much better @wildteen88,AbraCadaver, both the solutions were correct It works perfectly! Btw, does foreach make loading slower? Maybe something else I added is causing it but when I used "while" directly without any function, navigating from one post to another seemed a little faster. Thanks again!!
  23. "while" was easy to understand I don't know how to echo two variables using foreach. First I have a function function show_posts(MySQLi $connection, $category) { $posts = array(); $sql = "SELECT * FROM posts WHERE category_id = '$category' ORDER BY post_date DESC"; while ($row = $result->fetch_object()) { $posts[$row->post_id] = $row->post_title; } return $posts; } And then I echoed the post title but how about the post id (fk) or post date? $posts = show_posts($connection, $category); foreach ($posts as $key => $value){ $post_id = $row["post_id"]; $post_title = $row["post_title"]; $post_date = $row["post_date"]; ?> <li <?php if ($post_id == $post) {print $selected;} ?>><a href="single_post.php?cat=<?php echo $cat; ?>&postID=<?php echo urlencode($post_id); ?>"><?php echo $value; ?></a><br /> <div class="date"><?php echo relativeTime($post_date); ?> </div></li> <?php } ?> I get an empty postID an incorrect post date. Also I'm not sure if using "while" in the function and "foreach" on the another page that uses the function is good :-\ Foreach is really confusing me..
  24. Mchl that's awesome! So I have to pass the vars in the function's parameters Thank you!
  25. I know that variables should be in the scope of a function and I think that can be achived with globals but I also know that using globals is a security treat. I've been reluctant to use functions for this reason but my coding is getting too dense and I need to make evrything more compact. So I attempted to make a fucntion but I get " Undefined variable" errors. For example I want to show all the posts that belong to a category. I wrote this function. function show_posts(){ $posts = array(); $sql = "SELECT * FROM posts WHERE category_id = '$category' ORDER BY post_date DESC"; $result = $connection->query($sql) or die(mysqli_error($connection)); while ($row = $posts_result2->fetch_assoc()) { $posts[$row->post_id] = $row->post_title; } return $posts; } and I tried to use it like this $post = (int)$_GET['post']; $category = (int)$_GET['category']; $posts = show_posts(); foreach ($posts as $key => $value){ echo $key; echo $value; echo "<br />"; } I get I have the DB connection and variables on my page but the function isn't picking them up. Do I have to write the DB connection and vars in every function I make? That just seems like a hassle :-\
×
×
  • 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.