php forms and database navigatio
Posted on
16th Feb 2014 07:03 pm by
admin
Hello,
I'm new to php and i'd like to post the following.
I have written code to get records from a DB and i need one record at a time to be filled in a form i created. Then the next record should be displayed after the user hits the "press any ket button". It does not work
PLEASE HELP !
code is following
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<?php
$labels = array( "user_name" => "User Name", "create_date" => "Creation Date", "password" => "Password",
"last_name" => "Last Name",
"first_name" => "First Name",
"street" => "Street",
"city" => "City",
"state" => "State",
"zip" => "Zip",
"email" => "Email",
"phone" => "Phone",
"fax" => "Fax");
$submit = "Press any key";
include("dbstuff.inc");
$cxn = mysqli_connect($host,$user,$passwd,$databname);
if (!cxn) {
printf("Can't connect to localhost. Errorcode: %dn", mysqli_connect_errno ());
}
else { echo "connection successful !";
}
/* or die ("could not connect to server");*/
$query = "SELECT * FROM customer ";
$result = mysqli_query ($cxn,$query) or die ("could not execute query");
/*$customer = mysqli_fetch_assoc($result);*/
?>
<html>
<head><title>Customer Record</title>
<style type='text/css'>
/*div {background-color:#b0c4de}*/
body {color:blue}
body {background-color:#b0c4de}
<!--
#form {margin: 1.5em 0 0 0;
padding: 15;
}
#field {padding-bottom: 1em;}
label {
font-weight: bold;
float: left;
width: 10%;
margin-right: 1em;
text-align: right;
}
-->
</style>
</head>
<body>
<h3> Customer Details</h3>
<?php
/* Loop that displays the form fields */
/* print_r ($customer);*/
while ($customer = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
echo "<form action = '$_SERVER[PHP_SELF]' method = 'POST'>
<div id='form'>";
foreach($labels as $field => $label)
{
echo "<div id='field'><label for='$field'>$label</label>
<input id='$field' name='$field' type='text'
size='50%' maxlength='65' value = {$customer[$field]} />
</div>n";
} /* foreach*/
echo "<input style='margin-left: 33%' type='submit' value='$submit' />n";
} /*while*/
/*echo "</div>n";*/
/* free result set */
mysqli_free_result($result);
/* close connection */
mysqli_close($cxn);
?>
</form></body></html>
No comments posted yet
Your Answer:
Login to answer
262
7
Other forums
Which PHP-Editor do you think is the best?
Hi everyone,
Myself Brian Anderson. For the last 2 years i have been working a
removing space from the end of a variable
i have a variable $image which contains the following url "http://tiles.xbox.com/tiles/oo/P5/0m
Required to login help
I'm trying to set up my site so users have to be logged into the forum to access the site.I've been
I need help with formatting date from mysql! with php!
Hello guys
*Note: this is a php question not MySQL question, please do not move it to mysql s
RTF fomatting to email content
Im trying to sen an email with content is picked up from a rtf-file (file_get_contents('*.rtf'). Mai
Need help with some php code :)
Hey! I'm quite new to this whole thing, so please don't fire me with shait on this one =D
I'm
Download Image from URL and Upload it
Ok, I have been googling for the last 1/2 hour trying to figure this out, Most likely I'm just not s
Problem in OnClientClick and OnClick sync
Hi,Strange and irritating problem:
I have below button declaration in markup of the aspx page:
rdns with php
I am trying to build a script that will show all of the different domains that are hosted on the sam
Dynamically allocating the number of rows in a table based on a variable value
Hi,
I have situation here which i cannot resolve, I have a variable temp which stores the num