Jump to content

mystic7

Members
  • Posts

    18
  • Joined

  • Last visited

mystic7's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Josh, I would just LOVE to be able to teach you how to play guitar. I wouldn't show you how to play the chords, that would be like stealing snippets of code. No, I would just tell you what the chords are to a song, and if you get it wrong, I won't tell you the right way, I'll just point out that you're doing it wrong. Then you'll know what it's like asking for advice from a stuck up "programmer" like you. Go ahead and delete my account. I'm sure there are more helpful forums out there. To the rest of you, I'm sorry. That you have to deal with a jerk like Josh.
  2. Every time I try to do something the "right" way I get code that doesn't work. Further research shows that this syntax or that has been "deprecated". In ASP If I wanted to show the time it was a simple snippet like time(now). In PHP it's a mini-script in itself. I'll get to the "proper way" of doing things eventually. Right now I'm just trying to make things work and going over the syntax so I can break my ASP shaped way of thinking. btw, I notice that not one of you really answered my question. You just gave me your opinions on how I "should" be doing it.
  3. I will consider that in the future. Right now I'm still taking baby steps.
  4. btw, I found a snippet of code and cut it down to where it only displays the time: date("g.i a", time()); but the time it shows is 4 hours ahead. Since the server is running off my computer I don't see why it's doing this.
  5. I can't believe this is such a hassle. Google searches bring back results on displaying time differences, calculating the amount of time, etc. but not the syntax for sending the current time in hour:minute am/pm format. Little help, please.
  6. Thanks for the tips. Like I said I literally just started learning PHP two days ago, so you'll have to forgive my lack of coding etiquette. Yes, you can mark this solved.
  7. So are you saying my If/Then statement would have worked if I'd used the == operator? Again, sorry for all the posts but I'm not allowed to edit my previous posts.
  8. Right, forgot about that. There's no equivilent in ASP for ==. Thanks for all your help!
  9. GOT IT! I had to alter your classes code a bit but I got it working: // Retrieve data from database $sql="SELECT * FROM $tbl_name ORDER BY id DESC LIMIT 2"; $result=mysql_query($sql); // Start looping rows in mysql database. $classes = array('post_box', 'post_box post_box_last'); // define div classes here $i = -1; // initiate counter to -1 while($rows=mysql_fetch_array($result)){ $divname = $classes[++$i]; // get the next class, ++$i will increment $i by 1 $mystring = $rows['message']; ?> <div class= "<? echo $divname; ?>"><img src="images/templatemo_image_01.jpg" alt="image" /> <div class="post_box_right"> <h2><? echo $rows['title']; ?></h2> <div class="post_meta"><strong>Date: </strong><strong><? echo $rows['dateday']; ?></strong> <? echo $rows['datemonth']; ?> <? echo $rows['dateyear']; ?>| <strong>Author: </strong><? echo $rows['name']; ?></div> <p><? echo substr($mystring, 0, 100); ?>...</p> <a href="blog_post.php?id=<? echo $rows['id']; ?>" class="more">Read more</a><br /> <div class="category">Category: <a href="#">Freebies</a>, <a href="#">Templates</a> | <a href="blog_post.php">244 comments</a></div> </div> <div class="cleaner"></div> </div> <?php // close while loop }
  10. Can anyone tell me what's wrong with my If...Else statement? My $count is changing from 1 to 2 but the value of "div" is not changing. // Start looping rows in mysql database. $count = 1; while($rows=mysql_fetch_array($result)){ $mystring = $rows['message']; If ($count = 1) { $div = ("post_box"); } Else { $div = ("post_box post_box_last"); } ?> <div class="<? echo $div; ?>"> <img src="images/templatemo_image_01.jpg" alt="image" /> <div class="post_box_right"> <h2><? echo $rows['title']; ?></h2> <div class="post_meta"><strong>Date: </strong><strong><? echo $rows['dateday']; ?></strong> <? echo $rows['datemonth']; ?> <? echo $rows['dateyear']; ?>| <strong>Author: </strong><? echo $rows['name']; ?></div> <p><? echo substr($mystring, 0, 100); ?>...</p> <a href="blog_post.php?id=<? echo $rows['id']; ?>" class="more">Read more</a><br /> <div class="category">Category: <a href="#">Freebies</a>, <a href="#">Templates</a> | <a href="blog_post.php">244 comments</a></div> </div> <?php // close while loop $count = $count + 1; }
  11. Looking at the page source I see that it's not actually changing the name of the div. I'm going to tweak the code a bit. I'll post back if I find a solution.
  12. Also (sorry, I'm not allowed to edit my posts yet) the div names were "post_box" and "post_box post_box_last", which I can't change using your method (it's a template I found, again, for the purpose of learning PHP, not web design). This is the code I used, which actually worked, but like I said, messed up other parts of the page layout: $count = 1; If ($count = 1) { $div = "post_box"; } Else { $div = "post_box post_box_last"; }
  13. Yes, that's exactly what I did, if slightly less elegantly But as I said, it messes up other CSS layout rules, so I'll leave it and concentrate on the PHP portion for now. I will, however, keep your code as a better way of implementing what I did with my usual half wit solution. Thanks!
  14. I did come up with a way to dynamically change the div name, and it did the trick, but the pages layout is not looking so great. Since my main point is to learn PHP I'm gonna let it go for now.
×
×
  • 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.