Solved

How to create move next action in php forms

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

747 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now