hielo 65 Veteran Poster

My apologies for the oversight. The WHERE clause currently has two conditions which are separated by a comma. Replace the comma with a space followed by the word AND followed by a space

hielo 65 Veteran Poster

In general, Is they deciding the results like first, second, third based on votes or Stars?

They are typically based on an average. Those systems would typically have a minimum threshold. Only after an item has received a minimum # of votes should they be compared against others. Otherwise the result is actually meaningless (which is why you are seeing the results you are seeing and are confused by them).

In other words, if you set your minimum threshold to 100 votes, if an item has less than a 100, then for all practical purposes you can consider that item as "not yet rated".

hielo 65 Veteran Poster
var name=[];
name[0]=["tom",12];
hielo 65 Veteran Poster

The VALUES clause is missing the closing parenthesis:

$sql = "INSERT INTO updates (id, title, date_posted, content)
VALUES ( NULL, '".$title."', Now(), '".$content."')";
hielo 65 Veteran Poster

WRONG:

xmlhttp.send("username=" + username.value);
 xmlhttp.send("password=" + password.value);

You cannot call send() multiple times. You must call it exactly once. To pass multiple parameters you must separate each value with an ampersand and you should encode each value:

xmlhttp.send("username=" + encodeURIComponent(username.value) + "&password=" + encodeURIComponent(password.value) );
hielo 65 Veteran Poster

assuming that id is an AUTO_NUMBER and title & content are of text data type, try:

$sql = "INSERT INTO updates (id, title, date_posted, content)
VALUES ( NULL, '".$title."', Now(), '".$content."'";
hielo 65 Veteran Poster

Look at my first post again. Where's the exit statement in YOUR code?

If your php has spaces and/or a new line AFTER the final ?> then the output that the server sees is NOT just OK, but OK PLUS whatever extra blank spaces exist after the ?> . That's the purpose of the exit - it quits immediately without sending those extra blanks.

If the problem persist, put an alert inside the success ajax function to see EXACTLY what your php script is returning:

success:function(data){ 
  alert(data);
  ...
  }
hielo 65 Veteran Poster

i have done what you said and am now using the code exactly as you posted.

If that is true, then why did you post your javascript code? The code I posted (where you need to use equal sign) is in process.php. Take my ORIGINAL post and change line 11 of process.php FROM greater than zero TO equal to zero

hielo 65 Veteran Poster

I have just noticed that if i switch the above code to this..

NO, That doesn't fix anything. All it will do now is to always show div2. Put it back the way it was and update your php to have equal instead of greater than (as suggested above)

hielo 65 Veteran Poster

actually, it should be: if($status['total'] == 0)

hielo 65 Veteran Poster

But, I'm not agreeing the place it is used for results/rating?

It's not clear to me if you are making a statement or a question!

Okay. with your example of students quiz itself, let we try to define.
Quiz competition - total questions 5.
Student#1 - answered 1 out of 5 questions - what is his grade?
Student#2 - answered 3 out of 5 question - What is his grade?

I'm assuming that "answered X out of 5 questions" you actually mean "answered X questions CORRECT out of 5 questions". Clearly student #2 will have a higher average.

However, this same scenario does not apply to your "beautiful house" rating system. In the student-quiz scenario, the assumption is that both students will have/take the same number of quizzes.

On the house scenario, not all the houses will have the same number of votes. Even if they did, you really cannot quantify beauty.

That's why I stated:
"...these rating numbers you are seeing really have little to no significant meaning"

Mathematically, you are computing the averages correctly, but in practical terms, those numbers will very unlikely reflect/convey how beautiful a house is.

If you were rating my house against someone else's and I see that my house is low on the score, I would then rate my own house up (either directly or by having my friends do so for me or by using proxy servers - you really can't avoid this) just to put …

hielo 65 Veteran Poster

do i need to include the file that has the class in my new file?

Yes, of course. Otherwise file 2 won't know what new foo() means. You have to provide the implementation of foo.

with an include statement?

You can use either include OR require. I prefer to use require since it will halt execution if I provide the wrong path to the file and will force me to figure out what is the correct path before continuing.

hielo 65 Veteran Poster

look at line 9 of MY process.php and look at the equivalent line of what you posted.

hielo 65 Veteran Poster

If you think in terms of change:
"house" to "student"
"votes" to "quizzes"
"rate" to "grade"

then it should be clear that the average you are computing is correct.

You are confused due to the results/rating you are seeing. This is because you really can't quantify beauty. What I may consider a beautiful house (with a rating of 5) may not be considered beautiful by anyone else. So these rating numbers you are seeing really have little to no significant meaning especially if you are looking at ratings with significant differing number of votes. If you just looked/compared rating for equal number of votes, then the numbers would be less confusing to you. But your methodology of computing the average is correct.

hielo 65 Veteran Poster
<?php
if(isset($_POST['post']))
{
$title = $_POST['title'];
$post = $_POST['post'];
$time = date("d-m-y");
mysql_connect('localhost','awah_awah','awah') or die("cant connect to the server".mysql_error() );
  mysql_select_db("awah_admin") or die("can't select hte database " .mysql_error() );
$sql = mysql_query("INSERT INTO blog ('title','post','datetime') VALUES ('$title','$post','$time')");
if(!$sql)
{
echo "error: can't insert the values --> ".mysql_error();
}
else
{
echo "done";
}
mysql_close();` //get rid of this extra "garbage" character you have here
}
?>
hielo 65 Veteran Poster

Whenever you see "is not a valid MySQL result resource", that is a clear indication that the query failed.

You are probably executing something SIMILAR to: $result=mysql_query($query); If instead you had suffixed your query with "or die( mysql_error() );": $result=mysql_query($query) or die( "Unable to execute:<br> $query<br>". mysql_error() ); it would have given you a description of what you did wrong.

As for the actual problem, in PHP you check for equality using back-to-back equal signs, but NOT in SQL. You need just ONE equal sign: $query = "SELECT `uName`, `pwd` FROM `users` WHERE `uName` = '$uName', `pwd` = '$pwd'" ;

hielo 65 Veteran Poster

process.php

<?php
//here you need to connect to the db first
//...


$tagname = mysql_real_escape_string($_POST['tag']);
$sqll = "SELECT COUNT(tag_name) as total FROM Tags WHERE tag_name = '$tagname'";
$result = mysql_query($sqll) or die(mysql_error());
$status = mysql_fetch_assoc($result);

if($status['total'] > 0)
{
	echo 'OK';
}
else 
{
	echo '!OK';
}
exit;
?>

The Javascript:

<script type="text/javascript"> 

$('#i1').hide();  // this is my div that says tag inserted!
$('#i2').hide();  // this is my div that says tag already exists

$("#keyword").click(function() { 

	$('#i1').hide();  // this is my div that says tag inserted!
	$('#i2').hide();  // this is my div that says tag already exists

	var txt = $.ajax({
				url: 'process.php',
				async: true, 
				type:'POST',
				data:{
						tag: $('input#newtag').val()
					} ,
				success:function(data){
						if( data=='OK' )
						{
							$('#i1').show();
						}
						else
						{
							$('#i2').show();
						}
					}
				});	

}); 

</script>
hielo 65 Veteran Poster

modify/update process.php so that it returns/prints/echoes:
"OK" when tag is inserted
"!OK" when tag already exists

<script type="text/javascript"> 

$('#i1').hide();  // this is my div that says tag inserted!
$('#i2').hide();  // this is my div that says tag already exists

$("#keyword").click(function() { 

	$('#i1').hide();  // this is my div that says tag inserted!
	$('#i2').hide();  // this is my div that says tag already exists

	var txt = $.ajax({
				url: 'process.php',
				async: true, 
				type:'POST',
				data:{
						tag: $('input#newtag').val()
					} ,
				success:function(data){
						if( data=='OK' )
						{
							$('#i1').show();
						}
						else
						{
							$('#i2').show();
						}
					}
				});	

}); 

</script>
hielo 65 Veteran Poster

try: $getid = preg_match('/\b' . $id . '\b/', $string); Or if you prefer to use the double quotes (like you posted), be sure to escape the backslash: $getid = preg_match("/\\b$id\\b/", $string);

hielo 65 Veteran Poster

In case you are wondering, the problem in your ORIGINAL code is in line 16. You check for equality with TWO consecutive equal signs: if( $existingTags [B]==[/B] $tagname )

hielo 65 Veteran Poster

On line TEN of your original post you misspelled $image . You have $iamge = trim($_POST['image']);

hielo 65 Veteran Poster

count is a keyword, so you MUST wrap it in backticks. As a matter of fact, it is better if you always put backticks around your field and table names, that way you will always avoid this problem:
NOTE: The general syntax is: UPDATE `TableName` SET `fieldName`='value' Based on what you posted, the sql should be: mysql_query("UPDATE `count` SET `count`='5' WHERE `username` = '$username'"); Are you sure that BOTH your tableName AND your fieldName are named count? If not, fix your statement accordingly.

hielo 65 Veteran Poster

On your original post you have:

.content{
  ...
  .p{
     ...
   }
}

you cannot NEST those rules. If what you are trying to express is "the .p within .content" then the syntax should be:

/* notice that it is TWO separate rules*/

.content{
 /* this applies ONLY to .content*/
}

.content .p{
    /* this applies only to element with class .p contained within .content */
}
hielo 65 Veteran Poster

If all you have in your HTML is <p> then your css should NOT have that leading period in front of the "p".

If your markup is <p class="p"> THEN it is OK to have .p{---}

hielo 65 Veteran Poster

At the top of each page, will it lose any function?

No

I.e. will the search engines that are looking for meta tags still see them?

Yes. Ultimately if you have index.php and within index.php you put include 'meta.php'; the browser will ultimately receive the HTML in meta.php but will NOT know that it is actually in meta.php. The browser "thinks" that it is from index.php. The same goes for the search engines.

daviddoria commented: Thanks for the quick and thorough reply! +4
hielo 65 Veteran Poster

can i use the mysql_fetch_array twice in different places in my code

Yes

Probably the easiest solution is to build a complete unique array in the first loop, and use that

My suggestion would be to reset the pointer to the query result. IMMEDIATELY BEFORE the SECOND while put mysql_data_seek($rs, 0); http://us2.php.net/manual/en/function.mysql-data-seek.php

hielo 65 Veteran Poster

You need to convert your date STRINGS to an actual date first - Try:

/* http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_str-to-date */
$startDate='12-10-2010';
$endDate='15-12-2010';

$sql= "SELECT * FROM `tblPerson` WHERE `subscriptionDate` BETWEEN 
STR_TO_DATE('$startDate','%d-%m-%Y') AND STR_TO_DATE('$endDate','%d-%m-%Y')";
hielo 65 Veteran Poster

Now my problem is the misplacement of records on my fields.

Records that suppose to be in the Region field now displays at the Name field.
Records that should be on the Zipcode field now at the Age field.
Records that should be on CPnumber field now displays at the Birthday field.

How do you know that the records are "misplaced"? Are you
A. looking directly at the db table OR
B. are you querying the db via some php script and looking at the result of your php script?

If "B", then it is possible your php script is just showing the data incorrectly. Your insert statement seems correct.

hielo 65 Veteran Poster
foreach ($fields as &$value) {
${$value} = $myrow[$value];
}
hielo 65 Veteran Poster

Your problem is because you are using $count to "control" both loops. Do NOT use $count for BOTH loops. Use different variables. Try something like $outerCount and $innerCount instead.

Also, they should start at zero (not one) and be "less than" (not "less than or equal to") - ex: for($outerCount = 0; $outerCount < $catresult; ++$outerCount){...} However, you are NOT using that variable for anything other than to iterate through the complete result set. A better approach would be to use a while construct and dump the row result directly into $rowcat for( $ourount = 1; $count <= $catresult

$cat = mysql_query("SELECT * FROM forum_cat")or die(mysql_error());
	while($rowcat = mysql_fetch_assoc($cat)){
		$get=$rowcat['cat_name'];
		$latest = mysql_query("SELECT * FROM forum_question WHERE category='$get' ORDER BY datetime DESC LIMIT 2")or die(mysql_error());
		$counttresult = mysql_num_rows($latest);
		echo '<div class="box"><div id="title"><div class="icn"><div class="icons2_5"></div></div>'.$rowcat['cat_name'].'<i>'.$counttresult.'</i></div>';
			while($rowlatest = mysql_fetch_assoc($latest)){
				echo '<div id="block"><div class="title">'.$rowlatest['topic'].'</div>'.substr($rowlatest['detail'], 0, 200).'</div>';
	
			}
		echo '</div>';
		$cat2=$rowcat['cat_name'];
	}
hielo 65 Veteran Poster

It's time to close this thread. Your original issue has been long solved:
http://www.randomsnippets.com/2008/02/12/how-to-hide-and-show-your-div/

hielo 65 Veteran Poster

Im trying to get the following example to update without the need to click

You need to call the function somehow. If you want to do this upon page load then try:

<script type="text/javascript">>
//the stuff you currently have goes here
//...

//then right BEFORE you close the SCRIPT tag put
window.onload=ajaxFunction;//NO parenthesis
</script>
hielo 65 Veteran Poster

it simply displays: Resource id #3

That's because mysql_query() returns exactly that - a resource, NOT the direct value. You have to extract the value explicitly:

$result = mysql_query("SELECT total FROM usersystem WHERE username = '$username'") or die( mysql_error() );
$row=mysql_fetch_assoc($result);
$total = $row['total'];
...
hielo 65 Veteran Poster

try:

SELECT * FROM table WHERE type='cool' AND (id NOT IN(2,3,5) )
hielo 65 Veteran Poster
hielo 65 Veteran Poster
hielo 65 Veteran Poster

When you execute echo $html->find('table', YOU_FIGURE_OUT_THE_NUMBER_THAT_GOES_HERE)->innertext; it will give you everything INSIDE that table tag (NOT including the table tag itself). If you are getting everything inside, then it is working fine. You can add YOUR own opening and closing table tags: echo '<table id="gainersAndLosers">' . $html->find('table', YOU_FIGURE_OUT_THE_NUMBER_THAT_GOES_HERE)->innertext . "</table>";

hielo 65 Veteran Poster

Look the source code of the page you are interested in. Let's say that the DIV you are interested in is the THIRD in the page's HTML source code (but it has no attributes - id, class, etc).

Since you know it is the third, then you can get it by issuing find('div', 2) . The first DIV would be on index zero; the second in index one, etc.

hielo 65 Veteran Poster
//you can use an associative array and retrieve $args['foo'] $args['lorem'] within the function
$a=array("foo"=>'bar', "lorem"=>'ipsum');
example( $a );

//OR you can cast it to a "generic" object and access it at $args->foo and $args->lorem 
$a= (object) array("foo"=>'bar', "lorem"=>'ipsum');
example( $a );
hielo 65 Veteran Poster

try: <form [B]id[/B]="myForm" action = ""> AND var temperatureValue = [B]document.getElementById('myForm')[/B].TemperatureField.value;

hielo 65 Veteran Poster

My guess is you defined your Number field/column as Text data time instead of INT. So it is doing ascii comparisons. In the ascii table the '1' comes before the '2'. You need to change the data type of the column to INT or cast the Number:
http://dev.mysql.com/doc/refman/5.0/en/cast-functions.html SELECT * from PHOTOS WHERE `Subject`= '$Subject' AND `Location` = '$Location' ORDER BY CONVERT(`Number`,UNSIGNED INTEGER)

hielo 65 Veteran Poster

Read the available Date/Time functions in the manual:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_curdate

SELECT * FROM TABLE WHERE dateField > DATE_SUB(CURDATE(), INTERVAL 3 DAYS)

SELECT * FROM TABLE WHERE dateField > DATE_SUB(CURDATE(), INTERVAL 6 MONTHS)
hielo 65 Veteran Poster

The first place to look is the Date/Time functions in the manual page:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-sub SELECT * FROM forms WHERE today >= DATE_SUB( CURDATE(), INTERVAL 30 DAYS)

hielo 65 Veteran Poster

that does not look like jquery. If that is EXACTLY what you used then it's wrong.

As for the JSP part, I can't help you there. I am not a jsp developer.

hielo 65 Veteran Poster

if your server supporst PHP, you can use the php's include() to "import" that file into your pages. You would just save the menu bar as an independent file (let's call it menu.inc.php - even if you have just "plain" html in it).

Then you would need to rename index.html to index.php. Then in index.php at the point where you want to "insert" your menu, just put <?php include( '/path/to/your/file/menu.inc.php') ?> NOTE: It does NOT HAVE to be php. If you have ASP support, then you can accomplish the same task in a very similar manner. The syntax will be slightly different but the concept still applies.

Alternatively, see if your server has support for Server-Side includes (in which case your files "might" need to be renamed from "index.html" to "index.shtml"):

<!--#include virtual="/path/to/your/file/menu.inc" -->
hielo 65 Veteran Poster

Good job you figured that out

You are obviously missing the point

murtazamzk, try:

<script>
function backhome(e){
	var targeturl="index.htm"
	if (document.all)
	{
		if (event.keyCode==104||event.keyCode==72)
			window.location=targeturl
	}
	else
	{
		if (e.which==104||e.which==72)
			window.location=targeturl
	}
}
document.onkeypress=backhome
</script>
hielo 65 Veteran Poster

You only need to find the keycode of the "H" key.

His code already has that.
72 == H
104 == h

hielo 65 Veteran Poster
hielo 65 Veteran Poster

Change the "bullet;" with "#9632;" (leave the & alone).

hielo 65 Veteran Poster

try:

<script type="text/javascript">

function callAjax(type,method)
{
	method = (String(method).toUpperCase()=="POST") ? "POST" : "GET";
	var xmlHttpReq = false;
	try
	{
		// Opera 8.0+, Firefox, Safari
		//ajaxRequest = new XMLHttpRequest();
		xmlHttpReq = new XMLHttpRequest();
	} 
	catch (e)
	{
		// Internet Explorer Browsers
		try
		{
			xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try
			{
				xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e)
			{
				// Something went wrong
				alert("Your browser broke!");
			return false;
			}
		}
	}

	// Create a function that will receive data sent from the server
	var queryString = "mode=home&flag=i&flag2=" + type;
	var strUrl = "index.php?" + queryString;
	//window.location.href = strUrl;
	xmlHttpReq.onreadystatechange = function()
	{
		if( xmlHttpReq.readyState == 4 || xmlHttpReq.readyState == "complete")
		{
			if( 200==xmlHttpReq.status )
			{
				document.getElementById('my_requests').innerHTML = xmlHttpReq.responseText;
			}
			delete(xmlHttpReq.onreadystatechange);
			delete(xmlHttpReq);
		}
	return true;
	}

	try{
		xmlHttpReq.open(method, strUrl, true);
		var params=null;
		if("POST"==method)
		{	params=queryString;
			xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlHttpReq.setRequestHeader('Content-Length', params.length);
		}
		xmlHttpReq.send(params); 
	}
	catch(e)
	{
		alert(method + ' ' + e.toString());
		delete(xmlHttpReq.onreadystatechange);
		delete(xmlHttpReq);
		return false;
	}
return true;
}

</script>


<h3>Request Tracking System</h3>
<table width="70%" border='1'>
	<tr>
		<td width='100%' valign='top'>
			<table width='100%' cellpadding='8' cellspacing='0' class='bord' border='1'>
				<th colspan='2'>
					<button type="button" onclick="callAjax('m');return false;">Requests for me</button>
				</th>
				<th colspan='2'>
					<button type="button" onclick="callAjax('o');return false;">All Requests</button>
				</th>
			</table>
			<br/><br/>
			<div id="my_requests" >
			</div>
			<!-- <div id="remove_user_show" style="display:none;"></div> -->
		</td>
	</tr>
</table>