Jump to content

T1hom7as

New Members
  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

0 Neutral

About T1hom7as

  • Rank
    Newbie
  1. I am looking for some help as I cannot understand the logic of how I do what I want. This is what I am trying to do: - Use two select boxes, one to select a user name, another to select the date. - After selecting that information, press submit button and then hold that information in two variables.. - After submit button is pressed, use the two variables to execute this task: Code:SELECT * FROM timesheet_submission where user_id='$employee_id' and date between '$date_id' and date_add('$date_id', interval 6 day); - Then use that information and select each piece from the generated table and store in variables. This is the bit I am struggling with: - I want to use the stored variables and then print that information in another .php page. I am not sure how to actually do this? I can pull the data correctly by doing the following, it pulls the data and generates a select box form from the correct table in the database and uses "selected" to select the correct variable so it will automatically select that particular on in the list. PHP Code: <?php include_once('db_const.php'); //SQL to set up Select Box mysql_select_db('timesheet') or die(mysql_error()); $sql =mysql_query("SELECT * FROM am_task") or die (mysql_error()); $sql1 =mysql_query("SELECT * from timesheet_submission;") or die (mysql_error()); $result1 = mysql_fetch_array( $sql1 ); // Get array of All Monday Tasks $test1 =$result1['monday_am_task']; // print the ID echo '<select name="monday combo" id="Moncombo1"> <option value= " ">Please Select</option>'; // Populate Select Box while ($test = mysql_fetch_array( $sql)) { if($test['am_id']==$test1) { echo '<option value="'.$test['am_id'].'" selected>'.$test['am_task'].'</option>'; } else { echo '<option value="'.$test['am_id'].'">'.$test['am_task'].'</option>'; } } echo '<select selected="'.$test1.'"></select>'; echo '</select>'; ?> This is done inside of the my main.php though, I want to execute this when I click the submit button. However I want to make this dynamic, so when the user is selected, and the date is select, get the values from the database and insert as shown above. This is my submit.php PHP Code: <?php //┬žerror_reporting(E_ALL); $date_id = $_POST['datecombo']; // use POST to create variables $employee_id = $_POST['employeecombo1']; // use POST to create variables //print $date_id; // make sure it is grabbing the right date that has been selected from the select box //print $employeecombo1; // make sure it is grabbing the right employee that has been selected from the select box $link = mysql_connect("127.0.0.1", "root", "") or die(mysql_error()); mysql_select_db("timesheet",$link) or die(mysql_error()); // selects all the data $SQL = mysql_query("SELECT * FROM timesheet_submission where user_id='$employee_id' and date between '$date_id' and date_add('$date_id', interval 6 day); "); $result = mysql_fetch_array($SQL); $iam =$result['date'];// this prints '2015-04-10' $iam2 =$result['user_id']; // this prints '1' $iam3 =$result['monday_am_task']; // this prints '5' Hopefully this will all make sense
  2. Sorry guys I managed to fix the issue, I wasn't calling the variables correctly.
  3. Hi, I have my login system working fine with sessions. Now I want to use access levels. So if user 1 with access level 1 logs in, he redirects to profile.php. If user 2 with access level 2 logs in, he redirects to main_stats.php. Here is what I have so far for my login.php, however it is not reading the $user_id nor the $access_id: http://codepad.viper-7.com/Ck0Tsr Wondering if anyone can help?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.