Hello everyone! I don't know if I am in the right place to post my problem. My apology. Well I have a problem regarding on my computer. Everytime I turn it on, white vertical bars shows and it takes more than 30 minutes to load. Very slow to start up. This is how it look like ---> http://www.flickr.com/photos/xetness/9370853986/ .. What do you think is the problem of this? And also sometimes this error shows --->
http://www.flickr.com/photos/xetness/9368073383/in/photostream/ . I hope you can help me with this. Any help would be greatly appreciated.
aianne 23 Light Poster
Hello everyone! I am a student and still a noob in PHP. Well, I'm trying to figure out what is the best method for a log in page system that provide the ability for an Administrator to log in using the same log in form for normal users but get redirected to a administrator page if the system recognize as Admin and normal users redirected to users page. Any idea? Any help would be greatly appreciated! :) Here is my log in code for users -->
<?php
//Start session
session_start();
//Include database connection details
require_once('voting_connect.php');
//Array to store validation errors
$errmsg_arr = array();
//Validation error flag
$errflag = false;
//Connect to mysql server
include('voting_connect.php');
{
//Select database
$db = mysql_select_db($db);
if(!$db) {
die("Unable to select database");
}
//Function to sanitize values received from the form. Prevents SQL injection
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
//Sanitize the POST values
$s_ID = clean($_POST['s_ID']);
$s_Password = clean($_POST['s_Password']);
//Input Validations
if($s_ID == '') {
$errmsg_arr[] = 'ID number missing';
$errflag = true;
}
if($s_Password == '') {
$errmsg_arr[] = 'Password missing';
$errflag = true;
}
//If there are input validations, redirect back to the login form
if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: login.php");
exit();
}
//Create query
$qry="SELECT * FROM students WHERE s_ID='$s_ID' AND s_Password='$s_Password'";
$result=mysql_query($qry);
//Check whether the query was successful or not
if($result) {
if(mysql_num_rows($result) == 1) {
//Login Successful
session_regenerate_id();
$member = mysql_fetch_assoc($result);
$_SESSION['SESS_MEMBER_ID'] = $member['s_ID'];
$_SESSION['SESS_FIRST_NAME'] = $member['s_FirstName'];
$_SESSION['SESS_LAST_NAME'] = …
aianne 23 Light Poster
Yes sir. in every category I have different radio buttons' name. As you can see on my code above sir, In 'President' the radio button name of it is 'vote1' while on 'Vice President' it is 'vote2'. and so I want all the value of selected radio button will pass to database with just one submit button. Do you have any idea sir? Any help would be greatly appreciated.
aianne 23 Light Poster
Hello everyone! I need your help. So I am currently working on my school project for web based voting system and I'm having a hard time to figure it out how to pass value 1 of multiple selected radio buttons to database. Here's my code so far:
Here is my voting form:
---CUT---
<form action="show-poll.php" method="post">
<?php
include('voting_connect.php');
{
$result = mysql_query("SELECT * FROM candidates WHERE c_position='President'")
or die(mysql_error());
echo "<center><table id='tables' class='sortable'>";
echo "<tr><th scope='col' abbr='' class='nobg'> </th> <th>President:</th></tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td scope='row' class='spec'>" . '<input name="vote1" type="radio" value="'.$row['c_ID'].'">' . "</td>";
echo "<td>";
echo '<a href=# alt=Candidate Profile rel=tooltip content="<div id=imagcon><img src='.$row['c_Location'].' class=tooltip-image/></div><div id=con>Running for:'.$row['c_position'].'</div><div id=con>Gender:'.$row['c_gender'].'</div><div id=con>Year:'.$row['c_Year'].'</div><div id=con>Course:'.$row['c_Course'].'</div><div id=con>Class:'.$row['c_Class'].'</div><div id=con>Partylist:'.$row['c_Partylist'].'</div>">'.$row['c_fname'].' '.$row['c_lname'].'</a>'.'<br>';
echo "</td>";
echo"</tr>";
}
echo"</table></center>";
}
?>
<br></br>
<?php
include('voting_connect.php');
{
$result = mysql_query("SELECT * FROM candidates WHERE c_position='Vice President'")
or die(mysql_error());
echo "<center><table id='tables' class='sortable'>";
echo "<tr><th scope='col' abbr='' class='nobg'> </th> <th>Vice President:</th></tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td scope='row' class='spec'>" . '<input name="vote2" type="radio" value="'.$row['c_ID'].'">' . "</td>";
echo "<td>";
echo '<a href=# alt=Candidate Profile rel=tooltip content="<div id=imagcon><img src='.$row['c_Location'].' class=tooltip-image/></div><div id=con>Running for:'.$row['c_position'].'</div><div id=con>Gender:'.$row['c_gender'].'</div><div id=con>Year:'.$row['c_Year'].'</div><div id=con>Course:'.$row['c_Course'].'</div><div id=con>Class:'.$row['c_Class'].'</div><div id=con>Partylist:'.$row['c_Partylist'].'</div>">'.$row['c_fname'].' '.$row['c_lname'].'</a>'.'<br>';
echo "</td>";
echo"</tr>";
}
echo"</table></center>";
}
?>
<br></br>
<?php
include('voting_connect.php');
{
$result = mysql_query("SELECT * FROM candidates WHERE c_position='Secretary'")
or die(mysql_error());
echo "<center><table id='tables' class='sortable'>";
echo "<tr><th scope='col' abbr='' class='nobg'> </th> <th>Secretary:</th></tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td scope='row' class='spec'>" . '<input name="vote3" type="radio" value="'.$row['c_ID'].'">' . "</td>";
echo "<td>";
echo '<a href=# alt=Candidate Profile rel=tooltip content="<div id=imagcon><img src='.$row['c_Location'].' class=tooltip-image/></div><div id=con>Running for:'.$row['c_position'].'</div><div id=con>Gender:'.$row['c_gender'].'</div><div id=con>Year:'.$row['c_Year'].'</div><div …
aianne 23 Light Poster
Hello everyone! I am a student and I am currently working for online voting system for my school. I am having a hard time how to prevent users/students from multiple votes. Could please give me some example that users can only vote once using their ID number? I have a login system. I know there is a lot of tutorial out there but mostly they used IP address. Any help would be greatly appreciated. This is my code so far:
-----CUT-----
<form action="candidates.php" method="post">
<?php
include('voting_connect.php');
{
$result = mysql_query("SELECT * FROM candidates WHERE c_position='President'")
or die(mysql_error());
echo "<center><table id='tables' class='sortable'>";
echo "<tr><th scope='col' abbr='' class='nobg'> </th> <th>President:</th></tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td scope='row' class='spec'>" . '<input name="selector[]" type="radio" value="'.$row['c_ID'].'">' . "</td>";
echo "<td>";
echo '<a href=# alt=Candidate Profile rel=tooltip content="<div id=imagcon><img src='.$row['c_Location'].' class=tooltip-image/></div><div id=con>Running for:'.$row['c_position'].'</div><div id=con>Gender:'.$row['c_gender'].'</div><div id=con>Year:'.$row['c_Year'].'</div><div id=con>Course:'.$row['c_Course'].'</div><div id=con>Class:'.$row['c_Class'].'</div><div id=con>Partylist:'.$row['c_Partylist'].'</div>">'.$row['c_fname'].' '.$row['c_lname'].'</a>'.'<br>';
echo "</td>";
echo"</tr>";
}
echo"</table></center>";
}
?>
<br></br>
<?php
include('voting_connect.php');
{
$result = mysql_query("SELECT * FROM candidates WHERE c_position='Vice President'")
or die(mysql_error());
echo "<center><table id='tables' class='sortable'>";
echo "<tr><th scope='col' abbr='' class='nobg'> </th> <th>Vice President:</th></tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td scope='row' class='spec'>" . '<input name="selector1[]" type="radio" value="'.$row['c_ID'].'">' . "</td>";
echo "<td>";
echo '<a href=# alt=Candidate Profile rel=tooltip content="<div id=imagcon><img src='.$row['c_Location'].' class=tooltip-image/></div><div id=con>Running for:'.$row['c_position'].'</div><div id=con>Gender:'.$row['c_gender'].'</div><div id=con>Year:'.$row['c_Year'].'</div><div id=con>Course:'.$row['c_Course'].'</div><div id=con>Class:'.$row['c_Class'].'</div><div id=con>Partylist:'.$row['c_Partylist'].'</div>">'.$row['c_fname'].' '.$row['c_lname'].'</a>'.'<br>';
echo "</td>";
echo"</tr>";
}
echo"</table></center>";
}
?>
<br></br>
<?php
include('voting_connect.php');
{
$result = mysql_query("SELECT * FROM candidates WHERE c_position='Secretary'")
or die(mysql_error());
echo "<center><table id='tables' class='sortable'>";
echo "<tr><th scope='col' abbr='' class='nobg'> </th> <th>Secretary:</th></tr>";
while($row = mysql_fetch_array($result))
{ …
aianne 23 Light Poster
Oh I'm so sorry sir about that. I thought I didn't get a reply from my previous thread so that's why I made another thread. I'm so sorry. Anyway sir, about your answer in my previous thread, I don't think I can do it with AJAX. I still don't have any idea about it, maybe next month I'll try to take programming class for AJAX. but for now my class is more on PHP, HTML, CSS, MySQL and Javascript. On the code above sir, I can now display the information of the candidates on mouseover box but not in selected candidate when you hover the link. When I hover the link on the first, second, or third link it displays the same information. So do you have any idea sir how to display the information of the selected candidate onmouseover box? Any alternatives? I am so grateful sir for your reply. and I'm so sorry for my english. :)
aianne 23 Light Poster
Hello everyone! Guys I really need your help. I'm still a noob and a student. So I made a table for electoral officials and also I made a link where user can see the information of the certain candidates in mouseover box. But I'm still trying to figure out how to display the information of the candidates in mouseover box using php. Any help would be greatly appreciated.
Here is my code anyway:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>TITLE</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
<script src="sorttable.js"></script>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
$(function() {
var moveLeft = 20;
var moveDown = 10;
$('a#trigger').hover(function(e) {
$('div#pop-up').show();
//.css('top', e.pageY + moveDown)
//.css('left', e.pageX + moveLeft)
//.appendTo('body');
}, function() {
$('div#pop-up').hide();
});
$('a#trigger').mousemove(function(e) {
$("div#pop-up").css('top', e.pageY + moveDown).css('left', e.pageX + moveLeft);
});
});
</script>
</head>
<body>
<div id="page">
<?php
include('voting_connect.php');
{
$result = mysql_query("SELECT * FROM candidates WHERE c_position='Secretary'")
or die(mysql_error());
echo "<center><table id='tables' class='sortable'>";
echo "<tr><th>Secretary:</th></tr>";
while($row = mysql_fetch_array( $result )) {
echo "<tr>";
$row['c_ID'];
echo '<td>' . $row['c_fname'] . ' ' . $row['c_lname'] .'</td>';
echo '<td><a href="?ID=' . $row['c_ID'] .'" id="trigger">View Profile</a></td>';
echo"</tr>";
}
echo"</table></center>";
}
?>
<div id="pop-up">
<h3>Profile:</h3>
<font color="black" size="3">
<?php
include('voting_connect.php');
{
$result = mysql_query("SELECT * FROM candidates WHERE c_position='Secretary'")
or die(mysql_error());
$row = mysql_fetch_array( $result );
echo 'Name: ' . $row['c_fname']. ' ' .$row['c_lname']. '' ;
}
?>
</font>
</div>
</div>
</div>
<!-- …
aianne 23 Light Poster
Hello everyone! :) Could you please help me? I am still a noob and I'm having a hard time about displaying selected values from mysql database into popup window? This is my code where user can see the table of the electoral officials:
-----CUT-----
<div id="page">
<div id="blanket" style="display:none;"></div>
<div id="popUpDiv" style="display:none;">
<a href="#" name="bio" onclick="popup('popUpDiv')">Close</a>
</div>
<?php
include('voting_connect.php');
{
$result = mysql_query("SELECT * FROM candidates WHERE c_position='Secretary'")
or die(mysql_error());
echo "<center><table id='tables' class='sortable'>";
echo "<tr><th>Secretary:</th></tr>";
while($row = mysql_fetch_array( $result )) {
echo "<tr>";
$row['c_ID'];
echo '<td>' . $row['c_fname'] . ' ' . $row['c_lname'] .'</td>';
echo '<td><a href="cand.php?ID=' . $row['c_ID'] .'" name="bio" onclick="popup("popUpDiv")">View Profile</a></td>';
echo"</tr>";
}
echo"</table></center>";
}
?>
-----CUT-----
What I want to do is when the user clicks on the "View Profile", a pop up window opens with the information of the selected candidate that stored in the content field of the database. Do you have any idea? I hope you can help me with this. Any help would be greatly appreciated.
aianne 23 Light Poster
Hello. :) So I am creating a grading system where users can compute student's grades on selected ID Number. The problem is after clicking the COMPUTE button, an "Error!" message display. So far I can save the grades in database but I can't compute it. I'm sorry I'm new to PHP. Here is my code so far:
<?php
function renderForm($ID, $FirstName, $LastName, $Attendance, $Quiz, $MidtermExam, $FinalExam, $FinalGrade, $Remarks, $error)
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>COMPUTE GRADE</title>
</head>
<body>
<?php
if ($error != '')
{
echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>';
}
?>
<form action="grade1.php" method="POST">
<td> </td>
<br /><td> </td><label>ID Number: </label><input type="text" name="ID" value="<?php echo $ID; ?>" READONLY /><br />
<br /><td> </td><label>First Name: </label><input type="text" name="FirstName" value="<?php echo $FirstName; ?>" READONLY /><br />
<br /><td> </td><label>Last Name: </label><input type="text" name="LastName" value="<?php echo $LastName; ?>" READONLY /><br /><br />
<br /><td> </td><label>Attendance: </label><input type="text" name="Attendance" value="<?php echo $Attendance; ?>"/><br /><br />
<br /><td> </td><label>Quiz: </label><input type="text" name="Quiz" value="<?php echo $Quiz; ?>"/><br /><br />
<br /><td> </td><label>Midterm Exam: </label><input type="text" name="MidtermExam" value="<?php echo $MidtermExam; ?>"/><br /><br />
<br /><td> </td><label>Final Exam: </label><input type="text" name="FinalExam" value="<?php echo $FinalExam; ?>"/><br /><br />
<br /><td> </td><label>Final Grade: </label><input type="text" name="FinalGrade" value="<?php echo $FinalGrade; ?>" READONLY /><br /><br />
<br /><td> </td><label>Remarks: </label><input type="text" name="Remarks" value="<?php echo $Remarks; ?>" READONLY /><br /><br />
<br /><td> </td><input type="submit" value="COMPUTE" name="compute"/><br /><br />
<br /><td> </td><input type="submit" value="SAVE" name="save"/><br /><br />
</form>
</body>
</html>
<?php
}
include('collegeinfo_connect.php');
if (isset($_POST['save']))
{
if (is_numeric($_POST['ID']))
{
$ID = mysql_real_escape_string(htmlspecialchars($_POST['ID']));
$FirstName = mysql_real_escape_string(htmlspecialchars($_POST['FirstName'])); …
aianne 23 Light Poster
Oh yeah! I figured it out! thank you so much guys. :)
aianne 23 Light Poster
Hi everyone! I am sorry I'm new to PHP and MySQL. So, I am creating a form for user to update their details and compute student's grade but the updating part doesn't work. Here is code:
COMPUTE.PHP
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Compute Grade</title>
</head>
<body>
<?php
include('collegeinfo_connect.php');
$result = mysql_query("SELECT * FROM collegeinfo_tbl")
or die(mysql_error());
echo "<table border='1' cellpadding='10'>";
echo "<tr> <th>ID:</th> <th>First Name:</th> <th>Last Name:</th> <th>Gender:</th> <th>Year:</th> <th>Course:</th> </tr>";
while($row = mysql_fetch_array( $result )) {
echo "<tr>";
echo '<td>' . $row['ID'] . '</td>';
echo '<td>' . $row['FirstName'] . '</td>';
echo '<td>' . $row['LastName'] . '</td>';
echo '<td>' . $row['Gender'] . '</td>';
echo '<td>' . $row['Year'] . '</td>';
echo '<td>' . $row['Course'] . '</td>';
echo '<td><a href="grade.php?ID=' . $row['ID'] .'">COMPUTE</a></td>';
echo "</tr>";
}
echo "</table>";
?>
</body>
</html>
GRADE.PHP
<?php
error_reporting(0);
?>
<?php
if (isset($_REQUEST['solve']))
{
$Attendance = $_REQUEST['Attendance'];
$Quiz = $_REQUEST['Quiz'];
$MidtermExam = $_REQUEST['MidtermExam'];
$FinalExam = $_REQUEST['FinalExam'];
$solve1 = ($_REQUEST['Attendance'] * 0.10);
$solve2 = ($_REQUEST['Quiz'] * 0.30);
$solve3 = ($_REQUEST['MidtermExam'] * 0.25);
$solve4 = ($_REQUEST['FinalExam'] * 0.35);
$add = ($solve1 + $solve2 + $solve3 + $solve4);
$FinalGrade = round($add);
if ($add >= 75)
{
$Remarks = "PASSED";
}
else {
$Remarks = "FAILED";
}
}
if (isset($_REQUEST['save']))
{
$ID = $_REQUEST['ID'];
$Attendance = $_REQUEST['Attendance'];
$Quiz = $_REQUEST['Quiz'];
$MidterExam = $_REQUEST['MidtermExam'];
$FinalExam = $_REQUEST['FinalExam'];
$FinalGrade = $_REQUEST['FinalGrade'];
$Remarks = strtoupper($_REQUEST['Remarks']);
include('collegeinfo_connect.php');
$allowedFields = array(
'Attendance',
'Quiz',
'MidtermExam',
'FinalExam',
'FinalGrade',
'Remarks'
);
$requiredFields = array(
'Attendance',
'Quiz',
'MidtermExam',
'FinalExam'
);
$errors = …
aianne 23 Light Poster
place all the php before the DTD.
"UPDATE collegeinfo_tbl SET FirstName='$FN', LastName='$LN', Gender='$Gender', Year=$Year, Course='$Course' WHERE ID=$ID"
Also copy the sql to phpmyadmin, insert for hard-coded values and run it in the query window to see if it works. Check the table/fieldnames.
I would go further and validate input data for type rather than just simply/blindly sanitizing.
E.g.
if(is_int($_POST['Year']) && $_POST['Year'] > 1800 && $_POST['Year'] < (date('Y')+1)){ $year = $_POST['Year']; }else{ $error['year'] = 1; }
Oh! Yeah. Thanks! :)
aianne 23 Light Poster
Hi everyone! So, I'm trying to create a program which users can add, update, delete, view, and search records but I am having a hard time about updating records in my database. In my Update form, I've got 1 dropdown menu or option that contains ID number and when I click the Search button, a form contains students info from selected ID number will display in the same form which where users can update it, but after clicking the Update button, no results posted and when I looked in my database nothing gets updated. I hope it made sense. Any help would be appreciated. Here's my code so far:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Update Record</title>
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="5">
<form name="update" method="POST" action="edit.php">
<br /><td> </td><label>ID Number: </label>
<?php
include 'collegeinfo_connect.php';
mysql_connect("$server", "$user", "$pass")or die("cannot connect");
mysql_select_db("$db")or die("cannot select DB");
$sql = mysql_query("SELECT ID FROM collegeinfo_tbl ORDER BY ID");
$row = mysql_fetch_array($sql);
?>
<select name="ID">
<?php do{ ?>
<option value="<?php echo $row['ID']; ?>"><?php echo $row['ID']; ?> </option>
<?php } while($row = mysql_fetch_array($sql));?>
</select>
</td>
</tr>
<tr>
<td> </td>
<td><input name="submit" type="submit" value="Search"></td>
</tr>
</table>
<?php
include('collegeinfo_connect.php');
mysql_connect("$server", "$user", "$pass")or die("cannot connect");
mysql_select_db("$db")or die("cannot select DB");
if(isset($_POST['submit']))
{
if (is_numeric($_POST['ID']))
{
$ID = $_POST['ID'];
$result = mysql_query("SELECT * FROM collegeinfo_tbl WHERE ID='$ID'")
or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
?>
</form>
<form name="edit" method="POST" action="edit.php">
<br /><label>ID Number: </label><input type="text" name="ID" value="<?php echo $row['ID']; ?>"/><br />
<br /><label>First Name: </label><input type="text" name="FN" …
aianne 23 Light Poster
Are you sure that a correct ID is selected when submitting the form? And what do you see after clicking, an error message, or "Record Updated!", or "Failed to Update Record!"?
If the form disappears completely after clicking, there is a syntax error somewhere in your code (before the updating part), so check that too.
I don't see anything sir. there's no "record updated" or "failed to update record" after clicking submit. and I can't find the error sir in my form.
aianne 23 Light Poster
I don't see anything sir. there's no "record updated" or "failed to update record" after clicking submit. and I can't find the error sir in my form.
aianne 23 Light Poster
What do you see as output?
There's an option contains student's ID number *here is the printscreen-->http://www.flickr.com/photos/xetness/6976143911/ and when I click the Search button a form contains student's info from selected ID number will appear like this--> http://www.flickr.com/photos/xetness/6830026468/ where I can update using input type as text, then after will click the Update button there's no result posted. The form which contains student's info where I can update suddenly disappear and only option and search button's stays like the first photo/link and when I looked at my database nothing gets updated. I hope it made sense. Thank you so much for your reply sir. :)
aianne 23 Light Poster
Your query is executed twice. Change lines 104-116:
$query = "UPDATE studentinfo_tbl SET ID='$ID', FirstName='$FN', LastName='$LN', Year='$Year', Course='$Course' WHERE ID='$ID'"; $result = mysql_query($query) or die(mysql_error()); if ($result) { echo "<br>Record Updated!"; } else { echo "Failed to Update Record!"; }
Still the same sir. I tried your code and when click the update button nothing gets updated when i looked at my database. It doesn't work. I'm so sorry sir I'm new to php.
aianne 23 Light Poster
It because there is no SubItems(3) in your listview..
And why you show Owner ID twice in all of your codes?
modified as following "Set lst1 = lvStudentInfo.ListItems.Add With lst1 .Text = rs!Owner_ID .SubItems(1) = rs!Owner_Name .SubItems(2) = rs!Owner_Address End With
Oh! Thank you sir! It works. :)
aianne 23 Light Poster
Single quotes around your column names is wrong, replace them with backticks. Also remove the brackets, as that is used in MSSQL, not MySQL.
Yeah! I tried it but it didn't work. Any idea? Here's my updated code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Update Record</title>
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="5">
<form name="update" method="POST" action="edit.php">
<tr>
<td> </td>
<td><strong>ID Number:</strong></td>
</tr>
<tr>
<td> </td>
<td >
<?php
include 'studentinfo_connect.php';
mysql_connect("$server", "$user", "$pass")or die("cannot connect");
mysql_select_db("$db")or die("cannot select DB");
$sql = mysql_query("SELECT ID FROM studentinfo_tbl ORDER BY ID");
$row = mysql_fetch_array($sql);
?>
<select name="ID">
<?php do{ ?>
<option value="<?php echo $row['ID']; ?>"><?php echo $row['ID']; ?> </option>
<?php } while($row = mysql_fetch_array($sql));?>
</select>
</td>
</tr>
<tr>
<td> </td>
<td><input name="submit" type="submit" value="Search"></td>
</tr>
</table>
<?php
include('studentinfo_connect.php');
mysql_connect("$server", "$user", "$pass")or die("cannot connect");
mysql_select_db("$db")or die("cannot select DB");
if(isset($_POST['submit']))
{
if (is_numeric($_POST['ID']))
{
$ID = $_POST['ID'];
$result = mysql_query("SELECT * FROM studentinfo_tbl WHERE ID=$ID")
or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
?>
</form>
<form name="edit" method="POST" action="edit.php">
<br /><label>ID Number: </label><input type="text" name="ID" value="<?php echo $row['ID']; ?>"/><br />
<br /><label>First Name: </label><input type="text" name="FN" value="<?php echo $row['FirstName']; ?>"/><br />
<br /><label>Last Name: </label><input type="text" name="LN" value="<?php echo $row['LastName']; ?>"/><br /><br />
<label>Year: </label>
<select name="Year" value="<?php echo $row['Year']; ?>"><br />
<br /><option value="1">First Year</option><br />
<br /><option value="2">Second Year</option><br />
<br /><option value="3">Third Year</option><br />
<br /><option value="4">Fourth Year</option><br />
</select><br />
<br /><label>Course: </label>
<select name="Course" value="<?php echo $row['Course']; ?>"><br />
<br /><option value="IT">BS Information Technology</option><br />
<br /><option …
aianne 23 Light Poster
It because there is no SubItems(3) in your listview..
And why you show Owner ID twice in all of your codes?
modified as following "Set lst1 = lvStudentInfo.ListItems.Add With lst1 .Text = rs!Owner_ID .SubItems(1) = rs!Owner_Name .SubItems(2) = rs!Owner_Address End With
Oh! Thank you sir! It works. :)
aianne 23 Light Poster
Hello everyone! :) I'm sorry I'm new to this stuff. So I'm trying to create a simple system information and I am attempting to populate a listview control and I get a Run-time error '380': Invalid property value. I hope you can help me and I hope it made sense.
Here's the line to regenerates the error:
.SubItems(3) = rs!Owner_Address
Here's my entire code:
Option Explicit
Dim lst As ListItem
Dim lst1 As ListItem
Dim OwnerID As Long
Dim warning As String
Dim countertitle As Integer
Dim title As String
Dim titledance As String
Public Sub FillListView()
Set lst = lvStudentRecord.ListItems.Add(, , txtID.Text)
With lst
.SubItems(1) = txtID.Text
.SubItems(2) = txtname.Text
.SubItems(3) = txtadd.Text
End With
End Sub
Private Sub cmdaddstudent_Click()
If txtname.Text = "" Or txtID.Text = "" Or txtadd.Text = "" Then
MsgBox "Please fill all the fields..", vbExclamation, ""
Exit Sub
Else
Connection
sql = "tbl_Owner"
Set rs = New ADODB.Recordset
rs.Open sql, Conn, adOpenDynamic, adLockOptimistic
With rs
.AddNew
!Owner_ID = txtID.Text
!Owner_Name = txtname.Text
!Owner_Address = txtadd.Text
.Update
End With
End If
MsgBox "New student record successfully saved..", vbInformation, "Success"
Call FillListView
txtname.Text = ""
txtID.Text = ""
txtadd.Text = ""
Set rs = New ADODB.Recordset
sql = "SELECT Owner_ID FROM tbl_Owner"
rs.Open sql, Conn, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
With rs
.MoveLast
txtID.Text = !Owner_ID + Val(1)
.Close
End With
End If
lvStudentInfo.ListItems.Clear
Call GetStudentRecord
End Sub
Private Sub cmdcancel_Click()
Unload Me
End Sub
Private Sub cmdclose_Click()
Unload Me
End Sub …
aianne 23 Light Poster
So I'm trying to create a PHP and MySQL program where users can add, update, delete, view and search records. But the problem is I can't update records whenever I click update button. Here's my code -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Update Record</title>
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="5">
<form name="update category" method="POST" action="edit.php">
<tr>
<td> </td>
<td><strong>ID Number:</strong></td>
</tr>
<tr>
<td> </td>
<td >
<?php
include 'studentinfo_connect.php';
mysql_connect("$server", "$user", "$pass")or die("cannot connect");
mysql_select_db("$db")or die("cannot select DB");
$sql = mysql_query("SELECT ID FROM studentinfo_tbl ORDER BY ID");
$row = mysql_fetch_array($sql);
?>
<select name="ID">
<?php do{ ?>
<option value="<?php echo $row['ID']; ?>"><?php echo $row['ID']; ?> </option>
<?php } while($row = mysql_fetch_array($sql));?>
</select>
</td>
</tr>
<tr>
<td> </td>
<td><input name="submit" type="submit" value="Search"></td>
</tr>
</table>
<?php
include('studentinfo_connect.php');
mysql_connect("$server", "$user", "$pass")or die("cannot connect");
mysql_select_db("$db")or die("cannot select DB");
if(isset($_POST['submit']))
{
if (is_numeric($_POST['ID']))
{
$ID = $_POST['ID'];
$result = mysql_query("SELECT * FROM studentinfo_tbl WHERE ID=$ID")
or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
?>
</form>
<form name="update category" method="POST" action="edit.php">
<br /><label>ID Number: </label><input type="text" name="ID" value="<?php echo $row['ID']; ?>"/><br />
<br /><label>First Name: </label><input type="text" name="FN" value="<?php echo $row['FirstName']; ?>"/><br />
<br /><label>Last Name: </label><input type="text" name="LN" value="<?php echo $row['LastName']; ?>"/><br /><br />
<label>Year: </label>
<select name="Year" value="<?php echo $row['Year']; ?>"><br />
<br /><option value="1">First Year</option><br />
<br /><option value="2">Second Year</option><br />
<br /><option value="3">Third Year</option><br />
<br /><option value="4">Fourth Year</option><br />
</select><br />
<br /><label>Course: </label>
<select name="Course" value="<?php echo $row['Course']; ?>"><br />
<br /><option value="IT">BS Information Technology</option><br />
<br …
aianne 23 Light Poster
Oh. It works! Thank you so much guys! especially Sir GliderPilot, thank you. really. :))
aianne 23 Light Poster
Sorry I'm new to these stuff but I am having a hard time about this. So I'll trying to create a php and mysql program which can view records from database server. In my form I have 2 dropdown list and 2 submit button, the first one the the list of "section" and submit button, and the second one is a list of "year level" and submit button again. If I select the section "A" and click submit button, it will display only the student's information that belongs only on section "A" and same as on "year level". I can't figure it out whenever i click the submit button, i can't view the records. I hope it made sense. Please do you have any idea to make it work? here is what I have so far--->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>View</title>
</head>
<body>
<form action="view.php" method="POST">
<td> </td><label>By Section: </label>
<td> </td><select name="Section" value="<?php echo $Section; ?>">
<option value="a">A</option>
<option value="b">B</option>
<option value="c">C</option>
<option value="d">D</option>
</select>
<td> </td><input type="submit" value="GO" name="sec"/>
<td> </td><label>By Year: </label>
<select name="Year" value="<?php echo $Year; ?>">
<option value="1">First Year</option>
<option value="2">Second Year</option>
<option value="3">Third Year</option>
<option value="4">Fourth Year</option>
</select>
<td> </td><input type="submit" value="GO" name="year"/>
<?php
include('quiz1_connect.php');
mysql_connect("$server", "$user", "$pass")or die("cannot connect");
mysql_select_db("$db")or die("cannot select DB");
if (isset($_POST['sec']))
{
if (is_numeric($_POST['Section']))
{
$Section = $_POST['Section'];
$result = mysql_query("SELECT * FROM tblquiz1 WHERE SecName='$Section'")
or die(mysql_error());
echo "<table border='1' cellpadding='10'>";
echo "<tr> <th>ID:</th> <th>First Name:</th> <th>Last Name:</th> <th>Year:</th> <th>Section:</th> </tr>"; …
aianne 23 Light Poster
Using the Free Borland 5.5 command line compiler?
Which version?
Using Borland C++ Builder?
-------------------------------------------
I'm using the very very old one,
Turbo C++ Version 3.0. Borland Int.
I know this turbo is very old but it requires this in our school.. ;'(
so, guys can you help me now and stop arguing about what version I'm using,? I just need an example for my program.. I really need it.. :'( Please?
aianne 23 Light Poster
You want to do this in Windows, in Dos, Linux?
------------------
Windows.. I'm using borland turbo C++.. do u have any idea about this problem.? i'm so desperately need some example of it.. :'(
aianne 23 Light Poster
Hi! I need help to my Turbo C program.. I need to create a program that will ask the "Starting X:", "Starting Y:", Ending X:", and Ending Y:" on different shapes.. this is how the program should be:
SQUARE:
starting X:
starting Y:
ending X:
ending Y:
CIRCLE:
Starting X:
Ending Y:
Radius:
LINE:
Starting X:
Ending Y:
and also
POLYGON:
...the user will write numbers in starting X, starting Y, ending X, ending Y, and radius, after encoding the numbers, the result will create the shape that the user chose and according to their X and Y and radius of the program.
* I dont really have any idea how to start with it. I'm just a beginner and need some hand to help me. I understand if you don't want to give away code because I'm not show my effort as a starting point. You can give me some link about this program, if you'd like to. (^_^) thanks..
aianne 23 Light Poster
Hello,
I'm almost completely useless at C, and as part of a project I've got to conjure up a programme, and I'm just hoping someone can give me push to get it started.
I want to make a programme where the user can draw a CIRCLE, SQUARE, LINE and POLYGON (and eventually any polygon) by setting the size or the starting X & Y and ending X & Y and radius.
My professor gave us a clue, we have to use printf and scanf
This what our professor gave to us, : clue:
......
printf("SQUARE");
printf("starting X: ");
scanf( );
...
printf("starting Y: ");
scanf( );
...
printf("ending X: ");
scanf( );
...
printf("ending Y: ");
scanf( );
...
printf("CIRCLE");
printf("starting X: ");
scanf( );
....
printf("ending Y: ");
scanf( );
...
printf("radius: ");
scanf( );
....
printf("LINE");
printf("starting X: ");
scanf( );
....
printf("starting Y: ");
scanf( );
....
printf("POLYGON");
printf(" ");
scanf( );
*rest of the code here*
I don't have really have any idea about this programme, even my classmates can't do it.
So we have to research but we can't find it in our library neither on google.
I'm just asking for a bit of help to get started. :'(
I hope you guys can help me, :'(
and I understand if you don't give away code because I'm not showing my effort. Just a bit of help. :'( Really need it to pass tomorrow. :'(:'(:(:(:'(
jephthah commented: you used 6 cry-faces and 2 sad-faces in your first post. that's just fail. -1
aianne 23 Light Poster
Using the Free Borland 5.5 command line compiler?
Which version?
Using Borland C++ Builder?
-------------------------------------------
I'm using the very very old one,
Turbo C++ Version 3.0. Borland Int.
I know this turbo is very old but it requires this in our school.. ;'(
so, guys can you help me now and stop arguing about what version I'm using,? I just need an example for my program.. I really need it.. :'( Please?
aianne 23 Light Poster
I looked at your program, and it's almost in working condition. I don't know what the norm is out there, but I find it better to avoid mixing some of the older c-style code with c++. For instance, change line 1 to #include<iostream>. Remove the other two. Then change all your getch(); statements to cin.get();. Next, remove all of the clrscr(); statements. Inside everyone of your string literals you need to inlcude \n at the end of the sentence or << endl; just after the cout string literal. For example on line 12:
Instead of:
cout<<"Your Name: ";
Use this:
cout<<"Your Name: \n";
or this:
cout<<"Your Name: " << endl;
both of those will create a new line, so your statements don't just continue displaying right after one another.
If you don't like the fact that a new line is created before the user types in their answer. Then you can make some other aesthetic adjustments with "\n" or endl.
---------------------------------------------------------------------
Hi,
Thanks for that but I'm using gotoxy, I just removed it here because its too long for this thread.. Thanks anyway.. (^_^).. can you help me to figure out about how to eliminate used lifelines?
aianne 23 Light Poster
You want to do this in Windows, in Dos, Linux?
------------------
Windows.. I'm using borland turbo C++.. do u have any idea about this problem.? i'm so desperately need some example of it.. :'(
aianne 23 Light Poster
Hi! I need help to my c++ program. I created a program that is much like the "Who wants to be a Millionaire" television show. It has questions and the right answers and three lifelines. How can I possibly do eliminate a lifeline after being used.?
this is the program I created so far:
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
char name[50];
char ans;
char ask;
int life;
int main()
{
clrscr();
cout<<"Your Name: ";
cin>>name;
getch();
clrscr();
cout<<"Who Wants to be a MILLIONAIRE?";
cout<<"LIFELINE";
cout<<"1. 50:50";
cout<<"2. Call a friend";
cout<<"3. Ask the audience";
cout<<"QUESTION 1:";
cout<<"Who discovered Computer?";
cout<<"a. Charles Darwin";
cout<<"b. Charles Babbage";
cout<<"c. Isaac Newton";
cout<<"d. Abraham Lincoln";
getch();
cout<<"Do you want to use your lifeline?";
cout<<"[ Y/N : ] ";
cin>>ask;
if(ask=='y')
{
cout<<"Choose Lifeline Number: ";
cin>>life;
if(life==1)
{
cout<<"[ 50:50 ]";
cout<<"_________";
cout<<"c. Isaac Newton";
cout<<"b. Charles Babbage";
cout<<"_________";
getch();
}
else if(life==2)
{
cout<<"[ Call a friend ]";
cout<<"Friend: I think it is B";
getch();
cout<<"You: How sure are you?";
getch();
cout<<"Friend: I'm 95% sure about this.";
getch();
}
else if(life==3)
{
cout<<"[ Ask the audience ]";
cout<<"(a.) 23% (b.) 52% (c.) 13% (d.) 12%";
getch();
}
}
else if(ask=='n')
getch();
cout<<"Your answer is: ";
cin>>ans;
if(ans=='b')
{
cout<<"You're Right!";
getch();
cout<<"You just won $20,000!!!";
getch();
cout<<"Get ready for the next round!";
}
else
{
cout<<"Wrong!";
cout<<"Try again";
getch();
exit(0);
}
getch();
clrscr();
cout<<"Who Wants to be a MILLIONAIRE?";
cout<<"LIFELINE";
cout<<"1. 50:50";
cout<<"2. Call a friend";
cout<<"3. Ask the audience";
cout<<"QUESTION 2:";
cout<<"Folder …
aianne 23 Light Poster
Hi! I need help to my Turbo C program.. I need to create a program that will ask the "Starting X:", "Starting Y:", Ending X:", and Ending Y:" on different shapes.. this is how the program should be:
SQUARE:
starting X:
starting Y:
ending X:
ending Y:
CIRCLE:
Starting X:
Ending Y:
Radius:
LINE:
Starting X:
Ending Y:
and also
POLYGON:
...the user will write numbers in starting X, starting Y, ending X, ending Y, and radius, after encoding the numbers, the result will create the shape that the user chose and according to their X and Y and radius of the program.
* I dont really have any idea how to start with it. I'm just a beginner and need some hand to help me. I understand if you don't want to give away code because I'm not show my effort as a starting point. You can give me some link about this program, if you'd like to. (^_^) thanks..
aianne 23 Light Poster
before trying to implement eliminating lifelines I think you code is in desperate need to refactoring to put common code in functions that can be called.
For example:
A function that asks the question
Parameters:
The question
The 4 answers
The right answer
Returns a flag indicating if the question was answered correctlyA function that asks for a lifelline number
No parameters
Returns the number of a valid and available lifeline
------------------------------------------------------------------------------
Thanks for the reply! I really don't have any idea what "Parameters" you are talking about, I'm only just a beginner and what my teacher teach is only the basic. We haven't reach that too far. (^_^) I'll try to google it on my own. Thanks! and I'll be glad if you could still help figuring these things out for me. lol. Thanks again.
aianne 23 Light Poster
Hi! I need help to my c++ program. I created a program that is much like the "Who wants to be a Millionaire" television show. It has questions and the right answers and three lifelines. How can I possibly do eliminate a lifeline after being used.?
this is the program I created so far:
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
void box(int x, int xx, int y, int yy);
void box(int x, int xx, int y, int yy)
{
int xs,ys,i,j;
xs=xx-x;
ys=yy-y;
for(i=1; i<xs; i++){gotoxy(x+i,y);cout<<"Í";
gotoxy(x+i,yy);cout<<"Í"; }
for(j=1; j<ys; j++){gotoxy(x,y+j);cout<<"º"; }
for(j=1; j<ys; j++){gotoxy(xx,y+j);cout<<"º"; }
{gotoxy(x,y);cout<<"É";
gotoxy(x,yy);cout<<"È";
gotoxy(xx,y);cout<<"»";
gotoxy(xx,yy);cout<<"¼";}
}
char name[50];
char ans;
char ask;
int life;
int main()
{
clrscr();
box(20,50,9,15);
gotoxy(22,12);cout<<"Your Name: ";
cin>>name;
getch();
clrscr();
box(5,50,9,50);
box(10,65,1,5);
gotoxy(23,3);cout<<"Who Wants to be a MILLIONAIRE?";
box(55,78,8,30);
gotoxy(62,12);cout<<"LIFELINE";
gotoxy(57,15);cout<<"1. 50:50";
gotoxy(57,18);cout<<"2. Call a friend";
gotoxy(57,21);cout<<"3. Ask the audience";
gotoxy(6,10);cout<<"QUESTION 1:";
gotoxy(12,13);cout<<"Who discovered Computer?";
gotoxy(8,15);cout<<"a. Charles Darwin";
gotoxy(29,15);cout<<"b. Charles Babbage";
gotoxy(8,17);cout<<"c. Isaac Newton";
gotoxy(29,17);cout<<"d. Abraham Lincoln";
getch();
gotoxy(9,22);cout<<"Do you want to use your lifeline?";
gotoxy(13,24);cout<<"[ Y/N : ] ";
cin>>ask;
if(ask=='y')
{
gotoxy(10,28);cout<<"Choose Lifeline Number: ";
cin>>life;
if(life==1)
{
gotoxy(18,31);cout<<"[ 50:50 ]";
gotoxy(8,34);cout<<"_________";
gotoxy(29,34);cout<<"c. Isaac Newton";
gotoxy(8,37);cout<<"b. Charles Babbage";
gotoxy(29,37);cout<<"_________";
getch();
}
else if(life==2)
{
gotoxy(18,31);cout<<"[ Call a friend ]";
gotoxy(10,34);cout<<"Friend: I think it is B";
getch();
gotoxy(10,36);cout<<"You: How sure are you?";
getch();
gotoxy(10,38);cout<<"Friend: I'm 95% sure about this.";
getch();
}
else if(life==3)
{
gotoxy(18,31);cout<<"[ Ask the audience ]";
gotoxy(8,36);cout<<"(a.) 23% (b.) 52% (c.) 13% (d.) 12%";
getch();
}
}
else if(ask=='n')
getch();
gotoxy(16,42);cout<<"Your answer is: ";
cin>>ans;
if(ans=='b')
{ …
aianne 23 Light Poster
The problem is obvious :)
Let me show you some examples here:if(false) std::cout << "We can't get here"; // This is the first action after the if, so this is what will be executed if the condition is met std::cout << "We will get here, because I'm not a part of the if statement."; // This has nothing to do with the if. else // this is your problem... the else tries to match the if statement which may only be 1 action away.
The proper way to do it:
if(false) { std::cout << "We can't get here!"; std::cout << "This time you won't see me, because I'm inside the brackets connected to the if statement! :("; }else{ // now the else will match the if statement on the first matching opening bracket.
So if() without brackets are fine if theres only going to happen one thing. But more than one action requires brackets.
Let me know if it helped :)
Hi! it works! Thanks for helpin me! (^_^) I have one more question, why everytime I run the program and answer the "Your answer is: " it suddenly closed? is there something wrong with my code?
aianne 23 Light Poster
Your
if
s are going awry again
use {} everyif
,else if
andelse
and many of your problems vanish without themif
will only run until next;
if(x == 1) {//always use me x = 3; }//and me else {//here too x = 4l }//etc
so
if(ans=='a' || ans=='A') { gotoxy(14,35);cout<<"Correct!"; gotoxy(10,38);cout<<"Get ready for the next round!"; } else { gotoxy(14,35);cout<<"Wrong!"; gotoxy(10,38);cout<<"Play again?"; getch(); }
Hi! thanks for helping me again. it works! but theres a problem, when i tried to run it and answered the "Your answer is: " it suddenly closed. I tried the 'system delay code and the tip that you have given to me last day but it still. ;'(
aianne 23 Light Poster
Hi! I need help for my c++.
This is the code:
#include<iostream.h>
#include<conio.h>
void box(int x, int xx, int y, int yy);
void box(int x, int xx, int y, int yy)
{
int xs,ys,i,j;
xs=xx-x;
ys=yy-y;
for(i=1; i<xs; i++){gotoxy(x+i,y);cout<<"Í";
gotoxy(x+i,yy);cout<<"Í"; }
for(j=1; j<ys; j++){gotoxy(x,y+j);cout<<"º"; }
for(j=1; j<ys; j++){gotoxy(xx,y+j);cout<<"º"; }
{gotoxy(x,y);cout<<"É";
gotoxy(x,yy);cout<<"È";
gotoxy(xx,y);cout<<"»";
gotoxy(xx,yy);cout<<"¼";}
}
char ans;
char ask;
int life;
int main()
{
clrscr();
box(5,50,1,45);
box(55,78,8,30);
gotoxy(62,12);cout<<"LIFELINE";
gotoxy(57,15);cout<<"1. 50:50";
gotoxy(57,18);cout<<"2. Call a friend";
gotoxy(57,21);cout<<"3. Ask the audience";
gotoxy(13,3);cout<<"Who Wants to be a Millionaire?";
gotoxy(10,5);cout<<"The Folder contains?";
gotoxy(10,9);cout<<"a. Foods";
gotoxy(24,9);cout<<"b. Files";
gotoxy(10,11);cout<<"c. Animals";
gotoxy(24,11);cout<<"d. Clothes";
getch();
gotoxy(9,13);cout<<"Do you want to use your lifeline?";
gotoxy(13,14);cout<<" Y/N : ";
cin>>ask;
if(ask=='y')
{
gotoxy(10,15);cout<<"Choose Lifeline Number: ";
cin>>life;
if(life==1)
{
gotoxy(18,17);cout<<"[ 50:50 ]";
gotoxy(10,19);cout<<"_________";
gotoxy(24,19);cout<<"c. Animals";
gotoxy(10,21);cout<<"b. Files";
gotoxy(24,21);cout<<"_________";
}
else if(life==2)
{
gotoxy(18,17);cout<<"[ Call a friend ]";
gotoxy(10,20);cout<<"Friend: I think it is B";
getch();
gotoxy(10,23);cout<<"You: How sure are you?";
getch();
gotoxy(10,26);cout<<"Friend: I'm 95% sure about this.";
}
else if(life==3)
{
gotoxy(18,17);cout<<"[ Ask the audience ]";
gotoxy(10,23);cout<<"(a.) 23% (b.) 52% (c.) 13% (d.) 12%";
}
}
else if(ask=='n')
gotoxy(10,30);cout<<"Your answer is: ";
cin>>ans;
if(ans=='a' || ans=='A')
gotoxy(14,35);cout<<"Correct!";
gotoxy(10,38);cout<<"Get ready for the next round!";
else
gotoxy(14,35);cout<<"Wrong!";
gotoxy(10,38);cout<<"Play again?";
getch();
return 0;
}
The problem is when I try to run the program it says:
"ERROR Final.cpp 77: MISPLACED ELSE"
but i can't find if where is the error.
i'm so sorry, i'm not really good about this stuff. (^_^)
aianne 23 Light Poster
I am assume that the code that you have provided was a retype as it would not run.
using namespace std;
is the minor issue the bigger concern is that yourif
blocks are out of sync.I would recommend that you always nest your if blocks with
{}
this protects you from making mistakes that are difficult to readThis if condition wants to run for just life == 1 so
if(1 == life) { cout << "50-50"; cout<<"a. Files"; cout<<"c. Animals"; } else if(2 == life) { } /* //equivalent to what you wrote is if(1 == life) { cout << "50-50"; } //this will always run cout<<"a. Files"; cout<<"c. Animals"; */
You would also benefit a lot from having a question class
where you would need to track the
answer option_id
store 5 strings:
question
option_a
option_b
option_c
option_dthen you can add in your other methods
----------------------------------------------------------------------------------
Thank you!! it works!! but I still have one more question,. lol
when I chose yes for lifeline and it display the lifeline number but when I answerd the "Your answer is: " it suddenly closed..
this is the code:
#include<iostream.h>
#include<conio.h>
char ans;
char ask;
int life;
int main(void)
{
clrscr();
box(5,50,1,45);
box(55,78,8,30);
gotoxy(62,12);cout<<"LIFELINE";
gotoxy(57,15);cout<<"1. 50:50";
gotoxy(57,18);cout<<"2. Call a friend";
gotoxy(57,21);cout<<"3. Ask the audience";
gotoxy(13,3);cout<<"Who Wants to be a Millionaire?";
gotoxy(10,5);cout<<"The Folder contains?";
gotoxy(10,9);cout<<"a. Foods";
gotoxy(24,9);cout<<"b. Files";
gotoxy(10,11);cout<<"c. Animals";
gotoxy(24,11);cout<<"d. Clothes";
getch();
gotoxy(9,13);cout<<"Do you want to use …
aianne 23 Light Poster
hi! thank you soooo much! it works!! luvyah!!!!!!!!!
aianne 23 Light Poster
Hi! I need help! I need to create a program in c++ that ask a question, there is a multiple choice, display if your answer is wrong or correct. Like the gameshow "Who wants to be a millionaire" and included "LIFELINE"
I tried and it runs but when I chose "LIFELINE # 2" its also display the lifeline #1 and #3. and sometimes when i chose lifeline #1, it suddenly closed.
I'm so sorry i'm not really good about this. :'(
and sorry for my english. lol.
this is what i have done as of now >>:
#include<iostream.h>
#include<conio.h>
char ans;
char response;
int life;
int main()
{
clrscr();
cout<<"Who Wants to be a Millionaire?";
cout<<"Folder contains:?";
cout<<"a. Files";
cout<<"b. Foods";
cout<<"c. Animals";
cout<<"d. Stools";
getch();
cout<<"Do you want to use lifeline? Y/N: ";
cin>>response;
if(response=='y')
cout<<"1. 50-50";
cout<<"2. Call a friend";
cout<<"3. Ask the audience";
cout<<"Choose Lifeline [1-3]: ";
cin>>life;
{
if(life==1)
cout<<"50-50";
cout<<"a. Files";
cout<<"c. Animals";
{
if(life==2)
cout<<"Call a friend";
cout<<"Hi friend! I think the answer is letter B.";
cout<<"Im 89% sure. Good Luck!";
{
if(life==3)
cout<<"Ask the audience";
cout<<"The audience answers:";
cout<<"(a.) 52% (b.) 23% (c.) 13% (d.) 12%";
getch();
{ else if(response=='n')
cout<<"Your answer is: ";
cin>>ans;
switch(ans)
{
case 'a':
cout<<"a. Files";
getch();
cout<<"Correct!";
break;
case 'b':
cout<<"b. Foods";
getch();
cout<<"Wrong!";
break;
case 'c':
cout<<"c. Animals";
getch();
cout<<"Wrong!";
break;
case 'd':
cout<<"d. Stools";
getch();
cout<<"Wrong!";
break;
default:
cout<<"Invalid Choice!";
break;
}
getch();
return 0;
}}}}}}
aianne 23 Light Poster
Hi! I need help for my homework in c++. My professor wants us to write a program that ask a question and there is a multiple choice and the answer. like the gameshow "Who wants to be a millionaire?"
Please give me some example.. (^_^) thank you so much!
aianne 23 Light Poster
please help me.... guys.....
i want to know how to make a calculator in turbo c.
thanks....
try this code.
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void box(int x, int xx, int y, int yy);
void box(int x, int xx, int y, int yy)
{
int xs,ys,i,j;
xs=xx-x;
ys=yy-y;
for(i=1; i<xs; i++){gotoxy(x+i,y);printf("%c",205);
gotoxy(x+i,yy);printf("%c",205);}
for(j=1; j<ys; j++){gotoxy(x,y+j);printf("%c",186);}
for(j=1; j<ys; j++){gotoxy(xx,y+j);printf("%c",186);}
{gotoxy(x,y);printf("%c",201);
gotoxy(x,yy);printf("%c",200);
gotoxy(xx,y);printf("%c",187);
gotoxy(xx,yy);printf("%c",188);}
}
void main()
{
clrscr();
box(20,60,1,25);
box(23,57,2,7);gotoxy(37,4);printf("IPHONE");
box(23,29,8,11);gotoxy(26,9);printf("7");
box(23,29,12,15);gotoxy(26,13);printf("4");
box(23,29,16,19);gotoxy(26,17);printf("1");
box(23,29,20,23);gotoxy(26,21);printf("0");
box(31,37,8,11);gotoxy(34,9);printf("8");
box(31,37,12,15);gotoxy(34,13);printf("5");
box(31,37,16,19);gotoxy(34,17);printf("2");
box(31,37,20,23);gotoxy(34,21);printf(".");
box(39,45,8,11);gotoxy(42,9);printf("9");
box(39,45,12,15);gotoxy(42,13);printf("6");
box(39,45,16,19);gotoxy(42,17);printf("3");
box(39,45,20,23);gotoxy(42,21);printf("=");
box(47,57,8,11);gotoxy(52,9);printf("/");
box(47,57,12,15);gotoxy(52,13);printf("X");
box(47,57,16,19);gotoxy(52,17);printf("-");
box(47,57,20,23);gotoxy(52,21);printf("+");
getch();
}
Nick Evan commented: gotoxy() not declared. -2
Ancient Dragon commented: gotoxy is a Turbo C-specific function. +26
aianne 23 Light Poster
Hi! I need your help!! My teacher wants us to create flowchart with this code from turbo c :
#include<stdio.h>
main()
{
int grade;
clrscr();
printf("Enter Grade:");
scanf("%d",&grade);
if(grade<=74 && grade>=70)
printf("Sorry, You Failed!");
else if(grade>=75 && grade<=100)
printf("Congratulations! You Passed!");
else if(grade>=101 && grade>=101)
printf("Invalid Grade");
else if(grade<=69&&grade<=69)
printf("Invalid Grade");
getch();
}
pls help me! I tried to draw a flowchart and when i passed it to my teacher, he gave it back to me because it s wrong.
and another one:
#include<stdio.h>
#include<conio.h>
int m;
main()
{
clrscr();
printf("Enter Number:");
scanf("%d",&m);
switch(m)
{
case 1:
printf("\nJanuary: 31 Days");
break;
case 2:
printf("\nFebruary: 28 Days");
break;
case 3:
printf("\nMarch: 31 Days");
break;
case 4:
printf("\nApril: 30 Days");
break;
case 5:
printf("\nMay: 31 Days");
break;
case 6:
printf("\nJune: 30 Days");
break;
case 7:
printf("\nJuly: 31 Days");
break;
case 8:
printf("\nAugust: 31 Days");
break;
case 9:
printf("\nSeptember: 31 days");
break;
case 10:
printf("\nOctober: 30 Days");
break;
case 11:
printf("\nNovember: 31 Days");
break;
case 12:
printf("\nDecember: 31 Days");
break;
default:
printf("\nMonth is not available");
}
getch();
}
so i really really need your help guys. :'( I don't have any idea how to do it correctly.
Advance thanks to all of you.
xoxo
aianne 23 Light Poster
>>when I tried to run it, it suddenly closed
That's because there is nothing at the end of main() to prevent that behavior. If you want it to stay open so that you can see it, then add
getche();
at the end of main(). The program will then stop until you hit a key.
i tried it but still. :'(
aianne 23 Light Poster
Hi!, I'm newbie here on daniweb.. and i dont know if i'm in a right place to post this problem. lol. *sorry for my english*
anyway, will you please help me about Turbo C? My teacher gve us a sample problem and he starts it with this code :
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<graphics.h>
int gd,gm;
void main()
{
gd=DETECT;
initgraph(gd,gm,"");
if(graphresult()!=grOk){exit(1);}
rectangle(0,0,getmaxx(),getmaxy());
rectangle(1,1,getmaxx()-1,getmaxy()-1);
settextstyle(1,0,1);
outtextxy(50,50,"HELLO");
circle(400,600,10);
getch();
closegraph();
}
and when I tried to run it, it suddenly closed. and I don't know what is wrong with this. :'( help me! did I missed some codes to put on or any misspelled codes? pls check it and tell me what is the right code for this. (^_^)
and another one, my teacher wants us to make/draw us a "computer set (monitor,cpu,keyboard)" using turbo C. and i dont have any idea how to start with it. Do you have any codes for this problem? pls help me. :'(
thank you so much!