PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Obadiah
Forum Regular
Posts: 580 Joined: Mon Jul 31, 2006 9:13 am
Location: Ashland, KY
Contact:
Post
by Obadiah » Mon Oct 11, 2010 1:06 pm
im not sure if this was possible without placing the value of the var in a text box and using it to post but thats exactly what im trying to do and its not going!
here is an example of what im trying to do
Code: Select all
$time = time();
$DMonth = date('F');
$DYear = date('Y');
$percent=round($boolpool / $total * 100,0);
$sql = "INSERT INTO $table_name values ('{$realtime}',
'{$DMonth}',
'{$DYear}',
'{$areaReported}')";
thanks in advance
mikosiko
Forum Regular
Posts: 757 Joined: Wed Jan 13, 2010 7:22 pm
Post
by mikosiko » Mon Oct 11, 2010 1:14 pm
Obadiah wrote: im not sure if this was possible without placing the value of the var in a text box and using it to post but thats exactly what im trying to do and its not going!
here is an example of what im trying to do
Code: Select all
$time = time();
$DMonth = date('F');
$DYear = date('Y');
$percent=round($boolpool / $total * 100,0);
$sql = "INSERT INTO $table_name values ('{$realtime}',
'{$DMonth}',
'{$DYear}',
'{$areaReported}')";
thanks in advance
sorry but I don't get it... you mean that your $sql query is not working?... error message?, either way... according to the posted code I don't see where you are defining $table_name, $realtime, $areaReported, $boolpool and $total... so .. please clarify
Obadiah
Forum Regular
Posts: 580 Joined: Mon Jul 31, 2006 9:13 am
Location: Ashland, KY
Contact:
Post
by Obadiah » Mon Oct 11, 2010 1:33 pm
i appologize...it is a rather huge file but I will post it
Code: Select all
<?php
session_start();
$conn = mysql_connect("***************","************","********************") or die(mysql_error());
mysql_select_db("qmdb",$conn) or die(mysql_error());
//$next_program = "added.php";
$table_name = "data";
//define variables for posting
include("txtdefine.inc");
$total = $_POST['total'];
$areaReported = $_POST['area'];
//dates
$date1 = $_POST['date1'];
$date2 = $_POST['date2'];
$date3 = $_POST['date3'];
$date4 = $_POST['date4'];
$date5 = $_POST['date5'];
$date6 = $_POST['date6'];
$date7 = $_POST['date7'];
$date8 = $_POST['date8'];
$date9 = $_POST['date9'];
$date10 = $_POST['date10'];
//medical record numbers
$medrec1 = $_POST['medrec_num1'];
$medrec2 = $_POST['medrec_num2'];
$medrec3 = $_POST['medrec_num3'];
$medrec4 = $_POST['medrec_num4'];
$medrec5 = $_POST['medrec_num5'];
$medrec6 = $_POST['medrec_num6'];
$medrec7 = $_POST['medrec_num7'];
$medrec8 = $_POST['medrec_num8'];
$medrec9 = $_POST['medrec_num9'];
$medrec10 = $_POST['medrec_num10'];
//***************************************
//functions for questions 1-28***********
//variables are setup (question_medrec)**
//***************************************
//functions for question 1
$total1 = $_POST['total'];
$num1_1 = 0;
$bool1_1 = $_POST['mr1_bool1'];
if ($bool1_1 == "yes"){
$num1_1 = $num1_1 + 1;
}
else if ($bool1_1 == "no"){
$num1_1 = $num1_1 + 0;
}
else if ($bool1_1 == "na"){
$num1_1 +=0;
$total1 = $total1 - 1;
}
$num1_2 = 0;
$bool1_2 = $_POST['mr2_bool1'];
if ($bool1_2 == "yes"){
$num1_2 = $num1_2 + 1;
}
else if ($bool1_2 == "no"){
$num1_2 = $num1_2 + 0;
}
else if ($bool1_2 == "na"){
$num1_2 +=0;
$total1 = $total1 - 1;
}
$num1_3 = 0;
$bool1_3 = $_POST['mr3_bool1'];
if ($bool1_3 == "yes"){
$num1_3 = $num1_3 + 1;
}
else if ($bool1_3 == "no"){
$num1_3 = $num1_3 + 0;
}
else if ($bool1_3 == "na"){
$num1_3 +=0;
$total1 = $total1 - 1;
}
$num1_4 = 0;
$bool1_4 = $_POST['mr4_bool1'];
if ($bool1_4 == "yes"){
$num1_4 = $num1_4 + 1;
}
else if ($bool1_4 == "no"){
$num1_4 = $num1_4 + 0;
}
else if ($bool1_4 == "na"){
$num1_4 +=0;
$total1 = $total1 - 1;
}
$num1_5 = 0;
$bool1_5 = $_POST['mr5_bool1'];
if ($bool1_5 == "yes"){
$num1_5 = $num1_5 + 1;
}
else if ($bool1_5 == "no"){
$num1_5 = $num1_5 + 0;
}
else if ($bool1_5 == "na"){
$num1_5 +=0;
$total1 = $total1 - 1;
}
$num1_6 = 0;
$bool1_6 = $_POST['mr6_bool1'];
if ($bool1_6 == "yes"){
$num1_6 = $num1_6 + 1;
}
else if ($bool1_6 == "no"){
$num1_6 = $num1_6 + 0;
}
else if ($bool1_6 == "na"){
$num1_6 +=0;
$total1 = $total1 - 1;
}
$num1_7 = 0;
$bool1_7 = $_POST['mr7_bool1'];
if ($bool1_7 == "yes"){
$num1_7 = $num1_7 + 1;
}
else if ($bool1_7 == "no"){
$num1_7 = $num1_7 + 0;
}
else if ($bool1_7 == "na"){
$num1_7 +=0;
$total1 = $total1 - 1;
}
$num1_8 = 0;
$bool1_8 = $_POST['mr8_bool1'];
if ($bool1_8 == "yes"){
$num1_8 = $num1_8 + 1;
}
else if ($bool1_8 == "no"){
$num1_8 = $num1_8 + 0;
}
else if ($bool1_8 == "na"){
$num1_8 +=0;
$total1 = $total1 - 1;
}
$num1_9 = 0;
$bool1_9 = $_POST['mr9_bool1'];
if ($bool1_9 == "yes"){
$num1_9 = $num1_9 + 1;
}
else if ($bool1_9 == "no"){
$num1_9 = $num1_9 + 0;
}
else if ($bool1_9 == "na"){
$num1_9 +=0;
$total1 = $total1 - 1;
}
$num1_10 = 0;
$bool1_10 = $_POST['mr10_bool1'];
if ($bool1_10 == "yes"){
$num1_10 = $num1_10 + 1;
}
else if ($bool1_10 == "no"){
$num1_10 = $num1_10 + 0;
}
else if ($bool1_10 == "na"){
$num1_10 +=0;
$total1 = $total1 - 1;
}
//$row1 = '<td>1<td>'.$question1.'<td>' . $bool1_1 . '</td><td>' .$bool1_2. '</td><td>' .$bool1_3. '</td><td>' .$bool1_4. '</td><td>' .$bool1_5. '</td><td>' .$bool1_6. '</td><td>' .$bool1_7. '</td><td>' .$bool1_8. '</td><td>' .$bool1_9 . '</td><td>' .$bool1_10. '</td><td>' .$total1.'<td>';
$boolpool1 = $num1_1 + $num1_2 + $num1_3 + $num1_4 + $num1_5 + $num1_6 + $num1_7 + $num1_8 + $num1_9 + $num1_10;
if ($total1==0){
$result1 = "";
}
//*****************************************************************************
//*******************Posting the nessasary stuff to the DB*********************
//*****************************************************************************
$time = time();
$DMonth = date('F');
$DYear = date('Y');
$sql = "INSERT INTO $table_name values ('{$realtime}',
'{$DMonth}',
'{$DYear}',
'{$areaReported}')";
// defining the output
include("output.inc");
if ($total == "1"){
$output = $output1;
}
?>
<html>
<head>
<title></title>
</head>
<body>
<table border="1" bordercolor="blue" width="750px" >
<tr><th align="center" colspan=<?php echo $total + 1; ?>><?php echo $areaReported;?></th>
<th rowspan="4" valign="top">Total</th></tr>
<tr>
<?php echo $output;?>
</tr>
</table>
</body>
</html>
mikosiko
Forum Regular
Posts: 757 Joined: Wed Jan 13, 2010 7:22 pm
Post
by mikosiko » Mon Oct 11, 2010 3:26 pm
same questions than before:
you mean that your $sql query is not working?... error message?
In your code I see this line:
Code: Select all
$sql = "INSERT INTO $table_name values ('{$realtime}',
'{$DMonth}',
'{$DYear}',
'{$areaReported}')";
I don't see where you are defining $realtime in your code
and on top of that you are not doing anything with that $sql variable (query) definition... if you want to insert that data in your table you must code it ... with mysql_query() or similar