how to insert this into database n display

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DavidOwens
    New Member
    • Mar 2007
    • 56

    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,'reg ion1','John', 'Doe'),(2,2,'re gion1','Pete', 'Mackay');
    create table stores (name varchar(10));
    insert into stores values('Name1') ,('Name2'),('Na me3'),('Name4') ,('Na me5'),('Name6') ;
    */
    $con = mysql_connect(" localhost","roo t","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_q uery($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_ass oc($result)) {
    echo "<tr>";

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

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

    echo '<td><select name="Saturday" >';
    echo "<option value=''></option>";
    while($result_r ow = mysql_fetch_arr ay($result1)) {
    echo '<option value="'.$resul t_row[0].'" >';
    echo ($result_row[0]);
    echo '</option>';
    }

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

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

    echo '<td><select name="Monday">' ;
    echo "<option value=''></option>";
    while($result_r ow = mysql_fetch_arr ay($result2)) {
    echo '<option value="'.$resul t_row[0].'" >';
    echo ($result_row[0]);
    echo '</option>';
    }
    echo '</select></td>';

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

    echo '<td><select name="Tuesday"> ';
    echo "<option value=''></option>";
    while($result_r ow = mysql_fetch_arr ay($result3)) {
    echo '<option value="'.$resul t_row[0].'" >';
    echo ($result_row[0]);
    echo '</option>';
    }
    echo '</select></td>';
    $namequery = "SELECT name FROM stores WHERE region_id='REGI ON1'order by name ASC";
    $result4 = mysql_query($na mequery)
    or die('Error, query failed');

    echo '<td><select name="Wednesday ">';
    echo "<option value=''></option>";
    while($result_r ow = mysql_fetch_arr ay($result4)) {
    echo '<option value="'.$resul t_row[0].'" >';
    echo ($result_row[0]);
    echo '</option>';
    }
    echo '</select></td>';

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

    echo '<td><select name="Thursday" >';
    echo "<option value=''></option>";
    while($result_r ow = mysql_fetch_arr ay($result5)) {
    echo '<option value="'.$resul t_row[0].'" >';
    echo ($result_row[0]);
    echo '</option>';
    }
    echo '</select></td>';
    $namequery = "SELECT name FROM stores WHERE region_id='REGI ON1'order by name ASC";
    $result6 = mysql_query($na mequery)
    or die('Error, query failed');

    echo '<td><select name="Friday">' ;
    echo "<option value=''></option>";
    while($result_r ow = mysql_fetch_arr ay($result6)) {
    echo '<option value="'.$resul t_row[0].'" >';
    echo ($result_row[0]);
    echo '</option>';
    }
    echo '</select></td>';




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

    </div>


    <div align="center"> <br>
    <br>
    <br>
    <br>
    </div>
    <div align="center">
    <input name="clickback 2" type="button" value="Back" onClick="histor y.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.
  • DavidOwens
    New Member
    • Mar 2007
    • 56

    #2
    Originally posted by DavidOwens
    [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,'reg ion1','John', 'Doe'),(2,2,'re gion1','Pete', 'Mackay');
    create table stores (name varchar(10));
    insert into stores values('Name1') ,('Name2'),('Na me3'),('Name4') ,('Na me5'),('Name6') ;
    */
    $con = mysql_connect(" localhost","roo t","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_q uery($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_ass oc($result)) {
    echo "<tr>";

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

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

    echo '<td><select name="Saturday" >';
    echo "<option value=''></option>";
    while($result_r ow = mysql_fetch_arr ay($result1)) {
    echo '<option value="'.$resul t_row[0].'" >';
    echo ($result_row[0]);
    echo '</option>';
    }

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

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

    echo '<td><select name="Monday">' ;
    echo "<option value=''></option>";
    while($result_r ow = mysql_fetch_arr ay($result2)) {
    echo '<option value="'.$resul t_row[0].'" >';
    echo ($result_row[0]);
    echo '</option>';
    }
    echo '</select></td>';

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

    echo '<td><select name="Tuesday"> ';
    echo "<option value=''></option>";
    while($result_r ow = mysql_fetch_arr ay($result3)) {
    echo '<option value="'.$resul t_row[0].'" >';
    echo ($result_row[0]);
    echo '</option>';
    }
    echo '</select></td>';
    $namequery = "SELECT name FROM stores WHERE region_id='REGI ON1'order by name ASC";
    $result4 = mysql_query($na mequery)
    or die('Error, query failed');

    echo '<td><select name="Wednesday ">';
    echo "<option value=''></option>";
    while($result_r ow = mysql_fetch_arr ay($result4)) {
    echo '<option value="'.$resul t_row[0].'" >';
    echo ($result_row[0]);
    echo '</option>';
    }
    echo '</select></td>';

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

    echo '<td><select name="Thursday" >';
    echo "<option value=''></option>";
    while($result_r ow = mysql_fetch_arr ay($result5)) {
    echo '<option value="'.$resul t_row[0].'" >';
    echo ($result_row[0]);
    echo '</option>';
    }
    echo '</select></td>';
    $namequery = "SELECT name FROM stores WHERE region_id='REGI ON1'order by name ASC";
    $result6 = mysql_query($na mequery)
    or die('Error, query failed');

    echo '<td><select name="Friday">' ;
    echo "<option value=''></option>";
    while($result_r ow = mysql_fetch_arr ay($result6)) {
    echo '<option value="'.$resul t_row[0].'" >';
    echo ($result_row[0]);
    echo '</option>';
    }
    echo '</select></td>';




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

    </div>


    <div align="center"> <br>
    <br>
    <br>
    <br>
    </div>
    <div align="center">
    <input name="clickback 2" type="button" value="Back" onClick="histor y.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.

    Comment

    • DavidOwens
      New Member
      • Mar 2007
      • 56

      #3
      Originally posted by DavidOwens
      please help guys :(:( man in need here.
      IM STUCK :(, help me please

      Comment

      Working...