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>

262 Like 7 Dislike
Previous php-forum Next php-forum
Other php-forum

Locking mysql tables with php
Hi

BACKGROUND:
I have multiple instances of the same php script running in a WAMP environ

Is it a good practice to store user info. in sessions?
I am making a user class for my script which stores all the user information in sessions. It takes u

login from external site
Hi my new experience begins, Now what i am trying to do is i make three pages, login.php logout.php

Not loading image
When this function gets loaded it doesn't load the image just trying to figure out why.

Code:

Relative path
I have a absolute path to an image - like so: C:/Program Files/Apache Software Foundation/Apache2.2/

Working with Global Variables
hi, I'm not really sure why the following code is returning a "Call to a member function getBan

I have a parse error in this query help..
Code: $query1="INSERT INTO `rating` (`item_name`, `rating`, `ip_address`, `date_rated`) VALUES

Stuck with preg_replace
Hi,

I'm trying to use preg_replace to remove part of the IP address submitted using a form on

Date help - fetch dates for Mondays between xxx and yyy?
Does anyone know the best way to do this? I have two dates, say:

2010-01-26 and 2010-05-30

upload image name with extension using php
hi frds..

<input id="file1" type="file" name="file[]" &a

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash