Solved

How to create move next action in php forms

Posted on 2011-03-06
2
252 Views
Last Modified: 2012-05-11
I am using the following php codes to pass data from a database to a html form. It works fine but I can't move through the records

The form code is
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<HTML>

<BODY>
<?php
include '../Script/singledataview.php';

echo '<form action="singledataview.php" >';
echo 'ID: <input type="text" value="' . $id . '"><br>';
echo 'Title: <input type="text" value="' . $title . '"><br>';
echo 'Body: <input type="text" value="' . $body . '"><br>';
echo '<INPUT TYPE="button" NAME="Next" VALUE="Next">';
echo '</form>';

?>

</BODY>
</HTML>

Open in new window


singledataview.php
 
<?php
include '../Script/mysqlConnect.php';

$TableName="`notes`";	

include '../Script/tabledata.php';

$num= mysql_numrows($result);

$i=$i++;

echo 'charlie '. $i;
$id= mysql_result($result,$i,"id");
$title=mysql_result($result,$i,"title");
$body=mysql_result($result,$i,"body");

$i=$i++;
include '../Script/mysqlDisconnect.php';
	
?>

Open in new window


tabledata.php
 
<?php

$sql = "select * from " . $TableName;
echo $sql;

$result = mysql_query($sql,$con)

?>

Open in new window

0
Comment
Question by:Sheils
2 Comments
 
LVL 17

Accepted Solution

by:
psimation earned 500 total points
ID: 35045738
I'm not sure I can figure out what it is you are trying to do here?

Are you trying to populate a Form from data already in a mysql table?

To create loops, you have a couple of options:
1. while loops
2. for loops
3. foreach loops

You can look up examples of each on www.php.net 


0
 
LVL 16

Author Comment

by:Sheils
ID: 35047111
psimation,

Yes I am trying to populate the form with data already in a mysql table. I know about the looping technics but I don't think it will work in this instance. My understanding it that looping dumps all the records from the table or query in a datasheet. I want to display one record at a time and use a next button to display the following record.

I have the trial record on http://www.wowislandcharter.com/DBScratch/managementstystem/forms/Page2.php.

I have used loop on the main page and that's fine. What I am after is a solution for Page2 where I want to move through the records one by one.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question