943,952 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1671
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
May 3rd, 2009
0

use listbox to insert data?

Expand Post »
i have a Listbox available in my page and that Listbox have these items.




and i have trip named table which have these fields.

id which will autocrement
from
to
coach_type
fare
journey_date
seat

now i want this to be happen if a user come and take any item from Listbox it will inserts that that info to these fields not in the seats cuz seat is on the other page.

for example

if a user selects 1st item which is Sukkur-Karachi-(NonAC) then it will insert this data in the field.

in from it insert sukkur
in to it insers karachi
in couchtype it insert nonac
in fare it insert 550

also for the second it insert according to the item in the list box.


after that i have a field which is journey date that is timestamp now i want a calender to be attach to this if user selects date that insers in the journey_date field. please help me out on this.


i have these fields in the listbox.
http://i41.tinypic.com/epf0ug.jpg

In default situation

http://i39.tinypic.com/2hn6x42.jpg


PHP Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. $a = $_GET['Karachi'];
  4.  
  5. $b = $_GET['Sukkur'];
  6.  
  7. $c = $_GET['ac'];
  8.  
  9. $d = $_GET['nonac'];
  10.  
  11. $e = $_GET['550'];
  12.  
  13.  
  14.  
  15. mysql_connect("localhost", "root", "") or die ('Error'.mysqlerror());
  16.  
  17. mysql_select_db("online_bus_project");
  18.  
  19.  
  20.  
  21. $query="INSERT INTO trip (from,to,coach_type,fare) values ('".$a."','".$b."','".$c."'".$d."'".$e."')";
  22.  
  23.  
  24.  
  25. mysql_query($query) or die ('Error Cannnot Insert Records!');
  26.  
  27.  
  28.  
  29. ?>
  30.  
  31.  
  32. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  33. <html xmlns="http://www.w3.org/1999/xhtml">
  34. <head>
  35. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  36. <title>Untitled Document</title>
  37. <link href="obrs.css" rel="stylesheet" type="text/css" />
  38. <!--[if IE 5]>
  39. <style type="text/css">
  40. /* place css box model fixes for IE 5* in this conditional comment */
  41. .twoColFixRtHdr #sidebar1 { width: 220px; }
  42. </style>
  43. <![endif]--><!--[if IE]>
  44. <style type="text/css">
  45. /* place css fixes for all versions of IE in this conditional comment */
  46. .twoColFixRtHdr #sidebar1 { padding-top: 30px; }
  47. .twoColFixRtHdr #mainContent { zoom: 1; }
  48. /* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
  49. </style>
  50. <![endif]-->
  51. <script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
  52. <style type="text/css">
  53. <!--
  54. .style1 {
  55. color: #FFFF00;
  56. font-weight: bold;
  57. }
  58. .style2 {
  59. color: #FFFF66;
  60. font-weight: bold;
  61. }
  62. .style5 {color: #0066FF; font-weight: bold; }
  63. .style6 {
  64. color: #0066FF;
  65. font-weight: bold;
  66. font-size: 24px;
  67. }
  68. .style7 {font-size: 12px}
  69. #apDiv1 {
  70. position:absolute;
  71. left:35px;
  72. top:168px;
  73. width:621px;
  74. height:362px;
  75. z-index:1;
  76. }
  77. -->
  78. </style>
  79. </head>
  80.  
  81. <body class="twoColFixRtHdr">
  82. <div id="container">
  83. <div id="header">
  84. <!-- end #header -->
  85. <img src="images/header" alt="OBTRS: Header" /></div>
  86. <div id="sidebar1">
  87. <!-- end #sidebar1 -->
  88. <img src="images/sidebar_slideshow" alt="" />
  89. <div id="blogarea">
  90. <p class="style2">Casual Dining Restaurants</p>
  91. <p><br />
  92. Our family-style restaurants are the favorite of thousands of tourists and professional drivers alike. Our clean and friendly surroundings encourage people to stop and enjoy a wholesome meal with us when they travel. Our customers recognize our strong teamwork ethic as we provide them quality service.</p>
  93. <p><br />
  94. <span class="style1">Convenience Stores</span></p>
  95. <p><br />
  96. Our cashiers take pride in having the items on the shelf ready for our travelers when they stop. We know many are in a hurry and we need to be &quot;fast&quot; to meet their busy schedules. Some of our returning customers enjoy fresh coffee and we have it ready for them. The joint effort of our managers and associates creates a strong &quot;team spirit&quot; that provides the customers what they are looking for as they travel.</p>
  97. </div>
  98. </div>
  99. <div id="mainContent">
  100. <div id="nav">
  101. <script type="text/javascript">
  102. AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','760','height','30','src','images/nav_bar2','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','images/nav_bar2' ); //end AC code
  103. </script>
  104. <noscript>
  105. <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="760" height="30">
  106. <param name="movie" value="images/nav_bar2.swf" />
  107. <param name="quality" value="high" />
  108. <embed src="images/nav_bar2.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="760" height="30"></embed>
  109. </object>
  110. </noscript>
  111. </div>
  112.  
  113. <div id="status"><form name="status" method="post" action="bookinginfo.php">
  114. <br>
  115. <br>
  116. <br>
  117. <table class="note" width="90%" align="center" border="0" cellpadding="2" cellspacing="2">
  118. <tbody><tr>
  119. <td colspan="4" class="header" width="100%" align="center"><font size="4" color="royalblue" face="Verdana, Arial, Helvetica, sans-serif"><b class="heading"><span class="header"><font color="#336699">Welcome
  120. To Online B<span class="heading"><span class="heading">us Reservation</span></span></font></span><br>
  121. </b><font size="2" color="#ff0000">Please Select your date of departure and destination to proceed ahead with the booking.</font><font size="2" color="#000000">
  122. </font></font></td>
  123. </tr>
  124. <tr>
  125. <td colspan="4" width="100%">&nbsp;</td>
  126. </tr>
  127.  
  128.  
  129.  
  130. <tr>
  131. <td font="" face="Verdana, Arial, Helvetica, sans-serif" color="maroon" size="2" width="25%" align="right" height="30">Journey :</td>
  132.  
  133. <td font="" face="Verdana, Arial, Helvetica, sans-serif" size="2" width="25%" align="left" height="30">
  134.  
  135.  
  136.  
  137. <select id="journey">
  138.  
  139. <option value = "Sukkur-Karachi-(NonAC)">Sukkur-Karachi-(NonAC)</option>
  140.  
  141. <option value = "Karachi-Sukkur-(NonAC)">Karachi-Sukkur-(NonAC)</option>
  142.  
  143. <option value = "Sukkur-Karachi-(AC)">Sukkur-Karachi-(AC)</option>
  144.  
  145. <option value = "Karachi-Sukkur-(AC)">Karachi-Sukkur-(AC)</option>
  146.  
  147. <option value = "Karachi-Islamabad-(Volvo)">Karachi-Islamabad-(Volvo)</option>
  148. </select>
  149.  
  150.  
  151.  
  152. </select></td><td font="" face="Verdana, Arial, Helvetica, sans-serif" color="maroon" size="2" width="25%" align="left" height="30">
  153. </td></tr><tr>
  154.  
  155. <td valign="top" align="right">Journey Date:</td>
  156.  
  157. </tr>
  158.  
  159.  
  160.  
  161. <!--
  162. <tr>
  163. <td width="100%" colspan=4>&nbsp;</td>
  164. </tr>
  165. -->
  166.  
  167. <tr>
  168. <td colspan="4" width="100%"><hr width="95%" align="left" noshade="noshade"></td>
  169. </tr>
  170.  
  171.  
  172. <tr>
  173. <td colspan="4" width="100%" align="center">
  174. <input type="submit" name="submit" value="submit" >
  175. </td>
  176. </tr>
  177.  
  178. <tr>
  179. <td colspan="4" align="center">&nbsp;</td>
  180. </tr>
  181.  
  182. <!--
  183. <tr>
  184. <td width="100%" align="center" colspan="4">
  185. <div align="left" class="note">
  186. <hr noshade width="95%" align="left">
  187. <font face="Verdana, Arial, Helvetica, sans-serif" size="2"><font color="#000000"><br>
  188. Note :</font></font> <span class="note">Please fill in your departure
  189. and destination stations, number of seats required and the prefered
  190. date of your journey in this page and click on "Check Status" </span></div>
  191. </td>
  192. </tr>
  193. -->
  194.  
  195. </tbody></table>
  196.  
  197. </form></td>
  198. </tr>
  199. </tbody></table></div>
  200. <div id="features"></div>
  201. <!-- end #mainContent -->
  202. </div>
  203. <!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats -->
  204. <br class="clearfloat" />
  205. <div id="footer">
  206. <p><a href="aboutus.html">About us</a> |<a href="feedback.html"> Feedback</a> |<a href="faqs.html"> FAQs</a> | <a href="terms.html">Terms &amp; Conditions</a> | <a href="contactus.html">Contact us</a></p>
  207. <p> 2009 Copyright - Shah Abdul Latif University Khairpur</p>
  208. <!-- end #footer -->
  209. </div>
  210. <!-- end #container -->
  211. </div>
  212.  
  213. </body>
  214. </html>
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
m-hrt is offline Offline
46 posts
since May 2009
May 3rd, 2009
0

Re: use listbox to insert data?

cmon guys i need help????

see line 147 to 148

and the upper php code every thing is ok just tell me how can i put the values for every selection in data base.
Reputation Points: 10
Solved Threads: 0
Light Poster
m-hrt is offline Offline
46 posts
since May 2009
May 3rd, 2009
0

Re: use listbox to insert data?

A couple of questions..
1. Where are you getting those GET names from? Can't see any reference to them in your code..
2. Why are you putting GET data directly into the database.. That's just asking for trouble. Any and all input from a user should be seen cleaned before database entry.
3. What is so important about line 147/148, I see no problems there.
Reputation Points: 96
Solved Threads: 124
Master Poster
Will Gresham is offline Offline
728 posts
since May 2008
May 4th, 2009
0

Re: use listbox to insert data?

see this line
You are using four fields but five parameters and some commas are missing.



$query="INSERT INTO trip (from,to,coach_type,fare) values ('".$a."','".$b."','".$c."'".$d."'".$e."')";

try this now

it should be either c or d (AC or non AC. not both)


$query="INSERT INTO trip (from,to,coach_type,fare) values ('$a','$b','$c','$e')";
Last edited by BzzBee; May 4th, 2009 at 1:16 am.
Reputation Points: 16
Solved Threads: 48
Posting Whiz
BzzBee is offline Offline
327 posts
since Apr 2009
May 4th, 2009
0

Re: use listbox to insert data?

Click to Expand / Collapse  Quote originally posted by BzzBee ...
see this line
You are using four fields but five parameters and some commas are missing.



$query="INSERT INTO trip (from,to,coach_type,fare) values ('".$a."','".$b."','".$c."'".$d."'".$e."')";

try this now

it should be either c or d (AC or non AC. not both)


$query="INSERT INTO trip (from,to,coach_type,fare) values ('$a','$b','$c','$e')";
thanx buddy im goin to check this.


i have a text box and i want a calender to be attach to that i have found a calender dont know how to attach where to put that code can u plz help me out on that two
here is the page which have a calender coding + i want only attach to one text box:-

http://blog.davglass.com/files/yui/cal2/
Reputation Points: 10
Solved Threads: 0
Light Poster
m-hrt is offline Offline
46 posts
since May 2009
May 4th, 2009
0

Re: use listbox to insert data?

Click to Expand / Collapse  Quote originally posted by xan ...
A couple of questions..
1. Where are you getting those GET names from? Can't see any reference to them in your code..
2. Why are you putting GET data directly into the database.. That's just asking for trouble. Any and all input from a user should be seen cleaned before database entry.
3. What is so important about line 147/148, I see no problems there.
is it ok now??????
i have made 3 combobox one is from other is to and the 3rd is Couch now tell me how can i insert the 3 values of 3 comboboxes to database

my database name is online_bus_project
table name is trip

here is the code i have made some changes check it
PHP CODE
php Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3.  
  4. if(isset($_POST['submit']))
  5. {
  6. $a = $_POST['Karachi'];
  7.  
  8. $b = $_POST['Sukkur'];
  9.  
  10. $c = $_POST['ac'];
  11.  
  12. $d = $_POST['nonac'];
  13.  
  14. $e = $_POST['550'];
  15.  
  16.  
  17. mysql_connect("localhost", "root", "password") or die ('Error'.mysqlerror());
  18.  
  19. mysql_select_db("online_bus_project");
  20.  
  21.  
  22. $query="INSERT INTO trip (from,to,coach_type,fare) values ('$a','$b','$c','$e')";
  23.  
  24.  
  25.  
  26. mysql_query($query) or die ('Error Cannnot Insert Records!');
  27.  
  28. }
  29.  
  30. ?>

HTML CODE:
html Syntax (Toggle Plain Text)
  1. <div id="status"><form name="status" method="post" action="bookinginfo.php">
  2. <br>
  3. <br>
  4. <br>
  5. <table class="note" width="90%" align="center" border="0" cellpadding="2" cellspacing="2">
  6. <tbody><tr>
  7. <td colspan="4" class="header" width="100%" align="center"><font size="4" color="royalblue" face="Verdana, Arial, Helvetica, sans-serif"><b class="heading"><span class="header"><font color="#336699">Welcome
  8. To Online B<span class="heading"><span class="heading">us Reservation</span></span></font></span><br>
  9. </b><font size="2" color="#ff0000">Please Select your date of departure and destination to proceed ahead with the booking.</font><font size="2" color="#000000">
  10. </font></font></td>
  11. </tr>
  12. <tr>
  13. <td colspan="4" width="100%">&nbsp;</td>
  14. </tr>
  15.  
  16.  
  17.  
  18. <tr>
  19.  
  20.  
  21. <td font="" face="Verdana, Arial, Helvetica, sans-serif" size="2" width="25%" align="left" height="30">
  22. <center>
  23.  
  24. <br /><center> <strong>From:</strong>
  25.      <select id="from">
  26.  
  27. <option value = "from1">Karachi</option>
  28.  
  29. <option value = "from2">Sukkur</option>
  30.  
  31. </select>
  32. <center><br />
  33. <strong>To:</strong>          
  34. <select id="to"></center>
  35.  
  36. <option value = "to1">Sukkur</option>
  37.  
  38. <option value = "to2">Karachi</option>
  39. </select>
  40.  
  41. <center><br /><strong>Couch:   </strong>
  42. <select id="couch"></center>
  43.  
  44. <option value = "couch1">NonAC</option>
  45.  
  46. <option value = "couch2">AC</option>
  47. </select>
  48.  
  49. </select>
  50.  
  51.  
  52.  
  53. <!--
  54.   <tr>
  55. <td width="100%" colspan=4>&nbsp;</td>
  56. </tr>
  57. -->
  58. <tr>
  59. <td colspan="4" width="100%"><hr width="95%" align="left" noshade="noshade"></td>
  60. </tr>
  61.  
  62.  
  63. <tr>
  64. <td colspan="4" width="100%" align="center">
  65.  
  66.  
  67. <input type="submit" value="Submit" />
  68. </form>
  69. </td>
  70. </tr>
  71.  
  72. <tr>
  73. <td colspan="4" align="center">&nbsp;</td>
  74. </tr>
  75.  
  76. <!--
  77.   <tr>
  78. <td width="100%" align="center" colspan="4">
  79. <div align="left" class="note">
  80. <hr noshade width="95%" align="left">
  81. <font face="Verdana, Arial, Helvetica, sans-serif" size="2"><font color="#000000"><br>
  82. Note :</font></font> <span class="note">Please fill in your departure
  83. and destination stations, number of seats required and the prefered
  84. date of your journey in this page and click on "Check Status" </span></div>
  85. </td>
  86. </tr>
  87. -->
  88.  
  89. </tbody></table>
  90.  
  91. </form></td>
Last edited by Ezzaral; May 4th, 2009 at 3:41 pm. Reason: Added [code] [/code] tags. Please use them to format any code that you post.
Reputation Points: 10
Solved Threads: 0
Light Poster
m-hrt is offline Offline
46 posts
since May 2009
May 4th, 2009
0

Re: use listbox to insert data?

Apart from the fact that your HTML is appalling.. as I said earlier, where are you getting the (in this case) POST from?

You appear to be using the values that the fields have, this is incorrect.
You should be using:
php Syntax (Toggle Plain Text)
  1. $a = $_POST['to'];
  2. $b = $_POST['from'];
  3. $c = $_POST['couch'];
  4. $e = $_POST['550'];
This is not recommended though, the user can modify the data sent to the server through a form, you should look into SQL injection and how to prevent it.
Reputation Points: 96
Solved Threads: 124
Master Poster
Will Gresham is offline Offline
728 posts
since May 2008
May 5th, 2009
0

Re: use listbox to insert data?

hmmm now i got u. i have to insert values of list box in the $_POST let me try this
Reputation Points: 10
Solved Threads: 0
Light Poster
m-hrt is offline Offline
46 posts
since May 2009
May 5th, 2009
0

Re: use listbox to insert data?

still the same error which is from the navigation bar swf file

which is on the line 70 of HTML code

HTML CODE:

PHP Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. <link href="obrs.css" rel="stylesheet" type="text/css" />
  7. <!--[if IE 5]>
  8. <style type="text/css">
  9. /* place css box model fixes for IE 5* in this conditional comment */
  10. .twoColFixRtHdr #sidebar1 { width: 220px; }
  11. </style>
  12. <![endif]--><!--[if IE]>
  13. <style type="text/css">
  14. /* place css fixes for all versions of IE in this conditional comment */
  15. .twoColFixRtHdr #sidebar1 { padding-top: 30px; }
  16. .twoColFixRtHdr #mainContent { zoom: 1; }
  17. /* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
  18. </style>
  19. <![endif]-->
  20. <script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
  21. <style type="text/css">
  22. <!--
  23. .style1 {
  24. color: #FFFF00;
  25. font-weight: bold;
  26. }
  27. .style2 {
  28. color: #FFFF66;
  29. font-weight: bold;
  30. }
  31. #apDiv1 {
  32. position:absolute;
  33. left:35px;
  34. top:168px;
  35. width:621px;
  36. height:362px;
  37. z-index:1;
  38. }
  39. -->
  40. </style>
  41.  
  42.  
  43. </head>
  44.  
  45. <body class="twoColFixRtHdr">
  46. <div id="container">
  47. <div id="header">
  48. <!-- end #header -->
  49. <img src="images/header" alt="OBTRS: Header" /></div>
  50. <div id="sidebar1">
  51. <!-- end #sidebar1 -->
  52. <img src="images/sidebar_slideshow" alt="" />
  53. <div id="blogarea">
  54. <p class="style2">Casual Dining Restaurants</p>
  55. <p><br />
  56. Our family-style restaurants are the favorite of thousands of tourists and professional drivers alike. Our clean and friendly surroundings encourage people to stop and enjoy a wholesome meal with us when they travel. Our customers recognize our strong teamwork ethic as we provide them quality service.</p>
  57. <p><br />
  58. <span class="style1">Convenience Stores</span></p>
  59. <p><br />
  60. Our cashiers take pride in having the items on the shelf ready for our travelers when they stop. We know many are in a hurry and we need to be &quot;fast&quot; to meet their busy schedules. Some of our returning customers enjoy fresh coffee and we have it ready for them. The joint effort of our managers and associates creates a strong &quot;team spirit&quot; that provides the customers what they are looking for as they travel.</p>
  61. </div>
  62. </div>
  63. <div id="mainContent">
  64. <div id="nav">
  65. <script type="text/javascript">
  66. AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','760','height','30','src','images/nav_bar2','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','images/nav_bar2' ); //end AC code
  67. </script>
  68. <noscript>
  69. <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="760" height="30">
  70. <param name="movie" value="images/nav_bar2.swf"/>
  71. <param name="quality" value="high" />
  72. <embed src="images/nav_bar2.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="760" height="30"></embed>
  73. </object>
  74. </noscript>
  75. </div>
  76.  
  77. <div id="status"><form name="status" method="post" action="bookinginfo.php">
  78. <br>
  79. <br>
  80. <br>
  81. <table class="note" width="90%" align="center" border="0" cellpadding="2" cellspacing="2">
  82. <tbody><tr>
  83. <td colspan="4" class="header" width="100%" align="center"><font size="4" color="royalblue" face="Verdana, Arial, Helvetica, sans-serif"><b class="heading"><span class="header"><font color="#336699">Welcome
  84. To Online B<span class="heading"><span class="heading">us Reservation</span></span></font></span><br>
  85. </b><font size="2" color="#ff0000">Please Select your date of departure and destination to proceed ahead with the booking.</font><font size="2" color="#000000">
  86. </font></font></td>
  87. </tr>
  88. <tr>
  89. <td colspan="4" width="100%">&nbsp;</td>
  90. </tr>
  91.  
  92.  
  93.  
  94. <tr>
  95.  
  96.  
  97. <td font="" face="Verdana, Arial, Helvetica, sans-serif" size="2" width="25%" align="left" height="30">
  98. <center>
  99.  
  100. <br /><center> <strong>From:</strong>
  101.      <select id="from">
  102.  
  103. <option value = "from1">Karachi</option>
  104.  
  105. <option value = "from2">Sukkur</option>
  106.  
  107. </select>
  108. <center><br />
  109. <strong>To:</strong>          
  110. <select id="to"></center>
  111.  
  112. <option value = "to1">Sukkur</option>
  113.  
  114. <option value = "to2">Karachi</option>
  115. </select>
  116.  
  117. <center><br /><strong>Couch:   </strong>
  118. <select id="couch"></center>
  119.  
  120. <option value = "couch1">NonAC</option>
  121.  
  122. <option value = "couch2">AC</option>
  123. </select>
  124.  
  125. </select>
  126.  
  127.  
  128.  
  129. <!--
  130. <tr>
  131. <td width="100%" colspan=4>&nbsp;</td>
  132. </tr>
  133. -->
  134. <tr>
  135. <td colspan="4" width="100%"><hr width="95%" align="left" noshade="noshade"></td>
  136. </tr>
  137.  
  138.  
  139. <tr>
  140. <td colspan="4" width="100%" align="center">
  141.  
  142.  
  143. <input type="submit" value="Submit" name="submit">
  144. </form>
  145. </td>
  146. </tr>
  147.  
  148. <tr>
  149. <td colspan="4" align="center">&nbsp;</td>
  150. </tr>
  151.  
  152. <!--
  153. <tr>
  154. <td width="100%" align="center" colspan="4">
  155. <div align="left" class="note">
  156. <hr noshade width="95%" align="left">
  157. <font face="Verdana, Arial, Helvetica, sans-serif" size="2"><font color="#000000"><br>
  158. Note :</font></font> <span class="note">Please fill in your departure
  159. and destination stations, number of seats required and the prefered
  160. date of your journey in this page and click on "Check Status" </span></div>
  161. </td>
  162. </tr>
  163. -->
  164.  
  165. </tbody></table>
  166.  
  167. </form></td>
  168. </tr>
  169. </tbody></table></div>
  170. <div id="features"></div>
  171. <!-- end #mainContent -->
  172. </div>
  173. <!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats -->
  174. <br class="clearfloat" />
  175. <div id="footer">
  176. <p><a href="aboutus.html">About us</a> |<a href="feedback.html"> Feedback</a> |<a href="faqs.html"> FAQs</a> | <a href="terms.html">Terms &amp; Conditions</a> | <a href="contactus.html">Contact us</a></p>
  177. <p> 2009 Copyright - Shah Abdul Latif University Khairpur</p>
  178. <!-- end #footer -->
  179. </div>
  180. <!-- end #container -->
  181. </div>
  182.  
  183. </body>
  184. </html>



PHP CODE

PHP Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3.  
  4. if(isset($_POST['submit']))
  5. {
  6. $a = $_POST['from'];
  7.  
  8. $b = $_POST['to'];
  9.  
  10. $c = $_POST['couch'];
  11.  
  12. $d = $_POST['550'];
  13.  
  14.  
  15.  
  16. mysql_connect("localhost", "root", "password") or die ('Error'.mysqlerror());
  17.  
  18. mysql_select_db("online_bus_project");
  19.  
  20.  
  21. $query="INSERT INTO trip (from,to,coach_type,fare) values ('$a','$b','$c')";
  22.  
  23.  
  24.  
  25. mysql_query($query) or die ('Error Cannnot Insert Records!');
  26.  
  27. }
  28.  
  29. ?>
Reputation Points: 10
Solved Threads: 0
Light Poster
m-hrt is offline Offline
46 posts
since May 2009
May 5th, 2009
0

Re: use listbox to insert data?

it looks fine now
Reputation Points: 16
Solved Threads: 48
Posting Whiz
BzzBee is offline Offline
327 posts
since Apr 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: .htacess file dosent work on main server
Next Thread in PHP Forum Timeline: Update profile





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC