469,631 Members | 1,235 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

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 1348
[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

Post your reply

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

Similar topics

5 posts views Thread by Brad Baker | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.