hielo 65 Veteran Poster

are you using the html entity for the pound symbol?
&#+163;
(remove the + sign. I added it because it was being interpreted as html on this site's editor)

http://htmlhelp.com/reference/html40/entities/latin1.html

Also, try adding this to your document's <head>:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
hielo 65 Veteran Poster

do you have a link to your page?

hielo 65 Veteran Poster

The variables YOU declare are not visible within the functions. But others like $_GET, $_POST, $_SERVER, etc, are "special". They are visible everywhere without the need to "declare them"/"use the global keyword" within functions.

As for your include, consider this:

file1.php
<?php
$greeting="Hello";
?>

file2.php
<?php
include("file1.php");

echo $greeting;//variable from file1.php visible here

sayItAgainIfYouCan();

function sayItAgainIfYouCan()
{
  echo $greeting;//but NOT visible here. You will need "global" keyword
}
?>
hielo 65 Veteran Poster
the firts code dont work because you return $cell, you MUST return $cell but printed or echoed, dont do

He is returning $cell and saving it onto $test, THEN he has print($test); . So in his case he needs to return $cell. His problem is related to variable scoping.

hielo 65 Veteran Poster

Glad to help.

Regards,
Hielo

PS: Don't forget to mark the thread as solved!

jackparsana commented: thanks for help +1
hielo 65 Veteran Poster

the variables declared OUTSIDE the function do NOT exist within the function. So you need to pass all of them (INCLUDING the connection to the db - assuming somewhere you did [B]$dbConnection[/B]=mysql_connect(...) :

$test = date_sched($month,$date,$num_teachers,$timeslot,$dbConnection);

function date_sched($month,$date,$num_teachers,$slot,$dbConnection){
...
}

ALTERNATIVELY, you can use the global keyword to instruct the php engine to look for those variables OUTSIDE of the function:

function date_sched($slot){
  global $month,$date,$num_teachers,$dbConnection;
 ...
}
hielo 65 Veteran Poster

Did you try:

xmlDoc.documentElement.childNodes[i].nodeValue
hielo 65 Veteran Poster

it sounds like your "main" page is index.php and you are posting to search.php. It that is the case your pagination links should have href="search.php..." , NOT href="index.php..." . It sounds like your links are posting to the "main" page (index.php in my example).

hielo 65 Veteran Poster

actually, instead of:

<script type="text/javascript">
    $(function() {
        $("#tabs").tabs();
    });
    </script>

use:

<script type="text/javascript">
    $(function() {
        $("#tabs").tabs({ cookie: { expires: 30 } });
    });
    </script>

BUT make sure you also import a copy of the cookie.js plugin:
http://plugins.jquery.com/project/cookie

hielo 65 Veteran Poster

'nickels' is a string, NOT a variable. Your variable is $_POST['nickels'] So do:
intval(VARIABLE) * MULTIPLIER:

<td align="right"><?php echo $totalCents=intval($_POST['pennies']) + (intval($_POST['nickels'])*5) + (intval($_POST['dimes'])*10) + (intval($_POST['quarters'])*25); ?></td>
hielo 65 Veteran Poster

assuming your pagination script is generating links SIMILAR to:

<a href="search.php?page=1">1</a>
<a href="search.php?page=2">2</a>

try changing it so the output is:

<a href="search.php?page=1" onclick="return ajaxSearch(document.getElementById('search'), this.href)">1</a>
<a href="search.php?page=2" onclick="return ajaxSearch(document.getElementById('search'), this.href)">2</a>

Then in your script tag, instead of the $(document).ready(...) you have, try the modified version below (include the ajaxSearch() function I am providing):

<script type="text/javascript">
function ajaxSearch(f,u)
{
     var ajax_div = $(f).attr("id")+"_results";
     var data = $(f).serialize() +'&search_button=Search';
     var url = u?u:$(f).attr("action");
     var type = $(f).attr("method").toUpperCase();
     $.ajax({
        url: url,
        data: data,
        type: type,
        success: function(data){
            $("#"+ajax_div).html(data);
        }
     });
     return false;
}

$(document).ready(function(){

  $("form.ajax").submit(function(){
  	ajaxSearch(this,'');
	return false;
  });

});
</script>
hielo 65 Veteran Poster

My pleasure Little Grasshopper.

hielo 65 Veteran Poster
hielo 65 Veteran Poster

In your ajax code, try changing:
if you alert() the value of data before the ajax request is sent, are you seeing the search_button? IF not change:

var data = $(this).serialize();

to:

var data = $(this).serialize() +'&search_button=Search';
andrewliu commented: Excellent help! brilliant! +0
hielo 65 Veteran Poster

>>Does it matter about my pagination page?
That depends on whether or not it is producing html code that would "break" your initial markup. Do you have a link to your page?

hielo 65 Veteran Poster

I suppose you could simply include a couple of radio buttons:

<input type="radio" name="member" value="buyer" checked="checked"/>Buyer
<input type="radio" name="member" value="seller"/>Seller

(OR a select list with the two options).

hielo 65 Veteran Poster

are you getting any error message reported? Have you verified that the script actually attempts to execute that query? Does the authenticated DB user have permissions to delete records on that db? Does you paragraph have the word 'Example' (uppercase) as opposed to 'example' (all lowercase)?

hielo 65 Veteran Poster

FYI: on your original post, you are trying to insert the result into '#search_results', BUT I did not see any element with id="search_results" . Be sure to provide a target element:

<div id="search_results"></div>
hielo 65 Veteran Poster

and HTML CLOSING comment tag does NOT have a "!" symbol. The proper comment should be:

<!-- the html tag -->

WRONG:

<!--require("includes/pagination.php")!-->

CORRECT:

<!-- require("includes/pagination.php"); -->

Fix that and try again.

hielo 65 Veteran Poster

but now when I test my alerts, I get div tag alerts in my SUCCESS alert, and for COMPLETE: success

OK, but does the SUCCESS alert also have the output of your php search script?

try:

$(document).ready(function(){

 $("form.ajax").submit(function(){
     var ajax_div = $(this).attr("id")+"_results";
     var data = $(this).serialize();
     var url  = $(this).attr("action");
     var type = "GET";//$(this).attr("method").toUpperCase();
    // alert([url, data, type].join("\n"));//debug alert
     $.ajax({
        url: url,
        data: data,
        type: type,
        success: function(data){
            alert("SUCCESS: " + data);//debug alert
            if( document.getElementById(ajax_div) )
            {
             $("#"+ajax_div).html(data);
            }
            else
            {
              alert('I was not able to locate any element with id=' + ajax_div +'. You must provide a "target" element in which to dump/load the results!');
            }
        },
	        complete: function(XMLHttpRequest, textStatus){
          //  alert("COMPLETE: " + textStatus);//debug alert
        },
        error: function(XMLHttpRequest, textStatus){
           // alert("ERROR: " + textStatus);//debug alert
        }
     });
     return false;
  });

});
hielo 65 Veteran Poster

This is what I have in the body of my doc (I didn't include the head because it doesn't seem relevant):

<body>
	
	<php?
		echo "Hello World. You suck!"; ?>
		
</body>

OK, but:
a. The name of the file need to end in ".php"
b. You MUST use the proper php tag delimiters:
WRONG: <php? (this is what you have)
CORRECT: <?php

hielo 65 Veteran Poster

>>Thank you hielo!
You are welcome!

>>Your solution worked perfectly. Do you have time to educate me a bit more?
Not really :)

Why did I need to create a new variable from the onclick event?
In an HTML document, ALL the id's MUST be unique throughout the document. Due to this requirement, getElementById('charID') should get you a reference to THE one and only node with said id. So this would be wrong:

<input type='radio' id='charID' name='charID' value="1"/>
<input type='radio' id='charID' name='charID' value="2"/>

Because now getElementById() cannot determine accurately which element you want/need. That's why I "recorded" the clicked item into a "common/global" variable. Every time you click on any of those charID buttons, the variable gets updated.

It is OK for the names to be the same, but NOT the id. Correct:

<input type='radio' id='charID1' name='charID' value="1"/>
<input type='radio' id='charID2' name='charID' value="2"/>

>>When I used document.getElementById("charID").value I would get a different ID number each time. Why is the charID getting garbles / changed / modified?
Again, it must be unique. It sounds like you were probably re-using that id for multiple elements.

hielo 65 Veteran Poster

the browser submits the NAME of your input fields, NOT the id. So you MUST give your fields a name="..." attribute:

<input type=text id="usrName" name="usrName" size="20">

the same goes for the other fields.

hielo 65 Veteran Poster
<!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">

<html>
<head>
<title>Search the Database</title>
<style type="text/css">
<!--
.inactive{visibility:hidden;display:none;}
-->
</style>
<script type="text/javascript">
<!--
function toggleOptions(sel)
{
	if(1*sel.value==2)
	{
		document.getElementById('termSearch').className='inactive';
		document.getElementById('dateSearch').className='';
	}
	else
	{
		document.getElementById('dateSearch').className='inactive';
		document.getElementById('termSearch').className='';
	}
}
//-->
</script>

</head>
<body>
	<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
	Search: <select name="type" onchange="toggleOptions(this)">
			<option value='1' selected>PO Number</option>
			<option value='2'>Date</option>
			<option value='3'>VIN Number</option>
		</select>
		for: 
			<input type="text" id='termSearch' name="term" />
			<span id="dateSearch" class="inactive">
				<!-- complete the rest of your options for each of the selects below -->
				<select name="Month">
					<option value="January">January</option>
					<option value="February">February</option>
				</select>
				<select name="Day">
					<option value="1">1</option>
					<option value="2">2</value>
				</select>
				<select name="Year">
					<option value="2010">2010</option>
					<option value="2009">2009</option>
				</select>
			</span>

			<br />
<input type="submit" name="submit" value="submit" />
</form>
</body>
</html>
<?php
$sql="";
if( isset($_POST) && !empty($_POST) )
{
	$fields=array('0'=>'UNKNOWN'
				,'1'=>'po_number'
				,'2'=>'date'
				,'3'=>'vin_number'
				);
	mysql_connect ("localhost", "user","pass") or die (mysql_error());
	mysql_select_db ("inventory");

	$type=$fields[ intval($_POST['type']) ];

	if('date'==$type)
	{
		$term = date('Y-m-d',strtotime("{$_POST['Month']} {$_POST['Day']} {$_POST['Year']} "));
		if( empty($term) )
		{
			echo 'Your must provide a date.';
		}
		else
		{
			$sql="SELECT * FROM `partsorder` WHERE `{$type}`='".mysql_real_escape_string($term)."'";
		}
	}
	elseif('UNKNOWN'!=$type)
	{
		$term=$_POST['term'];
		if( empty($term) )
		{
			echo 'Please enter a value.';
		}
		else
		{
			$sql="SELECT * FROM `partsorder` WHERE `{$type}` LIKE '%".mysql_real_escape_string($term)."%'";
		}
	}
	if(!empty($sql))
	{
		$result = mysql_query($sql) or die("Unable to execute<br />$sql<br />".mysql_error());
		if(0==mysql_num_rows($result))
		{
			echo 'No records found.';
		}
		else
		{
			while ( $row = mysql_fetch_array($result) )
			{
				//var_dump($row);
				$search_result .= '<br/> <B>PO Number:</B> '.$row['po_num'] . "\n";
				$search_result .= '<br/><B> Date:</B> '.$row['date'] . "\n";
				$search_result .= '<br/><B> VIN Number:</B> '.$row['vin_num'] . "\n"; …
hielo 65 Veteran Poster

Before answering your question, make sure you close your <FORM> tags at the end of each tab. Otherwise you will get unexpected behaviour across browsers.

As for your problem, the easiest approach to your problem is to bind an onsubmit method to your forms and submit an ajax request. That way the browser would not reload the page.

Alternatively, you can bind an onclick method/function to each of your tabs and create a cookie. When the page reloads, you will need to read that cookie and in init code for your tabs use that cookie to specify which tab to show first.

hielo 65 Veteran Poster
hielo 65 Veteran Poster

see code below. Notice that there is a leading space:

<input type="text" onchange="this.className+=' YourNewClassNameHere'" value="" />
hielo 65 Veteran Poster

IF title will always be the first child of catalog, then simply use:

xmlDoc.documentElement.childNodes[0].firstChild.nodeValue

if it is likely to change position, then you will need to "search" for it:

var i=-1, limit=xmlDoc.documentElement.childNodes.length;
while(++i<limit)
{
    if("title"==xmlDoc.documentElement.childNodes[i].nodeName)
    {
        alert(xmlDoc.documentElement.childNodes[i].firstChild.nodeValue)
    }
}
hielo 65 Veteran Poster

Based on the fact that you are using document.getElementById("IncludeCharges_no").value , my guess is that you have:

<input type="radio" id="IncludeCharges_no".../>
<input type="radio" id="IncludeCharges_yes".../>

However, the browser does NOT provide/send the id to the server. Instead, it uses the name. So all you need to do is give both buttons the same name. Only the name and value of the checked item will be sent:

<input type="radio" id="IncludeCharges_no" name="IncludeCharges" value="0" />
<input type="radio" id="IncludeCharges_yes" name="IncludeCharges" value="1" />

On another note, this:

int Includecharges = Integer.parseInt(request.getParameter("IncludeCharges_yes");

is missing a closing parenthesis, but with the changes in html as suggested it should be:

int Includecharges = Integer.parseInt(request.getParameter("IncludeCharges"));
hielo 65 Veteran Poster

try adding a "fake" field with a fixed valud for each of the selects and use that as your primary sort field:

( SELECT 1 as `temp`, `name`, `date` FROM `events` WHERE `date` >= curdate()  ) UNION ALL ( SELECT 2 as `temp`, `name`, `date` FROM `events` WHERE `date` < curdate()  )
ORDER BY `temp`, `date`
hielo 65 Veteran Poster

Glad to help.

Regards,
Hielo

PS: Don't forget to mark the thread as solved!

hielo 65 Veteran Poster

instead of:

echo "<input type='radio' id='charID' name='charID' value='" . $row['characteristicID']
                  . "'/> " . $row['characteristic'] . "<br />" ;

try:

echo "<input onclick='window.clickedCharID=this.value' type='radio' id='charID' name='charID' value='" . $row['characteristicID']
                  . "'/> " . $row['characteristic'] . "<br />" ;

then on the function that you need to know which of the radio buttons was checked all you need to do is test to see if it the variable clickedCharID exists:

if(typeof(window.clickedCharID)!="undefined"){
 alert(window.clickedCharID);
}
hielo 65 Veteran Poster

Glad to help Little Grasshopper.

Regards,
Hielo

hielo 65 Veteran Poster
function ajaxpage(url,container)
{
 if(/\.(gif|png|jpg)$/i.test(url))
 {
   document.getElementById(container).innerHTML='<img src="'+url+'" alt="" />';
  return;
 }
 //whatever you currently have, should remain untouched
 ...
}
hielo 65 Veteran Poster

What you are actually (incorrectly) doing now is inserting the "BINARY" image content into the div. What you need to do is to insert and <IMG> tag into the div and set the SRC attribute to the path of the image. The browser will take care of the rendering.

qazplm114477 commented: nice, getting all that from such a short post +1
hielo 65 Veteran Poster

The first two are missing a semicolon at the very end to "end" the echo statement.
as for the <b></b>, I believe that is added by the text area where on this site (where I am typing this response). I've noticed it only when I click on "Toggle Plain Text" to get the plain text for editing, but if I click on it again (so it reverts to hmtl) it is invisible (since it IS HTML). Long story short, it should not have been there.

hielo 65 Veteran Poster

first, start with "blank" html body - just the basic structure with nothing in the body.

Then add your table markup with EMPTY cells (<td>) and run it through the validator. If you did anything wrong, it should give you feedback as to what you did wrong. Once you have a valid table then continue to add the ordered list to the cells. Add the TOP-most list first and run it through the validator, fixing any errors before proceeding. Then add the second level list within the list item tag, and then run it through the validator, and fix any errors. Keep repeating this until you are finished nesting your lists.

Here's a pointer for you:
An <ol> is NOT allowed to have another <ol> as its immediate child - ex:

<ol>
   <li>...</li>
   <li>...</li>
   <ol><li>...</li></ol><!-- WRONG: ol cannot be an immediate child of another ol -->
</ol>

an <ol> (and <ul> ) can only have <li> as an immediate child. So if you want to nest <ol> it must be wrapped in an <li>

<ol>
   <li>...</li>
   <li>
     <ol><li>...</li></ol>
   </li>
</ol>

In your case, pay attention to lines 41 and 49. You close the <li> at the wrong spot, leaving the <ol> as an immediate child of another <ol>. This same error happens in other places as well.

Line 126 is also a problem. Again, an OL and UL can only have an LI as an immediate child, so the SPAN has no business there. …

hielo 65 Veteran Poster

you need to prefix the double quote with a slash if your echo command uses the double
quotes:

echo "Welcome Guest!<br><a href='#' onclick=\"javascript:ajaxpage('login.php', 'ajax');\">"

Here's another implementation:

echo 'Welcome Guest!<br><a href="#" onclick="javascript:ajaxpage(\'login.php\', \'ajax\');">'

and another (look up the sprintf() function on the php.net site if it is not obvious to you what it is doing):

echo sprintf('Welcome Guest!<br><a href="#" onclick="%s">'
              ,"javascript:ajaxpage('login.php', 'ajax');");

and another one:

//begin echoing UNTIL you find the line that STARTS with the matching MYLINK+semicolon
echo <<<MYLINK
               Welcome Guest!<br><a href="javascript:ajaxpage('login.php', 'ajax');">
MYLINK;
/*on the line above, there MUST be a newline IMMEDIATELY after the semicolon. You cannot have any blanks between the semicolon and the newline; otherwise you will get a runtime error.*/
hielo 65 Veteran Poster
Talk about egg on my face

Let's make that a pie instead. That way at least you will "enjoy" somewhat:)

It happens. Thanks for the info on the other matter.

Regards,
Hielo

hielo 65 Veteran Poster
You both had introduced a relatively well known performance no no in your codes.

I didn't. The count is in the initializing part of the for construct.
"The first expression (expr1) is evaluated (executed) once unconditionally at the beginning of the loop."
http://us3.php.net/manual/en/control-structures.for.php

You should never have a function call in your loops.

agree

You can also remove the is_array check from your code by specifying the the parameter passed is of type array. Unfortunately besides object types and the array type there are no other function argument types you can use.

Excellent! Thanks for that.

hielo 65 Veteran Poster

If you are using MySQL and the data type of your fields in your table are DATETIME, then what you need to know is that the dates are stored in the following format: yyyy-mm-dd, NOT in mm/dd/yyyy. So try:

$validFrom =date('Y-m-d');
$validTo=date('Y-m-d',strtotime("now +2 years"));
hielo 65 Veteran Poster

hielo you code doesn't work.

I respectfully disagree. It works fine for me. Are you perhaps sending too many requests in short period of time to their network as FlashCreations stated?

hielo 65 Veteran Poster

On index.php, when you call ajaxpage('page1.php', 'rightcolumn');

then your rightcolumn will have html - the html from page1.php:

<div id="rightcolumn">
<a href="javascript:ajaxpage('page4.php', 'rightcolumn');">page4</a>
</div>

When you click on page4, it should load it into the rightdiv of index.php because that link now exists within index.php.

On another note, page1.php should NOT send any element with id="rightcolumn" because index.php already has an element with that id. An id MUST be unique throughout the document even if you are populating elements via ajax.

hielo 65 Veteran Poster

LOL. Yes of course. An oversight of my part. It should be:

$data[ $arr[$i] ]=isset($arr[1+$i]) ? $arr[1+$i]: '';

As a gesture of good faith let me return the favour and tell you that your while needs to check for "less than", not "less than or equal to".

Regards,
Hielo

hielo 65 Veteran Poster

try $date=date('m-d-Y');

hielo 65 Veteran Poster
function toAssoc($arr){
 $data=array();
 if(is_array($arr))
 {
   for($i=0,$limit=count($arr); $i < $limit; ++$i)
   {
      $data[$i]=isset($data[1+$i]) ? $data[1+$i]: '';
      ++$i;
   }
 }
return $data;
}
hielo 65 Veteran Poster

You are welcome.

Regards,
Hielo

PS: Don't forget to mark the thread as solved.

hielo 65 Veteran Poster

OK, then yes, it's like I suspected. You will need to use the PHPMailer class and connect to a REMOTE smtp server and send email out from that remote server.

For example, if you have a gmail account:
http://www.web-development-blog.com/archives/send-e-mail-messages-via-smtp-with-phpmailer-and-gmail/

hielo 65 Veteran Poster

without regex, the alternative is to list ALL the characters you don't want and use str_replace() to remove them - ex assuming you do not want any of the following:
# _ -

then use:

$str=str_replace('#_-','',$str);
echo $str;

but it is easier if you list only the ones that you DO want and use a regex to do the filtering.

hielo 65 Veteran Poster

Glad to help.

PS: Don't forget to mark the thread as solved.