pancgom 0 Light Poster

do u mean while retrieving data u want the
drop down to be selected

Yes....with the data that corresponds to that particular user...

pancgom 0 Light Poster

Use something like this

<?php
echo '<select name='dropdown' id='dropdown'>
<option> -- select -- </option>';

$sql = "SELECT * FROM table";
$result = mysql_query($sql);

while($row=mysql_fetch_array($result, MYSQL_ASSOC)){
echo '<option value="'.$row['country'].'">'.$row['country'].'</option>';
}
echo '</select>';
?>

This should work for you. Obviously change the SQL to suit your database, etc.

This works yes....but my question is i use the values in the drop down to insert into the database once i click the submit button, but the same fields which i use to insert have also have to display the information that has been entered into the database...as you see this just a part of the form that i am building.....i have a session id that will keep track of which user is logged and it will show only that particular users records...the text boxes are working but not the drop down boxes in this case...

pancgom 0 Light Poster

Hi,

I have this form which has got all these drop down boxes which has values built in the html form, once selected they are all sent to the database table to be stored only when the authentication is done and for that record only.

I am also using the same form to retrieve information from the database and display back to the form. The problem is i am not able to display data retrieved from the database into the drop down boxes. Can someone please help me the code please.

Thanks much for the help.

<?php
include 'init.php';

if (!is_authed())
{
        header("Location: http://xxxx/wewewe/wee.ph");
        exit;
}
$ID = $_SESSION['ID'];

$results = mysql_query("SELECT * FROM `WorkExperience` WHERE ID=$ID");
$row = mysql_num_rows($results);
if($row == 0)
{
        mysql_query("INSERT INTO `WorkExperience` (ID) VALUES ('$ID')");
}

if($_POST['save'] || $_POST['next'])
{ 



$CountryOfEmployment = $_POST['CountryOfEmployment'];
$CommencementDate = $_POST['CommencementDate'];
$CommencementMonth = $_POST['CommencementMonth'];
$CommencementYear = $_POST['CommencementYear'];



$query = "UPDATE `WorkExperience` SET CountryOfEmployment='$CountryOfEmployment', CommencementDay='$CommencementDay', CommencementMonth='$CommencementMonth', CommencementYear='$CommencementYear' WHERE ID=$ID";


mysql_query($query);
}

if($_POST['next'])
{
        header("Location: gotonextpage.php");
        exit();
}

$query = "SELECT * FROM `WorkExperience` WHERE ID=$ID";
$results = mysql_query($query);
$data = mysql_fetch_array($results);


$CountryOfEmployment = $data['CountryOfEmployment'];
$CommencementDay = $data['CommencementDay'];
$CommencementMonth = $data['CommencementMonth'];
$CommencementYear = $data['CommencementYear'];


?>





<!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>Graduate Admission System (Research Programme)</TITLE>

<link href="CSS/GraduateProgram.css" rel="stylesheet" type="text/css">

</head>

<body bgcolor="#FFFFFF" topmargin="0">
<br>
  <br>


<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post" name="pg6.php"> 
  <TABLE  border=0 ALIGN="center" cellpadding = 3 cellspacing = 0  width="1000" style="border:1px …
pancgom 0 Light Poster

Hi,

I have this page which has 2 fields name of the referee then the email address of the referee , this will be the first set of information. Then when the user click the add reference button there has to be another set of fields similar to the one on top for the next set of references.

I have posted a similar request earlier but i just could not figure out how this is done. Can anyone help me with the code please.

Thanks.

<?php
include 'init.php';

if (!is_authed())
{
        header("Location: xxxxxxxxx/login.php?fail=3");
        exit;
}
$ID = $_SESSION['ID'];

$results = mysql_query("SELECT * FROM `References` WHERE ID=$ID");
$row = mysql_num_rows($results);
if($row == 0)
{
        mysql_query("INSERT INTO `References` (ID) VALUES ('$ID')");
}

if($_POST['save'] || $_POST['next'])
{
$NameOfReferee = $_POST['NameOfReferee'];
$EmailAddress = $_POST['EmailAddress'];

$query = "UPDATE `References` SET NameOfReferee='$NameOfReferee', EmailAddress='$EmailAddress' WHERE ID=$ID";
mysql_query($query);
}

if($_POST['next'])
{
        header("Location: xxxxxxxx/pg6.php");
        exit();
}

$query = "SELECT * FROM `References` WHERE ID=$ID";
$results = mysql_query($query);
$data = mysql_fetch_array($results);

$NameOfReferee = $data['NameOfReferee'];
$EmailAddress = $data['EmailAddress'];
?>




<!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>xxxxxxxxxxx</TITLE>

<link href="CSS/GraduateProgram.css" rel="stylesheet" type="text/css">


</head>


<body bgcolor="#FFFFFF" topmargin="0">



<table width=1000 align="center" border="0" cellspacing="0" cellpadding="0" bgcolor="#FF6600">
    <tr>
      <td bgcolor="#FFFFFF"><img src="images/xxxxxxx.png" alt="xxxxxxxxx" width="450" height="92"></td>
    </tr>
  </table>
  <br>
  <table width=1000 border="0" align="center" cellpadding="3" cellspacing="0" bgcolor=white style="border:1px solid #999999;" valign=top>
    <TR>
      <td height="30" colspan=3 align="left" valign="middle" bgcolor=#ff9933 class="BodyTextHeaders">Section VI - Academic References</td>
    </TR>
    <TR>
      <td colspan=3 align="left" valign="top" bgcolor=white class="BodyText">Application Number:</td>
    </TR> …
pancgom 0 Light Poster
<input type="radio" name="WorkExperienceYesNo" value="Yes" >Yes
         <input type="radio" name="WorkExperienceYesNo" value="No">
              No

when the user clicks either yes or no will get insert....use ordinarry insert query

Hi,

Thanks for you reply..but my need is a bit more complicated than this...i do know how to do this.....

here is what my above code does....

it accepts the input from the form once the user is logged in and authenticated....the values are stored and then retrieved as and when the user needs it....the radio button field has the same name ....i am using the value attrib to insert the user input as you can see from the code...my sql table has only one field set to receive the data from the radio button....below the specific code..

if($_POST['save'] || $_POST['next'])
{ 

$WorkExperienceYesNo = $_POST['WorkExperienceYesNo'];
<input type="radio" name="WorkExperienceYesNo" value="Yes" "<?=$WorkExperienceYesNo?>" >
              Yes
              <input type="radio" name="WorkExperienceYesNo" value="No" "<?=$WorkExperienceYesNo?>" checked>
              No    </td>
pancgom 0 Light Poster

can you post the form code so I can make the php code based on that.

<?php
include 'init.php';

if (!is_authed())
{
        header("Location: http://xxxxxxxx/login.php?fail=3");
        exit;
}
$ID = $_SESSION['ID'];

$results = mysql_query("SELECT * FROM `WorkExperience` WHERE ID=$ID");
$row = mysql_num_rows($results);
if($row == 0)
{
        mysql_query("INSERT INTO `WorkExperience` (ID) VALUES ('$ID')");
}

if($_POST['save'] || $_POST['next'])
{



$WorkExperienceYesNo = $_POST['WorkExperienceYesNo'];



$query = "UPDATE `WorkExperience` SET WorkExperienceYesNo='$WorkExperienceYesNo'' WHERE ID=$ID";
mysql_query($query);
}

if($_POST['next'])
{
        header("Location: http://xxxxxxx/pg7.php");
        exit();
}

$query = "SELECT * FROM `WorkExperience` WHERE ID=$ID";
$results = mysql_query($query);
$data = mysql_fetch_array($results);

$WorkExperienceYesNo = $data['WorkExperienceYesNo'];


?>

<!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>Graduate Admission System (Research Programme)</TITLE>

<link href="CSS/GraduateProgram.css" rel="stylesheet" type="text/css">

</head>

<body bgcolor="#FFFFFF" topmargin="0">

<table width=1000 align="center" border="0" cellspacing="0" cellpadding="0" bgcolor="#FF6600">
    <tr>
      <td bgcolor="#FFFFFF"><img src="images/xxxx.png" alt="xxxxxxx" width="450" height="92"></td>
    </tr>
</table>
 
  <br>
<table width=1000 border="0" align="center" cellpadding="3" cellspacing="0" bgcolor=white style="border:1px solid #999999;" valign=top>
  <TR>
    <td height="30" colspan=3 align="left" valign="middle" bgcolor=#ff9933 class="BodyTextHeaders" >Section VII - Employment History</td>
  </TR>
  <TR>
    <td colspan=3 align="left" valign="top" bgcolor=white class="BodyText" > Application Number :</td>
  </TR>
  <TR>
    <td colspan=3 align="left" valign="top" bgcolor=white class="BodyText" > Applicant Name :</td>
  </TR>
  <TR>
    <td colspan=3 align="left" valign="top" bgcolor=white class="BodyText" > Please note that only personal details can be amended.
      For amendments on other data, please contact the 
    administrator for assistance. </td>
  </TR>
  <TR>
    <td colspan=3 align="left" valign="top" bgcolor=white class="BodyText" > Items indicated with an asterisk * are mandatory. </td>
  </TR>
  <TR>
    <td colspan=3 align="left" valign="top" bgcolor=white class="BodyText" …
pancgom 0 Light Poster

Hi,

I have 2 radio buttons which needs to submit a checked value to the database and then retrieve the same when called back in to display...any idea where i can get an example for this..

thanks a lot..

pancgom 0 Light Poster

can you check whether form tags are closed corrected or not.
also can you post code here?

Below is the code...thanks much for the help

<?php
session_start();
?>

<head>

<title>#*$!xx</title>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link href="CSS/program.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
<!--
function MM_validateForm() { //v4.0
if (document.getElementById){
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 ¦¦ p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min ¦¦ max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
} }
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<br>
<?php

$db_host = "localhost";
$db_user = "#*$!xx";
$db_pwd = "#*$!#*$!";
$db_name = "#*$!#*$!";
mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name);

?>

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

<table width=1000 border="0" align="center" cellpadding=3 cellspacing="0" style="border:1px solid #999999;">
<tr>
<td height="30" colspan="2" valign="middle" bgcolor="#FF933" class="BodyTextHeaders">User Login / Registration</td>
</tr>
<?php
if (!isset($_POST['submit'])) {
?>
<tr>
<td width=200 valign="middle" bgcolor="#E8E8E8" class="BodyText"><strong>Username
:</strong></td>
<td width="786" valign="top" bgcolor="#E8E8E8" class="BodyText">


<input name="Username" type="text" class="BodyText" id="Username" value="Enter email address" size="50"></td>
</tr>

<tr>
<td width=200 valign="middle" class="BodyText"><strong>Password :</strong></td>
<td valign="top" …
pancgom 0 Light Poster

I have a page1.php which is a form and i want to be able to go to page2.php when i click submit in page1.php.?
How do i do that ...my page1.php is a self processing form.


this is what i have now...

<form action="<?php echo $_SERVER?>" method="post"> - this is sending data to the database but not the one below

I tried the one as below as well but no use.

<form action="page2.php" method="post">

but not working...

pancgom 0 Light Poster

Hi,

I am trying to build a multipage php form using mysql as the backend much like the ones in monster.com.

First page with the personal details
Second page with educational details
Third page with work experience details

Can some one please give me a thread or a link or a source for me to get started.

Thanks much for the help.

pancgom 0 Light Poster

No worries...thanks for the help anyways...cheers

pancgom 0 Light Poster

Hi,

I am just a basic user, i managed to get the form to insert data to the mysql table.

Though i can understand what the code does i am not able to write my own to what i want the form to do to display information.

If you copy and paste the above code you will find that its not the work of 'me' genius but something of microsoft word standard for you in php.

pancgom 0 Light Poster

I can show you a simple example.

<?php
$name = $_POST['name'];
echo $name;
//query the table with $name and display the data
?>
<html>
<head>
</head>
<body>
<form name="test" method="post" action="selecttest.php">
<select name="name" onchange="javascript: document.test.submit();">
<option value=''>Select one</option>
<option value=1>1</option>
<option value=2>2</option>
</select>
</form>
</body>
</html>

Dont want to sound like a bain..but can you please give me the actual working code....please...i have gotten to the part where i can display the name but not other information corresponding to the name. thanks a lot.

pancgom 0 Light Poster

Have an onchange event for the select box. When the user selects a name, submit the page. $_POST will have the value selected by the user. Then query the table and get the values, print it.

Gentlemen i tried this..what you gave me but i am kind of lost trying it for the whole morning..can you please give me the actual code itself...thanks...

I just want to display all other information when the name is selected...that is information like staff number, contract period etc.

pancgom 0 Light Poster

I have this page which has to retrieve the information from a database and display using the list menu object can someone please let me know of how to do it.

The idea is when the name is selected it will retrieve the information relating to that name from the Database to display in the appropriate boxes. The php is given below.

You can scream if i am asking a stupid question. Sorry.

Someone please help.

<!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>Hr Leave Application Form</title>
	<script language="JavaScript" src="ts_picker.js">
//Script by Denis Gritcyuk: tspicker@yahoo.com
//Submitted to JavaScript Kit (http://javascriptkit.com)
//Visit http://javascriptkit.com for this script
	</script>
</head>

<body>
<?php

$db_host = "localhost";
$db_user = "xxxx";
$db_pwd = "xxxx";
$db_name = "xxxx";
mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name);

?>

<h1>&nbsp;</h1>
<p>  
<?php
if (!isset($_POST['submit'])) {
?>
</p>
<form action="" method="post" name="tstest">  
<h1>Staff Members Particulars</h1>  

<p>Name:<br>
  <label>
  <select name="name" id="name">
    <option>Name 1</option>
    <option>Name 2</option>
  </select>
  </label>
</p>
<p>Staff Number:<br>
	<input name="staffnumber" type="text" id="staffnumber">
</p>
<p>Department:<br>
	<input type="text" name="department" id="department">
</p>
<p>Present Appoinment:  <br>  
	<input type="text" name="presentappointment" id="presentappointment">
</p>
<p>Period of Present Contract<br />
	<input type="Text" name="contract_start" value="">
	<a href="javascript:show_calendar('document.tstest.contract_start', document.tstest.contract_start.value);">
	<img src="cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the contract_start"></a>
	<input type="Text" name="contract_end" value="">
	<a href="javascript:show_calendar('document.tstest.contract_end', document.tstest.contract_end.value);">
	<img src="cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the contract_start"></a><br />
</p>

<p>  <input type="submit" name="submit" value="Submit New Item">    
<input name="reset" type="reset" id="reset2" …
pancgom 0 Light Poster

Check this example to add html elements dynamically.
http://www.dustindiaz.com/add-and-remove-html-elements-dynamically-with-javascript/
When the page is reloaded on submit, you can have the previous value by assigning $_POST as value. For example, <input type="text" name="name" value="<?php echo $_POST['name']; ?>"> will retain the value entered in the textbox on submit.

Hi Again,

I have this html table with elements in it...i am not able to figure out how i can add another table like that by clicking on the add another reference button.

So sorry...i have tried so much but still not able to figure out how.
please help.

Thanks.

<table width="1000" border="0" align="center" cellpadding="3" cellspacing="0" style="border:1px solid #999999;" >
<div id="myDiv"></div>

<input type="hidden" value="0" id="theValue" />

  <tr>
    <th height="30" colspan="2" bgcolor="#ff9933" class="BodyTextHeaders" scope="col"><div align="left">* Referee 2</div></th>
  </tr>
  <tr>
    <th width="362" class="BodyTextHeaders" scope="col"><div align="left"><div class="BodyText">* Name of
    Referee : </div></div></th>
    <th width="624" class="BodyTextHeaders" scope="col"><div align="left"><span class="BodyText">
      <input name="t_ref_email5" type="text" class="BodyText"
		style="color: 000000 ; font-weight: bold; text-transform:mixedcase" value=" " size="50" maxlength="50">






    </span></div></th>
  </tr>
  <tr>
    <th class="BodyTextHeaders" scope="col"><div align="left"><span class="BodyText">* E-Mail Address
    : </span></div></th>
    <th class="BodyTextHeaders" scope="col"><div align="left"><span class="BodyText">
      <input name="t_ref_email6" type="text" class="BodyText"
					style="color: 000000 ; font-weight: bold; text-transform:mixedcase" value="

" size="50" maxlength="50">
    </span></div></th>
  </tr>
  <tr>
	
    <th height="50" colspan="2" class="BodyTextHeaders" scope="col"><a href="javascript:;"> <input type="button" class="BodyText" onclick="addEvent();" value="Add More Referee's"> </a></th>
  </tr>

</table>
pancgom 0 Light Poster

Hello Again,

I have another request, again i just need some direction and i can take it from there.

Have you been to monster.com there they ask you to add experiences...like you key in the first experience then if you have another you have to click a button to add more experience. the page then loads again with the first work experience that you entered with the new one with boxes for you to fill in, any idea how to do it or what it is called.

Thanks a lot for all the help.

pancgom 0 Light Poster

I guess you want to display some (say 10) records at a time and a button, called next to display the next 10 records ? Search for pagination in google. You will find some examples.

Thanks a lot.

pancgom 0 Light Poster

How do you want to split it ?

I dont know since i am new to php..not sure what else it can do..can you suggest for me please of how i can show it.

Currently i have about 25 columns of results displaying.

pancgom 0 Light Poster

Hi,

I am very new to php still trying to find my way around it, i got this code which will pull everything off my database and display in one endless table across the page is there a way i can split it and display.

<!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>
<p>

<table border="1" bordercolor="black" cellpadding="3">
  
<?php

$db_connect="localhost";
$db_username="xxxx";
$db_password="******";
$db_name="xxx****";

$link=mysql_connect($db_connect,$db_username,$db_password);

$db_select=mysql_select_db($db_name);

if ($db_select) {

print "database connected";

}else{

print "not connected";

}

//print "<table>";

$record_set=mysql_query("SELECT * FROM tableToDisplay");




for($c=0; $c<mysql_num_fields($record_set);$c++){
print"<th>".mysql_field_name($record_set,$c)."</th>";
}

while ($record=mysql_fetch_row($record_set)){
print"<tr>";

for($c=0; $c<mysql_num_fields($record_set);$c++){
print "<td>".$record[$c]."</td>";

}
print "</tr>";

}

//print"</table>";

mysql_close($link);

?>
</table>
</body>
</html>
pancgom 0 Light Poster

Hi,

I need some advice on how to edit records from a mysql database using php.

Basically the record will be displayed after a particular field is chosen.

What i need to know is how can i show the field data in a drop down box one after another and display the other data corresponding to it on a page and then edit them.

e.g., i have a form which captures name, address, telephone numbers etc.

Lets say i have the names displayed in a drop down box i want the address and telephones number displayed in the page in editable format.

I have the form and other stuff just need pointer on how to display using a drop down box and edit data.

Thank you very much.

pancgom 0 Light Poster

"The "bgcolor", "height", "width", and "nowrap" attributes of the th element were deprecated in HTML 4.01." --w3schools.com

just replace print "<th>".mysql_field_name($record_set,$c)."</th>";
with

print  "<tr><td bgcolor='red'><font size='2'>".mysql_field_name($record_set,$c)."</font></td></tr>";

ok?

It worked...thanks a lot for the help...

pancgom 0 Light Poster
<?php
echo "<table border=1>";
echo "<th bgcolor=\"red\">test</th>";
echo "</table>";
?>

Hope that helps.

IT WORKED..THANKS A LOT

pancgom 0 Light Poster

Hi Guys,

This is probably the most silliest of questions, i am still learning php and mysql :-| .

I have this code below which brings up data from the database and displays it, what i want to do is to give the table headers a bgcolor how do i insert it, i get a parse error when i try to introduce a bgcolor..

Can anyone help.

<table border="1" bordercolor="black" cellpadding="2" cellspacing="0" width="550">

{php}


$db_username=;
$db_password=;
$db_name=;

mysql_connect($db_connect,$db_username,$db_password);
mysql_select_db($db_name);
$record_set=mysql_query("SELECT * FROM dDdDdD");

for($c=0; $c<mysql_num_fields($record_set);$c++){


print "<th>".mysql_field_name($record_set,$c)."</th>";

}


while($record=mysql_fetch_row($record_set)){
print "<tr>";

for($c=0; $c<mysql_num_fields($record_set);$c++){
print "<td>".$record[$c]."</td>";

}
print "</tr>";
}

{/php}
</table>

pancgom 0 Light Poster

Its easier if you use javascript for this. Check these links.
http://www.javascriptkit.com/script/script2/timestamp.shtml
or
http://www.javascriptkit.com/script/script2/tengcalendar.shtml
Its simple to use. Call the javascript function wherever you want!

Super stuff man... solved a big big headache...

pancgom 0 Light Poster

Hi,

I am looking for some help in adding a calendar to a form that i am building.

Its much like a calendar when you book air tickets.. click on a calendar like icon and a pop up window opens select date year and month the details get into the form field.

Can someone give me pointer on how to do it please.

Thanks much.