heels 0 Light Poster

Hi All,

I am tasked to generate report templates in excel and I am new to excel, VBA and still learning.

A little more information on my task, the information for the report will be extracted from different sheets in the workbook which contains a whole list of calculation and description thus, within the same excel file I have created another sheet, sheet2 with the report format and linked the necessary information needed from sheet1.

In sheet1, there are checkboxes(control form) that states the type of materials used and upon being checked, the material ID should be reflected in sheet2 in a table format and the total number of rows for the table should be dependent on the total number of ticked checkboxes. I would like to know how should I go about checking the total number of checkboxes ticked to set the total number of rows for the report table and reflect the material ID?

Thanks!

heels 0 Light Poster

Sorry.
What i did was to reinstall the whole xampp again and download mysql-connector. Store it in the same folder as xampp and copy mysql-connector...bin.jar file into xampp/tomcat/lib and to xampp/tomcat/webapps/<foldername>/WEB-INF/lib

That was what i did, any better solutions ?

heels 0 Light Poster

Hi,

I am currently using xampp with all the preloaded add ons, such as tomcat, mysql and apache. When i try to connect to the database through my computer with windows xp, it works perfectly fine. But when i changed it to another OS, windows vista. It keeps giving me the error, Communication Failure During Handshake.

So can i safely deduce that it is the OS problem ?

Thanks,
Heels

heels 0 Light Poster

Well, if putting it in the inner loop gives you too many lines, try putting it in the outer loop instead. Step back and look. How many lines do you want? How many times does it go through the inner loop? How many times does it go through the outer loop? That tells you where to put the println.

Thanks man! i finally can see it and understand this looping better now. :)

heels 0 Light Poster

Sorry, i've put the println in the innest for loop, but it gives me 6 rows of results instead.

Enter height: 3
AA
BB
AA
AA
BB
AA
AA
BB
AA

I'm getting very very confuse now.

heels 0 Light Poster

Hi,

I am facing problem with my coding but can't seems to find the problem with it. Can someone guide me?

//for loop
			for (line=1; line <=height; line++)
			{	for(col=1; col <=line; col++)
				{
					if (line%2 !=0)// odd line
					{
						if (col%2 != 0)//odd line,odd col
						System.out.print(A);
					
						else //(col%2 == 0) //odd line, even col
						System.out.print(B);
		
					}
					
					if (line%2 == 0)//even line
					{
						if(col%2 !=0)//even line, odd col
						System.out.print(A);
						
						else //(col%2 == 0)//even line, even col
						System.out.print(B);
					}
				}
			}
		}
		else 
			System.out.println (height + "- Error input!!");
	}

the output should be
AA
BBAA
AABBAA
when height = 3

but instead, my output is AAAABBAABBAA.

Thanks.

Regards,
Heels

heels 0 Light Poster

try looking at this great example:
http://www.guidesandtutorials.com/dr...t_toolbar.html

Hi,

There is no such URL at the domain. Mind pasting me the whole URL again? Thanks.

Regards,
heels

heels 0 Light Poster

if there are errors it should not insert into the DB so it will repopulate using what is in the DB.
are you asking how to repopulate the form with their selections only highlighting the section that caused the error?

yeah, something like that. :)

heels 0 Light Poster

Simple..

$txtFname = isset($_POST['txtFname'])?$_POST['txtFname']:$contact['firstName'];
//if txtFname is set, then assign that value to $txtFname, else, assign $contact['firstName'] to $txtFname.

and then,

First Name: <input type="text" name="txtFname" value="<? echo $txtFname; ?>" /><br />

Thanks, it is working perfectly. But I am a little confuse over here, can you help me with it?

Over here, will be an edit function. This is redirected from the main page through their ID, so it will retrieve the contact details and "echo" them into the necessary text fields. So after the person makes the necessary changes, he/she will click the "Save" button.
When the "Save" button is clicked, it will start validating that the necessary fields are filled up and with no errors, if it fits the condition, it will automatically save the changes in the database.

But if there are missing textfields or errors, it will repopulate the form again with the changes being made previously, together with the error message.

The main problem now is, if there are any errors, it will repopulate the form again with the 1st set of values being selected from the database again and not the values with the changes being made. So how do i get started?

heels 0 Light Poster

Here are some examples for textboxes, checkboxes, radio buttons and select drop downs:

<?
session_start();

//collect text box values
$txtFname = isset($_POST['txtFname'])?$_POST['txtFname']:"";
$txtLname = isset($_POST['txtLname'])?$_POST['txtLname']:"";
$txtMI = isset($_POST['txtMI'])?$_POST['txtMI']:"";

//values for ages select element
$ages = array();
		$ages[] = "1 - 10";
		$ages[] = "11 - 20";
		$ages[] = "21 - 30";
		$ages[] = "31 - 40";
		$ages[] = "41 - 50";
		$ages[] = "51 - 60";
		$ages[] = "61 - 70";
		$ages[] = "71 - 80";
		$ages[] = "81 - 90";
		$ages[] = "91 - 100";
//selected value for ages
$selAge = isset($_POST['selAge'])?$_POST['selAge']:"";

//build and set selected values for chk boxes interests
$interests = array();
$interests["IT"] = (isset($_POST['chkInterests']) && in_array("IT", $_POST['chkInterests']))?' checked="checked"':"";
$interests["Snowboarding"] = (isset($_POST['chkInterests']) && in_array("Snowboarding", $_POST['chkInterests']))?' checked="checked"':"";
$interests["Hockey"] = (isset($_POST['chkInterests']) && in_array("Hockey", $_POST['chkInterests']))?' checked="checked"':"";
$interests["Football"] = (isset($_POST['chkInterests']) && in_array("Football", $_POST['chkInterests']))?' checked="checked"':"";

//build and set selected values for radio buttons Gender
$rdoGender = array();
$rdoGender["Male"] = (isset($_POST['rdoGender']) && $_POST['rdoGender'] == "Male")?' checked="checked"':"";
$rdoGender["Female"] = (isset($_POST['rdoGender']) && $_POST['rdoGender'] == "Female")?' checked="checked"':"";
?>
<!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>
</head>

<body onload="startTime();">
<form method="post" action="<? echo $_SERVER['REQUEST_URI']; ?>">
	First Name: <input type="text" name="txtFname" value="<? echo $txtFname; ?>" /><br />
	Last Name: <input type="text" name="txtLname" value="<? echo $txtLname; ?>" /><br />
	MI: <input type="text" name="txtMI" value="<? echo $txtMI; ?>" /><br /><br />
	Age:<br />
	<select name="selAge">
		<?
			foreach($ages as $age)
			{
			?>
				<option <? if($age == $selAge) echo ' selected="selected"'; ?> value="<? echo $age; ?>"><? echo $age; …
heels 0 Light Poster

Hi,

How do you retain values entered in the textbox after submitting? javascripts or any other methods? Thanks alot.

Regards,
heels

heels 0 Light Poster

:'( I am lil too late to reply !

hahaha, so cute. Thanks guys. Will check out the website and try out nav33n's method too :). You're not too late but you gave me another idea to try too.

heels 0 Light Poster

Hi,

Is it possible to use images for a button instead of the normal button?
I am not trying to link it to another page over here but, getting it to trigger some event like a normal button.
Thanks alot.

Regards,
heels

heels 0 Light Poster

because the javascript was need on the image itself because its not an submit element.

<input type="image" src="image.jpg" />

is the same as

<input type="submit" value="Submit" />

Oh, i understand it now. Thanks alot for teaching me. :).

heels 0 Light Poster

you can get rid of the onclick="javascript:this.form.submit()" , its not needed anymore.

why is that so?

heels 0 Light Poster

why is there <b></b> tags in the onclick? that is the problem.

haha, thanks dude, anyway the <b></b> doesn't affect anything.
changed it to

<input type="image" src="magnifyingGlass.jpg" width="15" height="15" border="0" alt="Search" onclick="javascript:this.form.submit()" />

now it is working perfectly fine.
THANKS ALOT. :)

heels 0 Light Poster

it should be able to. i put the onlick attribute there and that should invoke the submittion of the form upon the clicking of the image. no idea whats happening.

do you have the from online, if so post the url and I will look at this problem.

hm, i do not have the online form cause it is running on my server.
well, this is my form codes.

<!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=iso-8859-1" />
<title>Corporate Phone Book</title>
<style type="text/css">
<!--
.style1 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: medium;
	font-weight: bold;
}
.style7 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: x-small;
}
.style13 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small;}
.style17 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: x-small; color: #0000FF; }
-->
</style></head>
<form method="get" action="Search.php">
<body>

<table width="119%" border="0" cellspacing="0" cellpadding="0">

  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
  <?php
//connecting to database
			include ("config.php");
			include ("opendb.php");
?>
  <tr>
    <td colspan="2"><span class="style1">Search function</span></td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td height="69" colspan="2"><table width="894" height="82" border="0" cellpadding="0" cellspacing="1">
      <tr>
        <td width="406" rowspan="2"><table width="100%" height="57" border="0" cellpadding="0" cellspacing="1">
          <tr>
            <td width="402" height="42"><table width="100%" height="56" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
              <tr>
                <td height="16" bgcolor="#CCCCCC" class="style13"><p>Search by first name ,last name and company name</p>                  </td>
              </tr>
              <tr>
                <td bgcolor="#F0F0F0">
                  <div align="left">
                    <input name="txtSearch" type="text" id="txtSearch" size="40" />
<img src="magnifyingGlass.jpg" alt="Search" width="15" height="15" border="0" onclick="javascript<b></b>:this.form.submit()" />

            </table></td>
			
            </tr>

Thanks alot once again.

heels 0 Light Poster

this should do it:

<form action="search.php" method="get">
	<input name="txtSearch" type="text" id="txtSearch" size="40" />
	<img src="magnifyingGlass.jpg" alt="Search" width="15" height="15" border="0" onclick="javascript:this.form.submit()" />
</form>

what i did was change the method of the form to get and added some javascript to make the form submit when the image is clicked (eliminating the link).

you couldn't of done this the way you had because the form must be submitted before you can access those values via $_GET or $_POST arrays.

oh, i see. but the image button now can't be clicked?! what is happening?
i'm so sorry for the trouble caused, thanks alot for your help man.

heels 0 Light Poster

post your code and I will make adjustments and tell you what i did.

thanks man,

here it is.

<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?> ">

<input name="txtSearch" type="text" id="txtSearch" size="40" />

<a href="Search.php?txtSearch=<?php echo $txtSearch=$_POST['txtSearch'];?>"><img src="magnifyingGlass.jpg" alt="Search" name="Search" width="15" height="15" border="0" id="Search" /></a>
heels 0 Light Poster

you use a form with either get or post method.

once the form is submitted you can access this data by using:

//This is used when form method is get
$var = $_GET['input_name'];

//This is used when form method is post
$var = $_POST['input_name'];

input_name is the name of the form element in which you are trying to get info from.

yeah, tried that. but apparently still passing empty values. is it because you can't pass values through an image link?

heels 0 Light Poster

you can send it through the address

<a href="yourpage.php?info=imageinfo">

then on your other page you can grab the info using

$info = $_GET['info'];

this will grab whatever info your sending through the link from image.

Yeah, it works :). But i am trying to get the values from the textbox and pass it to another page. How can it be done? Sorry, i am very new to php. Thanks for your help.

heels 0 Light Poster

Hi,

i would like to know if it is possible to pass values from one page to another through an image link? I've have tried to "echo" the values but it seems like the values are not passing into the other page. Any suggestions on how to do it?

regards,
heels

heels 0 Light Poster

This should be your code.

$result = mysql_query($sql);

if ( $result )
{ 
  echo "Contact successfully added.";
}
else
{
  echo mysql_error(); 
}

If this does not work, their may be something wrong in your sql statement.

ah, thanks alot. :).

heels 0 Light Poster

Hi!

When executing a query which alters the table (UPDATE, INSERT, etc...), mysql_query returns TRUE on success and FALSE on error.

So your if-clause should read

if ($result == TRUE) {

or simply

if ($result) {

Hope that helps!

Happy coding! :)

hey,

I've tried your method, but it is still not working and the success message is being displayed whenever it loads for the first time. Any idea why is this happening?

Regards,
heels

heels 0 Light Poster

hi,

I am doing a insert query over here and if the query is executed successfully, there will be a success message. However, whenever the query is being executed successfully, the success message is not being displayed.

here is a snipet, can anybody guide me along? thanks alot.

//Execute SQL Statement and store results as a recordset
  $result= mysql_query($sql) or die (mysql_error());

if ( $result != ""  )
  { 
	echo "Contact successfully added.";
  }
  else
   {
echo "Please try again."; 
   }
heels 0 Light Poster

ah, thanks alot. PROBLEM SOLVED :)

heels 0 Light Poster

hi,

this is a snippet of my codes,

<td><a href="editFunction.php?ID=<?php echo $contact; ?>">update</a></td>
after clicking "update", the ID will be passed to the editFunction.php page.

editFunction.php

<?php 
		//get variables from previous page
		$ID = $_GET['ID'];
		
		
		//sql statement to retrieve the commands 
		$sql = "SELECT * FROM contacts WHERE ID LIKE '".$ID."'";
		
		//execute query 
		$result = mysql_query($sql) or die (mysql_error());
		
		//display on table 
		$contact = mysql_num_rows($result);  {
?> 
.
......
<td width="140"><span class="style2">ID : </span></td>
    <td width="384">
	  <input name="ID" type="ID" id="ID" value="<? echo $_GET['ID'] ?>" size="50" readonly />        </td>
  </tr>
  <tr>
    <td width="140"><span class="style2">First Name : </span></td>
    <td width="384">
      <input name="firstName" type="text" id="firstName" value="<? echo $contact['firstName'] ?>" size="50" />        </td>
  </tr>
</table>

<?php 
			
            }
?>
</body>
</html>

why aren't my results displaying out in the respective fields except for ID?
where do i start debugging? Thanks alot.

heels 0 Light Poster

You set the form's action to <?php echo $_SERVER['PHP_SELF'] ?> . The page will post back to itself.

AH, thank you. :)

heels 0 Light Poster

Hi,

I was just wondering if php is able to do the 'page post back function' like asp.net ? If possible, can someone guide me along with it or any site recommendations for reading up will be greatly appreciated. Thank you. :)

Regards,
heels

heels 0 Light Poster

The simplest way to solve that error is to print out the query and execute it phpmyadmin / mysql console. You will know the exact problem. You can also try $result = mysql_query($query) or die (mysql_error()); to get the error message. Also, mysql_fetch_row should be used if you are using numeric index for your array. ie., $row[0], $row[1] and so on. If you want associated names, you should use mysql_fetch_array or mysql_fetch_assoc.

Ah, thanks alot. problem solved. :)

heels 0 Light Poster

http://www.w3schools.com/PHP/php_mysql_intro.asp

That should help! :)

Ah. :) thanks alot. but i have another problem again. what do they mean by,
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource ?

here is part of the code,

ORDER BY firstName ASC";

    $result = mysql_query($query); 

echo "<table border='1'>
        <tr>
        <th>ID</th>
        <th>FirstName</th>
        <th>LastName</th>
        <th>CompanyName</th>"

             while($row=mysql_fetch_row($result))
            {
                echo "<tr>";
                echo "<td>" .$row['ID']."</td>";
                echo "<td>" .$row['FirstName']."</td>";
                echo "<td>" .$row['LastName']."</td>";
                echo "<td>" .$row['CompanyName']."</td>";
echo "</table>";

so sorry to trouble you again. mind telling me where is my mistake? :)
Thanks again.

heels 0 Light Poster

Hi,

I am a newbie to PHP and HTML and over here i am trying to display my sql results in a table format like this,

ID. Name. Contact
---------------------------------------------
----ROW1----------------------------------
----ROW2----------------------------------

any site recommendations where i can get help from? thanks alot.