473,805 Members | 1,956 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript : form .submit in while loop

2 New Member
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $dbhost = 'unix.lsbu.ac.uk';
  3. $dbuser = 'lrc3';
  4. $dbpass = 'dietdft_';
  5. $dbname = 'lrc3';
  6.  
  7. // This is an example open a db
  8. $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
  9.  
  10. mysql_select_db($dbname);
  11.  
  12. $today = date("d/m/Y");
  13.  
  14. $day=substr($today, 0, 2);
  15. $month = substr($today, 3, 2);
  16. $year = substr($today, 6, 4);
  17.  
  18. $search_date = mktime(0,0,0, $month, $day, $year);
  19.  
  20. // counting the offset
  21.  
  22. $offset = ($pageNum - 1) * $rowsPerPage;
  23.  
  24. $query = "SELECT * FROM class where module = '$module' and timestamp > '$search_date'";
  25.  
  26. $result = mysql_query($query) or die('Error, query failed');
  27.  
  28. $num=mysql_numrows($result);
  29.  
  30. echo "<P class=style19>$num test dates match your criteria of $module";
  31.  
  32. //echo "<p class=style19>Possible matches reference $module are ".$num."</P>";//
  33.  
  34. while($row=mysql_fetch_array($result)) 
  35. {
  36. if ($row['time']=="0")
  37. {
  38. $output="";
  39. if ($row['time']=="1")
  40. {
  41. $output=" at 1.00pm";
  42. if ($row['time']=="2")
  43. {
  44. $output=" at 2.00pm";
  45. if ($row['time']=="3")
  46. {
  47. $output=" at 3.00pm";
  48. if ($row['time']=="4")
  49. {
  50. $output=" at 4.00pm";
  51. if ($row['time']=="5")
  52. {
  53. $output=" at 5.00pm";
  54. }
  55.  
  56. //convert timestamp to date format for display//
  57. $displaytime=$row[timestamp];
  58. $thedate= date("d-m-y", $displaytime);
  59.  
  60. // get class primary and assign it to varible //
  61. $id = $row[id];
  62. $look_id = $id;
  63.  
  64. // calculate avaliability check //
  65. $avalible = "select * from enrol where class_id='$id'";
  66. $result1 = mysql_query($avalible);
  67. $num_rows = mysql_num_rows($result1);
  68.  
  69. //$query_enrol = "select * from class where module = '$module';//
  70.  
  71. // display response to query on screen //
  72. echo "<p class=style21>";
  73. echo ("<br>Exam scheduled on: ".$thedate);
  74. echo $output;
  75.  
  76. $unit = $row[units];
  77. $avaliblility = $unit - $num_rows;
  78. echo ("<BR>Class size: ".$row[units].", spaces avaliable: ".$avaliblility);
  79.  
  80. echo ("<br><a href=\"javascript:document.form1.submit($row[id])\">Click here to book this test </a><P></p> ");
  81.  
  82. echo ("<input name=\"id\" type=\"hidden\" value=$id >");
  83. echo ("<P>id: ".$id);
  84. echo ("<P>lid: ".$look_id);
  85.  
  86. }
  87.  
  88. mysql_close($conn);
  89.  
  90. ?>
  91.  

3 test dates match your criteria of Module 2 - Using the Computer and Managing Files (XP/2003)


Exam scheduled on: 10-07-07 at 1.00pm
Class size: 22, spaces avaliable: 21
Click here to book this test



id: 37

lid: 37


Exam scheduled on: 11-07-07 at 2.00pm
Class size: 20, spaces avaliable: 20
Click here to book this test



links are passing wrong value



id: 38

lid: 38


Exam scheduled on: 09-07-07 at 4.00pm
Class size: 25, spaces avaliable: 23
Click here to book this test



id: 39

lid: 39

passing wrong varible. Pls help,
Jul 4 '07 #1
2 2749
ronnil
134 Recognized Expert New Member
Hi sakat

welcome to TSDN

what is your exact problem?

would you please use [code] tags to make your code/question more readable.
Jul 4 '07 #2
sakat
2 New Member
Hi There Mate,

The php script displays 3 results in this output and when I click on on of the submit buttons to book a class I get the wrong value posted. This is because the the while loop runs to its conclusion before passing a value to next page. I need to submit class id with a link through out the display when selected - ie. the link selectred passes on that particlar class id???? making any sense????
Jul 4 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2434
by: Barnes | last post by:
Hi, Can anyone please tell me how I can use the replace method to replace a character if it occures in more than one textbox without having to write separate function for each textbox. The code below is the basic way to use the replace method but it only allows for one textbox. I'm sure I need a loop in there but I'm not sure how to use that
4
1700
by: javascript_noob12 | last post by:
Hi. I am trying to create a CGI script that will use Perl to read a text file to get a list of values, then turn that list into a menu on a website. The menu will be a form with a JavaScript "submit" function. . When someone selects a menu-item, the form will submit the value of that list-entry to another CGI page. The problem I'm encountering is that the script I've written submits every value of the form rather than the one specific...
0
3405
by: Juan Jose Costello Levien | last post by:
Hello, My name is Juan. I am new to the forum. Here I leave you a problem to see if you can help me. General Description I am developing an application in Visual Basic 6.
2
1269
by: khng | last post by:
When there is a HTML Form with lots of input elements, how can I know which element is triggering the form submit action with the help of javascript.
10
6110
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio button with this link of code: echo 'SCRIPT language=JavaScript setCheckedValue("'.$_SESSION.'");</SCRIPT>'; //? <snip of code>
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10607
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10359
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10104
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9182
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5541
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4317
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.