buddylee17 216 Practically a Master Poster

I'm assuming by menu, that you mean a drop-down menu populated from a web application. Being a programmer, you'll have the tendency to perform iterations over result sets. This will perform very poorly when your row count gets higher. Save the iterations for after the db gives you back the results. Moreover, think in SETS.

Your algorithm is correct, however this will not be optimal with a relational database. A relational database can retrieve 1 row as fast as it can 1000. However, retrieving 1000 rows, 1 row at a time will be very slow.

Get the entire result set from the db, then let the app format the presentation layer (query assumes the table name is Menu):

SELECT ROW_NUMBER() OVER (ORDER BY Parent.name) MenuId, Parent.name Level1, ChildFirst.name Level2, ChildSecond.name Level3
FROM Menu Parent
	LEFT OUTER JOIN Menu ChildFirst ON Parent.id = ChildFirst.parent
		LEFT OUTER JOIN Menu ChildSecond ON ChildFirst.id = ChildSecond.parent
WHERE Parent.parent IS NULL

The Left outer join is only required because there is no certainty that every parent has a child. Additionally, the ROW_NUMBER function is only available in sql 2005 and up.

adam_k commented: Excellent solution & explanation on the way dbs work +7
buddylee17 216 Practically a Master Poster

You can output to excel using OPENROWSET or bcp (with xp_cmdshell).

BitBlt commented: Oh, yeah...forgot about that one... :) +7
buddylee17 216 Practically a Master Poster

Try modifying the following to pull from the table, rather than comparing the date variables:

DECLARE @intime DATETIME
DECLARE @outime DATETIME
DECLARE @time int--total seconds
DECLARE @days int, @hours tinyint, @minutes tinyint, @seconds tinyint
SET @intime = GETDATE()
SET @outime = DATEADD(S, 3663, @intime)

SET @time = DATEDIFF(S,@intime,@outime)
SET @days = @time / 86400
SET @hours = (@time/3600) - (@days * 24)
SET @minutes = (@time/60) - (@days * 1440) - (@hours * 60)
SET @seconds = @time % 60

SELECT @time total_second_count
	 , @days day_count
	 , @hours hour_count
	 , @minutes minute_count 
	 , @seconds second_count
debasisdas commented: that will work nicely. +8
buddylee17 216 Practically a Master Poster

This will work with 2008. With 2005 or earlier, you'll need to use datetime and the convert to varchar to strip the time portion off.

DECLARE @yesterday DATE
SET @yesterday = DATEADD(D,-1,GETDATE())
debasisdas commented: thank you for providing alternate solution. +8
buddylee17 216 Practically a Master Poster

Use BETWEEN and cast the varchar to date:

select * from mytable where dtcreated BETWEEN CAST(fromdate AS DATE) and CAST(todate AS DATE)

Edit: This works on SQL Server 2008 and up. Cast to datetime if you are using an earlier version.

debasisdas commented: So simple solution. +6
buddylee17 216 Practically a Master Poster

It's unique to your area. Go to job sites like Monster.com or careerbuilder.com. Search different web development languages. Does coldfusion list 100 jobs? Does php? What about .net? If you are strictly learning a language for financial gain or employment security, this is what you should look into.
Getting paid is not about knowing one thing. It's about combining a potent and popular combination of skill sets and knowing how to do them extraordinarily well. When you see the search results for the jobs listed above, what other required skills are listed? For php, you'll probably see Apache and MySQL. For .net, you might see asp, vb, and/or C# plus the visual studio and sql server. The ultimate "GET PAID" stack is probably Oracle and Java. You know Oracle and Java and you are a made man! Whatever you do, stick with it and become an expert. You will not get rich by knowing how to output "Hello World" in 15 different languages. You will not get paid by knowing how to do a select statement in 18 different databases. You will get a great paying job for knowing the granular details of one specific skill set combination that is currently in demand.

buddylee17 216 Practically a Master Poster

Why do you need regex for this? Can you not use basic string functions like LEFT, MID, and RIGHT?

buddylee17 216 Practically a Master Poster

You haven't specified an image: "<img src=/em/tutor/images/". only specifies the folder that the image should be located.

papermusic commented: 10s +1
buddylee17 216 Practically a Master Poster

Here's a possible solution.
Step 1, Create an empty array.
Step 2, Evaluate each checkbox in a loop. If empty, push a 0 into the array. Else, push a 1 into the array.
Step 3, Implode the array using a comma as the "string glue":

<?php
if(isset($_REQUEST["submit"])){
$checkarray = array();
$numCheckBoxes = 5; //number of checkboxes to evaluate
	for($i=1; $i<=$numCheckBoxes;$i++){	
		if(empty($_REQUEST["check".$i])){
		array_push($checkarray,0);
		}else{
		array_push($checkarray,1);	
		}
	}
$checkstring = implode(",",$checkarray);//create comma separated string from array
echo $checkstring;//outputs:1,0,1,1,0 
}
?>

This code assumes that the checkboxes are named check1,check2,check3,check4,check5...

darkagn commented: nice suggestion +4
buddylee17 216 Practically a Master Poster

Actually, I modified your query to test the code in my db prior to posting and it outputted "No rows retrieved'". Also, when I run the code like so:

$sql = 'SELECT * FROM `absent faculty table` WHERE absentid = "blah"'; 
$result=mysql_query($sql,$conn);
$num_rows = mysql_num_rows($result);
echo $num_rows;

it returns 0 every time.

Have you got an error in your query?

OmniX commented: Thanks helped me find my problem! +2
buddylee17 216 Practically a Master Poster

Rewrite rules don't actually hide the query string. Rewrite rules pretty much convert seo friendly urls into the actual query string.
Example .htaccess:

RewriteEngine on 
RewriteRule ([^/\.]+)/?.html$ viewPage.php?ID=$1 [L]

The above rewrite rule will allow you to do something like this:
url reads: yoursite.com/DaniWeb.html
apache interprets as: yoursite.com/viewPage.php?ID=DaniWeb
Therefore

<?php
$id=$_GET['ID'];
echo $id;
?>

will output DaniWeb.

Shanti C commented: Thanks Man... +3
buddylee17 216 Practically a Master Poster

Here is a simple AJAX form submission using POST. It basically sends the first and last name to the server, and the server outputs the form information and the date on the server. Very simple, but easy to build on.
post.php:

<?php
$FirstName = $_POST['FirstName'];
$LastName = $_POST['LastName'];
$today = date("m/d/Y");
//send output back to page.
echo "Hello $FirstName $LastName. Todays date is $today.";
?>

html file(name it whatever you want):

<!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 http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" language="javascript">
   var http_request = false;
   function makePOSTRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('myspan').innerHTML = result;            
         } else {
            alert(http_request.status);
         }
      }
   }
   
   function get(obj) {
      var poststr = "FirstName=" + encodeURI( document.getElementById("FirstName").value ) +
                    "&LastName=" + encodeURI( document.getElementById("LastName").value );
      makePOSTRequest('post.php', poststr);
   }
</script>
</head>
<body>
<form action="javascript:get(document.getElementById('myform'));" name="myform" id="myform">
<input type="text" id="FirstName" />
<input type="text" id="LastName" />
<input type="Submit" value="Submit" /> …
nav33n commented: Good example.. +10
buddylee17 216 Practically a Master Poster

Have you added a loop to display the output?

<cfquery name="players" datasource="connsilvereagles">
SELECT *
FROM player
ORDER BY playernumber DESC</cfquery>

<cfoutput>
<table>
<cfloop query="players">
<tr><td>#playernumber#</td></tr>
</cfloop>
</table>
</cfoutput>
peter_budo commented: Good job +15
buddylee17 216 Practically a Master Poster

Either disable html messages or look into using BBCode

buddylee17 216 Practically a Master Poster

Basically something like

RewriteEngine on 
RewriteRule ([^/\.]+)/?.html$ viewPage.php?ID=$1 [L]

So if you typed
www.blastingart.com/New Features.html
into the url, it would be the same as typing in
www.blastingart.com/viewPage.php?ID=New Features

wickedsunny commented: thanks simmply genius !! +1
buddylee17 216 Practically a Master Poster

Do the customers know you are storing there credit card numbers? Do the credit card companies know about this? I think that both parties would have a problem with you storing this information without their knowing and without you having the proper security credentials.

Salem commented: Yes indeed, a disaster waiting to happen. We should be told the name of the store, so we can avoid it. +25
buddylee17 216 Practically a Master Poster
<?php
$page = file_get_contents('http://www.google.com');
$num = md5(uniqid());
$filename = $num;
$filename .=".html";
$handle=fopen($filename,"x+");
fwrite($handle,$page);
?>
theimben commented: Thanks for your help - !Unreal +2
buddylee17 216 Practically a Master Poster

Create a blank php page and put the following in to see how it should work:

<?php 
$profpic="http://www.daniweb.com/alphaimages/logo/logo.gif";
?>
<html>
<head>
<style type="text/css"> 
body {
    background-image:url('<?php echo $profpic ;?>');   
	margin-left: 10px;
	margin-top: 4px;
	margin-right: 5px;
	}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html>

After you see how it works, try replacing the $profpic value with your image path.

Kavitha Butchi commented: u r simply gr8!! +1
buddylee17 216 Practically a Master Poster

The name the element has in the form goes inside the brackets.
So if your form has

<input name="name" type="text" id="name" tabindex="16" />

After the form is submitted, PHP can assign the value posted to the variable. Here we assign the value of the textbox above to the variable $nameField:

$nameField=$_POST['name'];

Now if you want to use that variable in your email, you'll need to use the variable just defined.

$body = <<<EOD
<br><hr><br>
name: $nameField <br>

Get it??

peter_budo commented: Nicely done +12
buddylee17 216 Practically a Master Poster

Are you accessing the file through localhost?

enzogoy commented: Solve my problem +1
scru commented: Ha, i never thought of that +4
buddylee17 216 Practically a Master Poster

In the form element, add the attribute target="_top".

<form action="process.php" target="_top">

Have a look at all of the possible target values:
http://www.w3schools.com/TAGS/att_form_target.asp

darkagn commented: good tip and link, very useful info :) +3
buddylee17 216 Practically a Master Poster

You can use extract.

@extract($_POST);

This will convert all of your form names to variables.
You can then access each variable by using the following:

foreach($_POST as $key => $value){
echo "$key=$value<br>";
}

In this code, $key is the variable name. $value is the value of the variable submitted from the form.
Obviously, you'll need to add in some major validation.

Shanti C commented: very smart.... +2
buddylee17 216 Practically a Master Poster
echo "<img src='/photos/".$info['photo']."' width='200'><br>"; 
echo "<b>Description:</b> ".$info['name']."<p> <hr>" ;
justted commented: Very very Helpful! Thankyou :) +1
buddylee17 216 Practically a Master Poster

This is supported in php. I'm not to sure if the keyword super is. Here's a simple example of this:

class Human 
{
	public $thirsty = 'Very thirsty!';
	
	function drink($water)
	{
		$this->thirsty = 'Not thirsty!';
	}	
}
buddylee17 216 Practically a Master Poster

Change the mode parameter on line 20 to r:

$fp = fopen($path, 'R');

should be:

$fp = fopen($path, 'r');
Dukane commented: excellent, quick solution! thanks +2
buddylee17 216 Practically a Master Poster

Also, see http://www.daniweb.com/forums/thread136175.html on how to set up the connection string for accdb.

peter_budo commented: Nicely spotted... +10
buddylee17 216 Practically a Master Poster

You shouldn't compare the two. It's like comparing a school bus (Oracle) to a Corvette (MySql). Oracle can deliver tons of data in a reasonable amount of time consistently. MySql can deliver smaller amounts of data in a much faster time consistently. How big is the db and how frequent will it receive requests? Are you planning on having millions of users querying the db every 3 seconds? If so, Oracle should be your choice (or even better, IBM DB2). However, if you are predicting <10000 users and average query of 5 per minute or less, MySql will do all you have ever hoped for.

peter_budo commented: I like this reply +9
buddylee17 216 Practically a Master Poster

The two important ones are keywords and description. They both go in the head of the document. Metadata help search engines find content relative to what was searched for. Let's look at this page:

<meta name="keywords" content="HTML and CSS, programming forum, computer forum, programming help, computer help, tech support, technical support, web development, website promotion, internet marketing, seo" />

Keywords are important because they give the search engine an idea about the pages content. To create keywords, simply make a list of all the keywords you think people might find you with. Also, ask your customers to make a list of all the keywords they would try to find you with.

<meta name="description" content="How do I go about metadata - HTML and CSS Community and Forum - Our HTML and CSS forum is the place for Q&amp;A-style discussions related to the XHTML markup language and stylesheets. Note we have a separate JavaScript forum for clientside scripting languages." />

The description is a bio for the page. Try to keep it under a few sentences and related to the content. In either case, if you start repeating words, it can dilute the content and actually lower your page rank.

Search engines all use different algorithms to decide page rank. Metadata can help you improve page rank but, there are many other factors involved.

Perhaps the most important factor would be having other sites link to yours. It's similar to how rep power works on Dani Web:

Soleybancing commented: This is a clear Explanation. Thanks +2
buddylee17 216 Practically a Master Poster

Okay, what this does is it performs a substr on the text portion of the link only by using a function inside the preg_replace function:

<?php
$content="You can read more about reducing the text of the link at  http://www.daniweb.com/forums/thread135726.html .";
function reduceurl($url, $url_length) {
        $reduced_url = substr($url, 0, $url_length);
        if (strlen($url) > $url_length) {
		$reduced_url .= '...';
		return $reduced_url;
		}
	}
$text = preg_replace("@(http://[^\s]+)@sme", "'<a class=\"diaryUrl\" target=\"_blank\" href=\"$1\">' . reduceurl(\"$1\", 40) . '</a>'", $content);
echo $text;
?>

This will output "You can read more about reducing the text of the link at http://www.daniweb.com/forums/thread1357..." with the link in place.

Venom Rush commented: A great help. Thank you very much +1
buddylee17 216 Practically a Master Poster

Once you get comfortable with the xhtml syntax, look into a server side language. At some point you'll find that xhtml won't full fill all of your needs and will need some server interaction. If you have no preference, I'd recommend php. Php has a wealth of documentation and tutorials available free online. I believe a good way to learn a server side language is to start off with a form that submits to the server. Here is a good place to start. The easiest way to develop and test php is with some type of WAMP (Windows Apache MySql PHP) server running on your local machine. Probably the easiest to get started with is xampp. It will run on just about any operating system and will allow you to test pages locally before uploading to the web.

Also, try to create an external stylesheet for your xhtml page. W3Schools is a good place to learn CSS basics. You'll also note that the site has tutorials on just about anything else related to web development.

peter_budo commented: Nice post +9
buddylee17 216 Practically a Master Poster

Yes, this is called a preloader. It's a movie clip that should go in at the beginning of the timeline and play until getBytesLoaded=getBytesTotal. Here's a tutorial with many downloadable examples and actionscript which should get you going in the right direction.

iamthwee commented: Yeah that's better than my suggestion +15
buddylee17 216 Practically a Master Poster

You are right about the onclick function. The onclick function is a JavaScript event handler so you'll need to incorporate JavaScript (else you'll have to have a page refresh after each button is clicked). Here is a link to a memory game tutorial written in JavaScript and PHP. I believe this is similar to what you are asking.

martin5211 commented: nice example +1
buddylee17 216 Practically a Master Poster

This site claims it can with something called the image gaurdian. Explanation copied from site:
"Here comes the Image Guardian - it will split your images into pieces and will generate the appropriate code (which will be then encrypted by HTML Guardian) to display those pieces in your pages as if this is an integral, non-splitted image.
This will make image theft nearly impossible - if someone wants to get some of your images, he/she will not be able to get the entire image, only a pieces of it saved under random, meaningless names. It will be very hard to determine that a certain piece is a part of a certain image. Let's say your website has 10 images, and you configured Image Guardian to split them into 3x3=9 pieces each - this will result in 90 image pieces with random names, mixed with a lot of images from other websites visited. A determined person may still be able to find all the pieces of a certain image, but finding them and joining them together to recreate the original image will require a lot of time, knowledge and expensive image editing programs(like Photoshop and similar). In most cases, this will also lead to a seriously decreased image quality. We can say that HTML Guardian's image protection will decrease the risk of image theft with 95-98% (but not 100%).."

buddylee17 216 Practically a Master Poster

The reason is that each browser applies its own default stylesheet to your page. What this means is that each browser adds a certain amount of margin, padding, line height... to each element. The problem with this is that IE may add 2px and FireFox may add a different amount. Thus the inconsistency problem that has plagued the world of web design. The only way to make things appear consistent is to reset the elements you will be using in the beginning of your stylesheet. I often post this link, as the question comes up quite often. Have a read, it should clear some things up. Here is a link dealing with white space that IE adds in between images.

jephthah commented: good links, thanks +3
buddylee17 216 Practically a Master Poster

No, CSS is not hard to learn but, it does take time to master. You'll catch the basic concepts in a day or so but, because you can manipulate the design in so many different ways, it will take a while to master them all.
You'll need to get used to previewing the site in different browsers because what looks great in FireFox may not look so good (or even work) in IE and vice versa.

You can find just about anything you need to know on CSS at W3Schools.

alwaysworking commented: Thank you! +1
buddylee17 216 Practically a Master Poster

You want something like this? This textbox clears when the user clicks it.

<input type="text" onfocus="this.value=''; this.onfocus=null;" name="notes" value="enter ticket number here" />
peter_budo commented: Good example, nice work :) +8
buddylee17 216 Practically a Master Poster

my_sound.loadSound("music/track1.mp3", false); This tells me that the music is being downloaded and is not actually in the flash movie or library. Look in the folder that you downloaded. It should contain a subfolder named music. Inside (I think) will contain mp3's named track1.mp3,track2.mp3, & track3.mp3.

my_sound.onSoundComplete = function() {
numtrack++;
if (numtrack == 4) {
numtrack = 1;
}

This is incrementing the track number by one at the end of the song and resetting the song number after track3.mp3. To change the songs, take the mp3's that you want in the player and name them track1.mp3, track2.mp3...and replace the current songs in the music folder.

This is all just a guess but hopefully it will help get you going in the right direction.

peter_budo commented: Good code example +8
buddylee17 216 Practically a Master Poster

An easy way to validate is to install the free web developer add-on in Firefox. Once installed, you can simply press Ctrl+Shift+A and the W3C validator will open in a new tab and validate the page that you were on.

With dreamweaver you start a new document, it always has meta tags, etc.
Anyone explain for what purpose?

META tags are HTML Tags that describe the contents of a web page. The primary purpose of Meta tags is to help catalog and categorize the contents of a web page. If your pages do not contain them then they may not get categorized the way you‘d like by the search engines.

So there isnt any program that can validate all your code for cross browsing (ie/firefox)?

Yes, although Dreamweaver can spot things that won't work in different browsers, you just have to follow Midi's advice. Here's a link to answer the question, Why does my site look different in IE than in Firefox?

OmniX commented: Thanks for your comprehensive response! +1
buddylee17 216 Practically a Master Poster

External css should not contain style tags (<style type = "text/css"></style>) at the beginning and end like they do when putting them inline. If the styles aren't showing up, they probably aren't in the same place that you are pointing the link href to. Try typing the absolute address of your css file into the browser and view it to make sure it's there. Then copy and paste the same url into the href. i.e.<link href="http://www.insanecricket.com/sleek/styles.css" rel="stylesheet" type="text/css" />

peter_budo commented: Good spoting +7
buddylee17 216 Practically a Master Poster

Do a SELECT to find the user_id for the current user in the USER table. Assign the user_ID to a variable, $user_ID. Now do your UPDATE on the USER_INFORMATION table using WHERE user_ID='$user_ID'

hooray commented: good solution +1
buddylee17 216 Practically a Master Poster

newcountry, sql injection is not desirable. You want to download it? Sorry it's not some open source program you can download.

SQL injection is a technique used by hackers to exploit your database. It can be used to view, update, or delete data, without the knowledge of the db admin.

Wanna learn more?
http://unixwiz.net/techtips/sql-injection.html

Ramy Mahrous commented: Very good (Y) +2
buddylee17 216 Practically a Master Poster

Read up on password sniffing. It's great if your server is secure, but if the user is on a LAN then it's still possible to get hacked.

Good rules for any database:

1.) Never pull a password out of the database. Once it is in, it stays there. You can look for it in the query, but don't pull it out.

2.) You should never know your users actual password. This means that every password is encrypted before it gets to the database. This will make it much more difficult for a sniffer to intercept it and successfully login.

iamthwee commented: I like! +13