Solved

How to create move next action in php forms

Posted on 2011-03-06
2
255 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using cfstoredproc to return query data 2 30
Javascript 2 26
Responsive Font Size 6 29
output of netstat -r in Powersshell HTML 3 28
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

828 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