ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
<?php
session_start();
if($_SESSION['flag']=='0') /* Previously I have set $_SESSION['flag']as 0 in some file and I am calling this file from that file*/
{
$i='0';
$assno=$_POST['assignno'];
$totques=$_POST["totques"];
session_register("assno");
session_register("totques");
session_register("i");
$_SESSION["i"]=$i;
$_SESSION["assno"]=$assno;
$_SESSION["totques"]=$totques;
$qno=$_POST["qno"];
$link=mysql_connect('localhost')or die("unable to connect");
$db=mysql_select_db("test",$link)or die("Unable to Select");
$ass="assignment".$assno;
$query1="CREATE TABLE assignments(assignno VARCHAR(20) NOT NULL,qno VARCHAR(20) NOT NULL,subqno VARCHAR(20) NOT NULL,qtext VARCHAR(200),startdate date,start time,enddate date,endtime time,timeinterval time,maxsub int(4),nooverwrites int(2),ncurrsub int(3),ntestcases int(2),marks int(3) ,PRIMARY KEY(assignno,qno,subqno));";
mysql_query($query1);
$query2="INSERT INTO assignments(assignno) VALUES('$ass')";
$resource=mysql_query($query2);
$_SESSION['flag']='1';
}
else
{
/* I have to store the values entered by the user into some database */
}
?>
<?php
for(;$_SESSION["i"]<$_SESSION['totques'];$_SESSION["i"]=$_SESSION["i"]+1) /* Can I give like this */
/*Actually I want to generate the pages the $_SESSION["totques"] no;of times */
{
?>
<html>
<body bgcolor=lightgrey>
<br>
<br>
<br>
<form action='configure.php' method='post'>
Section Number <input type='text' name='secno'>
<br>
Question Number <input type='text' name='quesno'>
<br>
Question <br><textarea cols=30 rows=10 wrap="soft"></textarea>
<br>
Marks <input type='text' name='Marks'>
<br>
Start Time <input type='textarea' name='st_time'>
<br>
End Time <input type='textarea' name='end_time'>
<br>
Sample Input <br><textarea name=samin cols=30 rows=10 wrap="soft"></textarea>
<br>
Sample Output <br><textarea name='samout' cols=30 rows=10 wrap="soft"></textarea>
<br>
Number of OverWrites <input type='text' name='overwrites'>
<br>
<center><input type='submit' value='Submit'>
<input type='reset' value='Reset'></center>
</form>
</body>
</html>
<?php
}
?>
You could replace :
<?php for(;$_SESSION["i"]<$_SESSION['totques'];$_SESSION["i"]=$_SESSION["i"]+1) {
?>
<!-- html code -->
<?php } ?>
with :
<?php for($i = $_SESSION["i"]; $i < $_SESSION['totques']; $i++) : ?>
<!-- html code -->
<?php endfor; ?>
That won't fix anything, but it is more readable to me.
Also I don't get what you expect by looping the html part... As the result will be in one page, so why open and close <html> markup in each loop iteration ?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.