I've used a tutorial, and got to a point where I need help, im trying to remove the id column and add another column where I can select an option from a dropdown menu.
<?php
/**** Dealing with the database ****/
// connect to db
$conn = mysql_connect('localhost','dbuserwebsite','dbpassword') or trigger_error("SQL", E_USER_ERROR);
$db = mysql_select_db('dbwebsite',$conn) or trigger_error("SQL", E_USER_ERROR);
// INSERT: if we have a website to add...
if($_POST['website']) {
// little bit of cleaning...
$website = mysql_real_escape_string($_POST['website']);
// insert new website into table
$sql = "INSERT INTO info (id, website) VALUES ('','$website')";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
} // end if
// UPDATE: if we have website(s) to change...
if($_POST['cwebsite']) {
// for each website to change...
foreach($_POST['cwebsite'] as $cid => $cwebsite) {
// little bit of cleaning...
$id = mysql_real_escape_string($cid);
$website = mysql_real_escape_string($cwebsite);
// update website in the table
$sql = "UPDATE info SET website = '$website' WHERE id = '$id'";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
} // end foreach
} // end if
// DELETE: if we have a website to delete...
if($_GET['website']) {
// little bit of cleaning...
$website = mysql_real_escape_string($_GET['website']);
// delete website from table
$sql = "DELETE FROM info WHERE website = '$website'";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
} // end if
// ORDERBY: if one of the links was clicked..
if ($_GET['orderby']) {
// make an aray of allowed websites
$allowed = array('id','website');
// bit of cleaning...
$order = mysql_real_escape_string($_GET['orderby']);
// is it a valid column website? yes: use it. no: default to 'id'
$order = (in_array($order, $allowed))? $order : "id";
// if no link clicked, default to 'id'
} else {
$order = "id";
} // end else
// SELECT: get the list of websites from database
$sql = "SELECT id, website FROM info ORDER BY $order";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
/**** end deal with the database ****/
/**** list everything out ****/
// list columns
echo <<<LISTCOLS
<form action = '{$_SERVER['PHP_SELF']}' method = 'post'>
<table border = '1'>
<tr>
<td><a href = '{$_SERVER['PHP_SELF']}?orderby=id'>ID</td>
<td><a href = '{$_SERVER['PHP_SELF']}?orderby=website'>Website</td>
<td>Delete</td>
</tr>
LISTCOLS;
// loop through list of websites
while ($list = mysql_fetch_assoc($result)) {
echo <<<LISTINFO
<tr>
<td>{$list['id']}</td>
<td><input type = 'text' website = 'cwebsite[{$list['id']}]' value = '{$list['website']}'>
<td><a href = '{$_SERVER['PHP_SELF']}?website={$list['website']}'>delete</a></td>
</tr>
LISTINFO;
} // end while
// list input box for adding new entry
echo <<<NEWENTRY
<tr>
<td bgcolor = 'gray'></td>
<td><input type = 'text' website = 'website'></td>
<td bgcolor = 'gray'></td>
</tr><tr>
<td></td>
<td align = 'center'><input type = 'submit' value = 'submit'></td>
<td></td>
</tr>
</table>
</form>
NEWENTRY;
/**** end list everything out ****/
?>
Heres how it currently looks:

Heres how im trying to get it too look:

Can anyone help.
Thanks