floatingDivs 21 Junior Poster

Good God! Why do you guys waste your precious time with this bullcrap? Don't help them if they can't help themselves. Prop open a book and read about classes. Once you read a chapter on classes, you're good to go assuming you know how to use arrays, what data types are, etc.

Second year CIS with 0 knowledge in programming? Tsk tsk...

floatingDivs 21 Junior Poster

Uh huh. Either that, or he was too busy surfing the web.

floatingDivs 21 Junior Poster

Why are people like hajiakbar not banned immediately? Zero effort in even coming up with a simple algorithm for adding/subtracting/multiplying/division.

To kbshibukumar: This is someone you may end up working with in the future! *shakes head* I read those popular sites like codinghorror.com and you'll be surprised how easy it is for people with bad programming skills to get jobs. What makes it worse is they don't seem to recognize it (or don't care) and their future co-workers will suffer for it.

Read a book on C++, hajiakbar. You can't expect to be spoonfed answers.

floatingDivs 21 Junior Poster

JSPMA1988,

I completely agree with everything you said. First, such a title is a serious misuse of this forum's database. It doesn't take a genius to see that all the people who ask things such as "How do you get ..." will receive better answers than those who demand "help yo plz!". Secondly, saying you need it done and don't have the time is just more ammunition for people like you and I. What exactly was the original poster doing when he should have done the homework?

floatingDivs 21 Junior Poster

Why is this crap not deleted? Anyone who so blatantly ignores the rules should not only have the thread deleted, but be banned for a long time. If I recall, after you register, you are sent to the "rules" thread (not 100% sure) where it specifically states that for you to receive homework help, you have to show effort. Where is the effort?

floatingDivs 21 Junior Poster

ok. I tried that code above in my random number generating program and now it creates the exact same number every time I run it. Is that because 700 octillion is too big for C++ to handle or what?

Hi thecoolman5,

I believe it is too big a number to hold in the standard C++ data types.

http://msdn.microsoft.com/en-us/library/s3f49ktz%28v=vs.80%29.aspx

However, you could always create a BigInteger class similar to Java's.

floatingDivs 21 Junior Poster

Hi thecoolman5,

First off, I think you should always create your own thread rather than asking questions in a thread created by someone else.

However, welcome!

The way to convert from scientific notation to regular integers is done using the setf member function. For instance, by setting the formatting flags, you give yourself a host of options with how to display the numeric data. If you set the ios::fixed flag, you can make sure that floating-point numbers are not written in e-notation. If you set the ios::scientific flag, you can make sure they are written in e-notation.

Here's a small example of setting the ios::fixed flag to not display floating-point numbers in scientific notation.

#include <iostream>

int main()
{
    double pi = 384790124379273489274923740928743027492735e33;

    std::cout.setf(std::ios::fixed);
    std::cout << pi << std::endl;

    return 0;
}
floatingDivs 21 Junior Poster

Plenty of people here would know HOW to build one. Why the hell SHOULD anybody here help you? You don't seem to have put any thought into this yourself. You join up and in your first post demand answers that you as a 4th year BSIT should be developing yourself. Are you running out of time? Did you leave it too late to get going? Are you up to the task of doing this? How many sites have you joined lately, hoping to hook some schmuck into doing your work for you?

Why, I believe we have a winner!

floatingDivs 21 Junior Poster

@ardav

LOL...I think you think I don't know it's OOP. My admiration came from how few lines of code he managed to squeeze a full calendar with mod-ability into.

floatingDivs 21 Junior Poster

@fD - I was about to say don't post anything to me via PM, but I'm glad to see you've posted it to the forum. KK is such a show off isn't he? :)

Hey ardav,

Do you prefer not to receive PM's or is it that you wanted me to post the code for everyone to see (since it was finished)?

If it's because you prefer not to receive PM's, I'll make a mental note of that. If it's because you wanted me to share finished code, I'll try to do so more often.

floatingDivs 21 Junior Poster

Hi kkeith29,

Amazing job! Just looking at all that code gives me a headache and lets me know just how much more I really have to learn about programming!

Here's my very basic PHP Calendar.

<?php

	/* application information */
	$application = "calendar";
	$application_id = 1;
	
	/* there are 7 days in a week */
	$columns_for_week = 7; 

	/*
	 * The following variables are used to initialize the current date
	 * If the month is November 2010, $month = 11 and $year = 2010
	 */
	if(isset($_GET['year']))
	{
		$year = $_GET['year'];
	}
	else
	{
		$year = date("Y");  // 2010
	}
	$max_year = date("Y") + 10;

	if(isset($_GET['month']))
	{
		$month = $_GET['month'];
	}
	else
	{
		$month = date("n"); // 11
	}
	
	/*
   * The following variables are used to print out days for the current month
   *
	 * $days_in_month: returns how many days are in the month
	 * $first_day: returns a numeric representation (0[Sunday]-6[Saturday]) for the day of the week
   * $blank_days: returns how many empty boxes to display before the first of the month based on the $first_day variable
	 * $rows_for_month: returns how many rows the month will require (most require 4-5, some require 6)
	 * $day_counter: represents the first day of the month and is incremented in loop
	 */
	$days_in_month = date("t", mktime(0,0,0,$month,1,$year));
	$first_day = date("w", mktime(0,0,0,$month,1,$year));
	$blank_days = $first_day;
	$rows_for_month = intval(ceil(($days_in_month + $blank_days) / $columns_for_week));
	$day_counter = 1;

	/*
	 * The following variables are used to print the first couple days of the next month if empty …
floatingDivs 21 Junior Poster

Hi Ardav,

I've already completed all my goals with getting the calendar to work.

I've PMed you my final "solution" and if you don't mind, I'd love for your review. This isn't some online solution I copied and pasted, this is 8+ hours (sadly) of hard labor. Thankfully, now I know the proper pseudocode to creating a fully functional calendar. Hip hip hooray? :D

floatingDivs 21 Junior Poster

@ardav,

Thanks for the quick response.

The thing is, I saw MANY ready-made scripts available, but I wanted to work on my own just for "learning sake" and actually managed to get it to work. I have a fully functioning calendar setup and now am in the process of replacing the "empty" boxes with days from the previous month, so that if November starts on Wednesday, Tuesday would be populated with October 31, Monday October 30, and so on and so forth.

:)

I'll mark it as solved.

If you're interested in peering over my code to see if it's efficient (not great with PHP by ANY MEANS) and logical, let me know and I'll be glad to post it.

floatingDivs 21 Junior Poster

Hi Daniweb,

I'm trying to create a basic, grid-based (table-layout) calendar using PHP. I'm in the planning stages currently, but need some help coming up with an effective way to display empty boxes (for instance, November starts on Monday, so the left-most box (Sunday) needs to be empty. December starts Wednesday, so Sunday-Monday-Tuesday need to have empty, unmarked boxes (maybe black backgrounds?).

So, here's my current planning info.

What I need to Know
Current date (month + year)
First day value (0-6) [found with date("w", mktime(0,0,0,month,day,year))...]
Total days in month
Number of weeks in a month (can be 4-6)
Counter to loop through each day

---

I have a basic idea of how to create a proper for loop of a for loop, but I can't seem to make the "blanks" appear correctly.

for($rows = 0; $rows < $weeksInMonth; $rows++)
{
   for($daysInWeek = 0; $daysInWeek < 7; $daysInWeek++)
   {
       LOOP THROUGH DAYS, BUT WHAT'S THE LOGIC FOR BLANK BOXES?
   }
}

If anyone could help me out, I'd appreciate it. I don't need a full, detailed answer per se, but a shove the right way would help. :D

Thanks a lot! It's 12:20A.M. and I'll be up all night so I'll check in frequently.

floatingDivs 21 Junior Poster
floatingDivs 21 Junior Poster
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>

</head>
<body>
   <ul>
      <li>
         <a href="link.html">Link</a>
      </li>
      <li>
         <a href="link.html">Link</a>
      </li>
      <li>
         <a href="link.html">Link</a>
      </li>
   </ul>
</body>
</html>
floatingDivs 21 Junior Poster

Thanks a bunch, sops21, for your response.

Yeah, I figured it out within a couple hours of posting but forgot to mark solved. I'm using REGEX to help me create the "pretty links".

floatingDivs 21 Junior Poster

Here's a much better example. [SOURCE]

floatingDivs 21 Junior Poster

Hi Daniweb,

I've got a question regarding what I call "dynamic URL rewriting" -- which is probably the wrong term -- and need some help.

OK, so basically, I know how to rewrite the URL for static pages (i.e. have "localhost/index.php" also work as "localhost/index". However, let's say I have three database categories that each serve different users: "Sports", "Education", and "Finance". Their URL's are as such:

http://localhost/category/index.html


What I'd like is for all of these "folders" to dynamically be updated with one line of RewriteRule code. (something like this down below) That way, if I add 100 categories, I won't have 100 lines of "RewriteRule ..." to add.

I've seen that "environment variables" might do that trick but I'd REALLY prefer not to go that route. Rather, I'm hoping there are existing mod_rewrite functions up to that task.

An example would be Wordpress. If you create a category for each subject you want to write about and turn on permalinks ("pretty links"), you'll notice how they rewrite the URLs. I'm guessing they don't actually write RewriteRule(s) dozens of times...

floatingDivs 21 Junior Poster

I'll take a look at it in the morning...

floatingDivs 21 Junior Poster

Change the margin-top value from -36px to -38px for #sidebar-wrapper.

floatingDivs 21 Junior Poster

Here's how the include file is called...

<?php
include("filename.php");
?>

There is no <td> before and after the include...

floatingDivs 21 Junior Poster

You don't have border styles defined...

floatingDivs 21 Junior Poster

You might have turned off page styles for your browser.

In Firefox, click on the View toolbar menu, go to Page Style and select Basic Page Style.

floatingDivs 21 Junior Poster

Blastoise,

Assuming you're in college (and courses started at the end of August, start of September), it would mean two months have passed in the semester. Are you telling me you don't have a clear understanding of how "if-else" statements work?

Anyways, here's an example of the type of program you're looking for. [SOURCE]

floatingDivs 21 Junior Poster

Hi Daniweb,

I've found my solution. You can't do something which I was trying to do -- use a hash when creating the table -- and the way to apply hashes to user passwords is done in the "INSERT" process.

Here's a link explaining how md5, sha, and sha1 hashing is used.

Thanks!

floatingDivs 21 Junior Poster

Hi Daniweb,

I have a question for you guys. I've been reading up on PHP security and want to get it down pat before embarking on some projects I wish to do. The question right now is about how to create a table with PHP that will enable SHA1 hashing without requiring me to log in to phpMyAdmin and select it from the drop down. Basically, what I'm asking is can the SHA1 be written as part of a PHP table creation script?

Here's what I've tried.

$sql = "CREATE TABLE Members
(
   mem_id int(3) NOT NULL AUTO_INCREMENT,
   mem_username varchar(12) NOT NULL UNIQUE,
   mem_password [B][U][I]md5(varchar(12))[/I][/U][/B] 
)
floatingDivs 21 Junior Poster

Again, I'm not 100% sure as my PHP knowledge is still a work in progress. The thing is, more than likely you'll need to "refresh" the page or go to another to get the result. Otherwise, you'll need to implement AJAX with PHP to get the result on that page without any refresh or redirect. That is what I think. Make sure to ask others about this.

Here's a quick example I've concocted. JavaScript solution...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
</head>

<body>
<script type="text/javascript">
function calculate()
{
	var string = document.getElementById('calculate').value;
	var numbers = new Array();
	numbers = string.split(' + ');
	var sum = 0;
	
	for(var i = 0; i < numbers.length; i++)
	{
		alert("number " + (i+1) + " is " + numbers[i]);
		sum = sum + parseInt(numbers[i]);
	}
	
	alert("sum is " + sum);
}
</script>
<input type="text" id="calculate" />
<input type="button" onclick="calculate()" value="calc" />
</body>

</html>

---EDIT---

It is by no means the best way and it's not proper coding, but I wanted to show you a simple example.

floatingDivs 21 Junior Poster

OK.

Split the string using the split() method. [Source]

Create a variable for the numbers and make sure to use parseInt(string) to convert the variables into actual numbers.

floatingDivs 21 Junior Poster

Hi timpogue,

I'd recommend you use JavaScript to return the value dynamically. PHP, by itself, is not capable of doing so (that I know of). It would have to be used in conjointly with AJAX or something of that sort.

Also, do you mean you enter "2 + 2" or do you enter "2", click the add button, and enter "2" again?

floatingDivs 21 Junior Poster

Hello daniweb,

I'd like to know if it's possible for a newsletter to check which email client is rendering the content and based on which one it is, it would create a link for the best possible viewing solution.

For instance, if someone has Outlook 2003, I want to create a link here: http://test.com/2003/index.html

If someone is using Outlook 2007, I want to create a link here: http://test.com/2007/index.html

Would something like that be possible?

Thanks!

floatingDivs 21 Junior Poster

I see floats but I don't see a clear. Try to "clear" after the floating <div> LOL.

floatingDivs 21 Junior Poster

Why not use a customized Google search?

http://www.google.com/cse/

floatingDivs 21 Junior Poster

Hi Daniweb,

I'm unable to edit a file in Split View using Dreamweaver. The file is based around a template, but the region is editable when changing the code in split view, but when attempting to change the info with the WYSIWYG, it shows a black circle with a diagonal line through it (saying "can't do that" basically). Does anyone have a clue how to get around that? It's not for me...

floatingDivs 21 Junior Poster

JavaScript. The top-level bars ("Products", "Windows", etc) pass a javascript function from their <a> tag.

floatingDivs 21 Junior Poster

Care to post the code? Better yet, you have a link to it? I'll make a copy on my desktop and attempt to work with it.

floatingDivs 21 Junior Poster

Did you make sure to clear your floats?

<!-- left float div -->
<div class="left" style="float:left;">...</div>
<!-- right float div -->
<div class="right" style="float:right;">...</div>
<!-- clear floats -->
<div class="clear" style="clear:both;">...</div>
floatingDivs 21 Junior Poster

hielo,

That could work, but the problem becomes if you want to do anything with CSS. For instance, if you wanted to alternate background colors for even and odd-numbered <div>'s, you couldn't with the generateid() function, since it creates a random ID. By using a variable, you can check the position() and create an attribute that determines whether a <div> is even or odd numbered. Still, good contribution and it might be exactly what they're looking for!

floatingDivs 21 Junior Poster

Set the height of #page equal to the height of the image and it should work.

floatingDivs 21 Junior Poster

Add a background-repeat:no-repeat in the <td> that holds the background-image. I tested it and it worked well.

<td height="32" background="images/up.png" width="0" style="background-repeat:no-repeat">
floatingDivs 21 Junior Poster

Figured out the problem. You didn't clear your floats.
Between #headstrap and #navbar (after #headstrap <div> ends and before #navbar <div> starts), place a new div such as this: <div style="clear:both;"></div> to "clear" your floated divs. After that, it should work 100% correctly.

floatingDivs 21 Junior Poster

Did you get it fixed? I can't seem to find any problems with the page.

floatingDivs 21 Junior Poster

Hi teedoff,

I took a look at your code and I think I found the problem. After resizing to a very small browser, I saw the table "sticking out" past the white content area and going into the gray background area. Analyzing the code, I saw that you are using fixed margin sizes rather than percentages. You'll have to use percentages for margins (specifically #content).

Hope that helped,
floatingDivs

floatingDivs 21 Junior Poster

The biggest problem is you are using classes and not inline styles. Being that outlook express (and many other clients) have trouble with using <style> blocks, you need to do everything inline. It's going to be a lot of hard work, but that's the way it has to be built to view properly in most email clients.

floatingDivs 21 Junior Poster

That's a pretty simple thing to do. Create a variable called "evenOdd" and have it be even if the position() of the loop modulus 2 is equal to 0. If not, have it be odd. Let's say you have a calendar XML file with the following format (where the dots represent the values):

<root>
   <calendar>
      <event>
          ...
      </event>
      <event>
          ...
      </event>
      <event>
          ...
      </event>
      <event>
          ...
      </event>
      <event>
          ...
      </event>
   </calender>
</root>

To display the event data, you'll run an xsl:for-each loop where you'll output the <div> and the value inside of it (event), but you'll also create an attribute (class) that will determine whether the outputted div (for each event) is a even or odd.

<xsl:for-each select="/data/calendar">
   <div><xsl:value-of select="event"></div>

<xsl:attribute name="class">
   <xsl:choose>
      <xsl:when test="position() mod 2 = 0">
         <xsl:text>even</xsl:text>
      </xsl:when>
      <xsl:otherwise>
         <xsl:text>odd</xsl:text>
      </xsl:otherwise>
   </xsl:choose>
</xsl:attribute>

</xsl:for-each>

Hope that helped. If not, feel free to PM me and I'll go into greater detail or attempt helping you in any way you need help.

floatingDivs 21 Junior Poster

Would you care to explain what it is you're trying to do? Are you trying to use a JavaScript function to output HTML divs using an XSL stylesheet?

floatingDivs 21 Junior Poster

The variable example works, but there is a much easier way to do it (in my opinion). Let's say, in your XML, you have the element "events" repeating 31 times -- indicating 31 events -- and you want each one to have a unique ID.

In your XSL sheet, you'd run a loop creating a <div> like this:

<div id="event-{position()}"><xsl:value-of select="event" /></div>

And that would create a div with a unique ID for every event listed.

The curly braces are required around the XSL function position() because XSL functions need to be "enclosed" when used by HTML tags.

Hope that helped,
floatingDivs