473,401 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

how to insert this into database n display

[php]

<form action="do.php" method="post">

<?php
/*
create table users (id int, staffid int, region varchar(20), firstname varchar(20), surname varchar(20));
insert into users values(1,1,'region1','John', 'Doe'),(2,2,'region1','Pete', 'Mackay');
create table stores (name varchar(10));
insert into stores values('Name1'),('Name2'),('Name3'),('Name4'),('Na me5'),('Name6');
*/
$con = mysql_connect("localhost","root","password");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("DB_NAME", $con);

$sql="SELECT firstname, surname FROM users WHERE region='DO' order by firstname ASC";
$result=mysql_query($sql)
or die("Error Occured while Searching Records : " . mysql_error());

echo "<table border='1' align='center'>
<tr>

<th>Firstname</th>
<th>Surname</th>
<th>Saturday</th>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thursday</th>
<th>Friday</th>

</tr>";

while($row = mysql_fetch_assoc($result)) {
echo "<tr>";

echo "<td>" . $row['firstname'] . "</td>";
echo "<td>" . $row['surname'] . "</td>";

$namequery = "SELECT name FROM stores WHERE region_id='REGION1'order by name ASC";
$result1 = mysql_query($namequery)
or die('Error, query failed');

echo '<td><select name="Saturday">';
echo "<option value=''></option>";
while($result_row = mysql_fetch_array($result1)) {
echo '<option value="'.$result_row[0].'" >';
echo ($result_row[0]);
echo '</option>';
}

echo '</select></td>';

$namequery = "SELECT name FROM stores WHERE region_id='REGION1'order by name ASC ";
$result2 = mysql_query($namequery)
or die('Error, query failed');

echo '<td><select name="Monday">';
echo "<option value=''></option>";
while($result_row = mysql_fetch_array($result2)) {
echo '<option value="'.$result_row[0].'" >';
echo ($result_row[0]);
echo '</option>';
}
echo '</select></td>';

$namequery = "SELECT name FROM stores WHERE region_id='REGION1'order by name ASC ";
$result3 = mysql_query($namequery)
or die('Error, query failed');

echo '<td><select name="Tuesday">';
echo "<option value=''></option>";
while($result_row = mysql_fetch_array($result3)) {
echo '<option value="'.$result_row[0].'" >';
echo ($result_row[0]);
echo '</option>';
}
echo '</select></td>';
$namequery = "SELECT name FROM stores WHERE region_id='REGION1'order by name ASC";
$result4 = mysql_query($namequery)
or die('Error, query failed');

echo '<td><select name="Wednesday">';
echo "<option value=''></option>";
while($result_row = mysql_fetch_array($result4)) {
echo '<option value="'.$result_row[0].'" >';
echo ($result_row[0]);
echo '</option>';
}
echo '</select></td>';

$namequery = "SELECT name FROM stores WHERE region_id='REGION1'order by name ASC";
$result5 = mysql_query($namequery)
or die('Error, query failed');

echo '<td><select name="Thursday">';
echo "<option value=''></option>";
while($result_row = mysql_fetch_array($result5)) {
echo '<option value="'.$result_row[0].'" >';
echo ($result_row[0]);
echo '</option>';
}
echo '</select></td>';
$namequery = "SELECT name FROM stores WHERE region_id='REGION1'order by name ASC";
$result6 = mysql_query($namequery)
or die('Error, query failed');

echo '<td><select name="Friday">';
echo "<option value=''></option>";
while($result_row = mysql_fetch_array($result6)) {
echo '<option value="'.$result_row[0].'" >';
echo ($result_row[0]);
echo '</option>';
}
echo '</select></td>';




}
echo "</table>";mysql_close($con);
?>

</div>


<div align="center"><br>
<br>
<br>
<br>
</div>
<div align="center">
<input name="clickback2" type="button" value="Back" onClick="history.go(-1)">
<input name="submit" type='submit' value='Submit' />
</div>

[/php]

hey guys how do i insert the follwoing into the database and they display it to the screen when the submit button is pressed.

im just not sure were to put the INSERT INTO part.

help really required, thanks guys, keep up the good work.
Apr 11 '07 #1
2 1551
[php]

<form action="do.php" method="post">

<?php
/*
create table users (id int, staffid int, region varchar(20), firstname varchar(20), surname varchar(20));
insert into users values(1,1,'region1','John', 'Doe'),(2,2,'region1','Pete', 'Mackay');
create table stores (name varchar(10));
insert into stores values('Name1'),('Name2'),('Name3'),('Name4'),('Na me5'),('Name6');
*/
$con = mysql_connect("localhost","root","password");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("DB_NAME", $con);

$sql="SELECT firstname, surname FROM users WHERE region='DO' order by firstname ASC";
$result=mysql_query($sql)
or die("Error Occured while Searching Records : " . mysql_error());

echo "<table border='1' align='center'>
<tr>

<th>Firstname</th>
<th>Surname</th>
<th>Saturday</th>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thursday</th>
<th>Friday</th>

</tr>";

while($row = mysql_fetch_assoc($result)) {
echo "<tr>";

echo "<td>" . $row['firstname'] . "</td>";
echo "<td>" . $row['surname'] . "</td>";

$namequery = "SELECT name FROM stores WHERE region_id='REGION1'order by name ASC";
$result1 = mysql_query($namequery)
or die('Error, query failed');

echo '<td><select name="Saturday">';
echo "<option value=''></option>";
while($result_row = mysql_fetch_array($result1)) {
echo '<option value="'.$result_row[0].'" >';
echo ($result_row[0]);
echo '</option>';
}

echo '</select></td>';

$namequery = "SELECT name FROM stores WHERE region_id='REGION1'order by name ASC ";
$result2 = mysql_query($namequery)
or die('Error, query failed');

echo '<td><select name="Monday">';
echo "<option value=''></option>";
while($result_row = mysql_fetch_array($result2)) {
echo '<option value="'.$result_row[0].'" >';
echo ($result_row[0]);
echo '</option>';
}
echo '</select></td>';

$namequery = "SELECT name FROM stores WHERE region_id='REGION1'order by name ASC ";
$result3 = mysql_query($namequery)
or die('Error, query failed');

echo '<td><select name="Tuesday">';
echo "<option value=''></option>";
while($result_row = mysql_fetch_array($result3)) {
echo '<option value="'.$result_row[0].'" >';
echo ($result_row[0]);
echo '</option>';
}
echo '</select></td>';
$namequery = "SELECT name FROM stores WHERE region_id='REGION1'order by name ASC";
$result4 = mysql_query($namequery)
or die('Error, query failed');

echo '<td><select name="Wednesday">';
echo "<option value=''></option>";
while($result_row = mysql_fetch_array($result4)) {
echo '<option value="'.$result_row[0].'" >';
echo ($result_row[0]);
echo '</option>';
}
echo '</select></td>';

$namequery = "SELECT name FROM stores WHERE region_id='REGION1'order by name ASC";
$result5 = mysql_query($namequery)
or die('Error, query failed');

echo '<td><select name="Thursday">';
echo "<option value=''></option>";
while($result_row = mysql_fetch_array($result5)) {
echo '<option value="'.$result_row[0].'" >';
echo ($result_row[0]);
echo '</option>';
}
echo '</select></td>';
$namequery = "SELECT name FROM stores WHERE region_id='REGION1'order by name ASC";
$result6 = mysql_query($namequery)
or die('Error, query failed');

echo '<td><select name="Friday">';
echo "<option value=''></option>";
while($result_row = mysql_fetch_array($result6)) {
echo '<option value="'.$result_row[0].'" >';
echo ($result_row[0]);
echo '</option>';
}
echo '</select></td>';




}
echo "</table>";mysql_close($con);
?>

</div>


<div align="center"><br>
<br>
<br>
<br>
</div>
<div align="center">
<input name="clickback2" type="button" value="Back" onClick="history.go(-1)">
<input name="submit" type='submit' value='Submit' />
</div>

[/php]

hey guys how do i insert the follwoing into the database and they display it to the screen when the submit button is pressed.

im just not sure were to put the INSERT INTO part.

help really required, thanks guys, keep up the good work.
please help guys :(:( man in need here.
Apr 12 '07 #2
please help guys :(:( man in need here.
IM STUCK :(, help me please
Apr 12 '07 #3

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

Similar topics

15
by: Jack | last post by:
I have a text file of data in a file (add2db.txt) where the entries are already entered on separate lines in the following form: INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great...
8
by: Sans Spam | last post by:
Greetings! I have a table that contains all of the function permissions within a given application. These functions are different sections of a site and each has its own permissions (READ, WRITE,...
3
by: John Marble | last post by:
I am quite new with Access, so please be indulgent if my question sound a little bit newbish. I have two table in the same database: DOSSIER and MAIN. MAIN is having already formatted data...
10
by: Mike | last post by:
I know this sounds strange but I am at a loss. I am calling a simple funtion that opens a connection to a SQL Server 2000 database and executes an Insert Statement. private void...
20
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just...
5
by: Brad Baker | last post by:
I'm trying to write a simple asp.net page which updates some data in a SQL database. At the top of the page I have the following code: <%@ Page Language="C#" Debug="true" %> <%@ import...
0
by: martin.wong | last post by:
Hi, sorry if this is too rudimentary. I've got an ASP page with CODEPAGE=932 setup as a form. Encoding is SHIFT_JIS In it, the user will put in some details in Japanese and submit Another...
2
by: krajah | last post by:
Need Help Here....... I'm using visual C#: How to insert the value that user have entered combobox and click button.The value will sent into database.This is in form1. In form2,if click button...
1
by: Luqman | last post by:
I have created a Insert Query in Sql Data Source using Oracle Database, with the parameters, and its connected with DetailView Control. When I try to Insert through DetailView Control, Illegal...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.