hielo 65 Veteran Poster

this:

$(document).ready(function(){
   $(".productSelect").click(function() {
     alert( this.innerHTML );
   });
});

is equivalent to this:

$(document).ready(function(){
   $(".productSelect").bind('click',function() {
     alert( this.innerHTML );
   });
});

but bind will "attach/trigger" that anonymous function upon document.ready ONLY to already existing elements with class="productSelect".

So, the elements that you are adding via ajax with class="productSelect" do not exist upon page load (document.ready). They exist LATER on AFTER the bind has done executing, so they will NOT trigger that alert. Instead of bind() you need to use live(). live() will "keep an eye" for dynamically created elements and if needed will attach the necessary anonymous function:

$(document).ready(function(){
   $(".productSelect").live('click',function() {
     alert( this.innerHTML );
   });
});
hielo 65 Veteran Poster

It sounds like you have:

if ($rank < "Boss, Supreme Boss, Kingpin, Don, Godfather"){ 
  echo "You have to be ranked atleast Boss to kill";
}
//code that "kills" follows here
...

You need to wrap the code that kills in an else clause:

if ($rank < "Boss, Supreme Boss, Kingpin, Don, Godfather"){ 
  echo "You have to be ranked atleast Boss to kill";
}
else
{
  //code that "kills" follows here
  ...
}

OR simply exit the script immediately from the if clause:

if ($rank < "Boss, Supreme Boss, Kingpin, Don, Godfather"){ 
  echo "You have to be ranked atleast Boss to kill";
  exit;
}
hielo 65 Veteran Poster

(you can try it yourself @ http://www.birdnest.org/joshid2/bgrades.html -->username: student1 --->password: AAAAAAAA).

a. I went to that page and it has no field to enter the username
b. Based on your username and password arrays, student1 corresponds with password cNmeKFBc, NOT AAAAAAAA. In other words,
item 0 in $Ukeys should correspond to item 0 in $Pkeys
item 1 in $Ukeys should correspond to item 1 in $Pkeys
...
item 31 in $Ukeys should correspond to item 31 in $Pkeys

hielo 65 Veteran Poster

On line 67, you probably meant to write $var_Ulist = explode("\n",$var_data);

hielo 65 Veteran Poster

based on this:

Notice: Undefined index: page in C:\wamp\www\webdesigning1\webdesigning1\inc\index.php on line 28

my guess is that you have the post above in:
C:\wamp\www\webdesigning1\webdesigning1\inc\index.php

But it should be in:
C:\wamp\www\webdesigning1\webdesigning1\index.php

OR if you want to retain that code in:
C:\wamp\www\webdesigning1\webdesigning1\inc\index.php

then change $path = "inc/".$page.".php"; to $path = $page.".php";

hielo 65 Veteran Poster

line 26 should be { line 28 should be } also, you are missing the closing brace } for the first if Try:

<html>
<table width='70%' align='center'>
<tr>
<td>
<img src='inc/b.png'>
</td>
</tr>
</table>
<table width='20%' align='center'>
<tr>
<td>
<a href='index.php'>Home</a><br>
<a href='index.php?page=tutorials'>Tutorials</a>
</td>
<td width='80%'>
<?php
if( isset($_GET['page']) && !empty($_GET['page']) )
{
	$page=$_GET['page'];
	$path = "inc/".$page.".php";
	if (file_exists($path))
	{
		include($path);
	}
	else
	{//<-- should NOT be parenthesis
		echo"Page doesn't exist.";
	}//<-- should NOT be parenthesis
}//<-- you are missing this
?>
</td>
</tr>
</table>
</html>
hielo 65 Veteran Poster

line 27 is missing a semicolon at the end: echo"Page doesnt exist.";

hielo 65 Veteran Poster

try "APPENDING" the text. If you just swap the lines you have, then you would be overwriting the textarea with the text:

var table = document.getElementById(tableID); 
	var rowCount = table.rows.length;
	var row = table.insertRow(rowCount);  
	
	var cella = row.insertCell(0);
	cella.style.backgroundColor = "EAEAEA";
	var element1 = document.createElement("textarea");
	element1.cols = "9";
	element1.rows = "3";
	element1.name = "txtDescription[]";
	element1.size = "10";
	cella.style.fontWeight = "Bold";
	cella.appendChild(element1);
	cella.innerHTML += "UNIT ";
hielo 65 Veteran Poster

use the attr() method:
http://api.jquery.com/attr/

If you have
<div id="myid1" class="myid">Data1</div>
<div id="myid2" class="myid">Data2</div>


alert( $('.myid:eq(0)').attr('id') );
hielo 65 Veteran Poster

Ids must be unique, so you will need to change the id of at least one of them or you will likely experience cross-browser incompatibilities. However, it is OK to have multiple elements with the same class name. So, if you change those id='myid' to class='myid' then use $('.myid:eq(0)').html() to get the innerHTML of the first div. For the second div, change the zero to a ONE.

hielo 65 Veteran Poster

It seems that $row[0] and $row[1] contain Arrays, NOT the numeric value you think they have. Try using:
assuming they are INDEXED arrays, try $row[0][0] and $row[1][0] instead.

hielo 65 Veteran Poster

OK, so if you know HTML, then you should know that the syntax for an image is:

<img src="http://yoursite.com/" alt="some image description here"/>

What you need to do is make sure that the [B]SRC[/B] attribute points to some php page (let's call it imageRetriever.php) and that each url contains a unique ID to the image you want - ex:

<!-- You need to update the code you posted above so that it generates the following markup for EACH of the images. Given my example below, the assumption is that there would be only three images in your query result, but in your case it may be more or less. The 3, 12, and 47 I chose at random, but in your case these would be the unique ids for each of your images. -->
<img src="http://yoursite.com/imageRetriever.php?id=3" alt=""/>
<img src="http://yoursite.com/imageRetriever.php?id=12" alt=""/>
<img src="http://yoursite.com/imageRetriever.php?id=47" alt=""/>

Then in imageRetriever.php you need to use $_GET['id'] and use that value to query the db and send the binary data with the appropriate content-type (basically what you have above, but you need to do it for the reqquested image)

hielo 65 Veteran Poster

Are you trying to view the images via an HTML page? If yes, do you know what is the SYNTAX for an HTML Image?

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

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

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

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

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

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

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
//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

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

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

hielo 65 Veteran Poster

can't you just install any of those packages (the one you prefer) and then reverse-engineer the db design since that is all you want. You should be able to generate a diagram using MySQL workbench:
http://dev.mysql.com/downloads/workbench/

hielo 65 Veteran Poster

Load you page via the browser. Now look at the browser's source code. Are you seeing all the expected item ids? How are you sending/printing your first block of code. It looks incomplete, so I am wondering if you are using an echo (or print) WITH double quote delimiters.

hielo 65 Veteran Poster

If you query for ALL the fields, you can use a while to iterate through all the records. Then if you need to generate another "report" later on in the page you can use mysql_data_seek($result, 0); to "reset" the $result so it points back to the initial/first row WITHOUT having to requery the db