Newbie In Need of Assistance - PHP & SQL
Posted: Wed Mar 16, 2011 11:20 am
Hey all! I'm recently new to programming and am working on a small basic personal timetable project using PHP and SQL. I have a web-page where a user wants to update data in one of the database tables. I've been through sources online and my 'php for dummies' book(!) and i'm still unable to solve my problem. I'll try to post my code below and hope someone will be able to point out what i'm doing wrong:
hope to hear some feedback soon, many thanks Aaron 
Code: Select all
<?php
session_start();
$hostname_logon = "***.*.*.*" ;
$database_logon = "aal9" ;
$username_logon = "root" ;
$password_logon = "" ;
$coursenametext = '';
$connections = mysql_connect($hostname_logon, $username_logon, $password_logon) or die ( "Unable to connect to the database" );
mysql_select_db($database_logon) or die ( "Unable to select database!" );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Edit Courses</title>
<link href="Aaron.css" rel="stylesheet" type="text/css" />
</head>
<div class="container">
<h1><a href="http://www.bbc.co.uk"><img src="logo.gif" alt="Logo" width="224" height="62" id="ol_logo" align="left"/></a>Update Courses</h1>
</div>
<div class="sidebar1">
<ul class="nav">
<li><a href="homepage.php">Homepage</a></li>
<li><a href="modules.php">My Modules</a></li>
<li><a href="update.php">Update Database</a></li>
<li><a href="googles1.php">Sem 1 Google</a></li>
<li><a href="timetable2.php">Sem 2 Timetable</a></li>
<li><a href="googles2.php">Sem 2 Google</a></li>
<li><a href="logout.php">Logout</a></li>
</ul>
<p><a href="javascript:window.print()">Print This Page</a></p>
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. </p>
<p>Welcome To Timetable Management. Please Find All Necessary Links Above.</p>
</div>
<div class="content">
<form action="editcourses.php" method="post">
<table border="1" cellspacing="1" align="center" bordercolor="#FFFFFF">
<tr>
<td>Course Name</td>
<td>Edit</td>
<td>Submit</td>
</tr>
<?php
$query = "SELECT * FROM Courses ";
$result = mysql_query ($query);
if(mysql_num_rows($result)>0){
while($row = mysql_fetch_array($result)) {
echo('<tr>' .
'<td>' . $row['CourseName'] . '</td>' .
'<td><textarea name="coursenametext" rows="1"></textarea>' . '</td>' .
'<td>' . '<input type="Submit" name="Submit" value="Submit">' . '</td>' .
'</tr>');
}
}
$query1 = "UPDATE courses SET courseName = $coursenametext";
$result1 = mysql_query ($query1);
?>
</table>
</form>
<br>
</div>
<div class="footer">
<p><a href="mailto:********" class="Email">Click Here To Email For Help With Faults</a></p>
</div>
</div>
</body>
</html>