hi i would like to update the lecturer lec_id of an module if that module does not have an lecturer a signed, but same time must not update the modules lecuturer when there is already one present... the columns in table module are mod_id, mod_name, lec_id..
mod_id and mod_names have been preset, thus just lec_id needs to be inserted or updated through form which then sent results to this code...please help noob
function mysql_evaluate($query, $default_value="undefined") {
$result = mysql_query($query);
if (mysql_num_rows($result)==0)
return "<br/>hello ".$default_value;
else
return "<br/> mysql ".mysql_result($result,0);
}
if (isset($_POST['submitted'])&&(is_array($module)))
{
foreach($module as $key => $value)
{
//check if the module selected is PHP
$query = "SELECT mod_name FROM module WHERE mod_name='$value'";
$result = mysql_query($query);
$row = mysql_fetch_array ($result , MYSQL_ASSOC);
if($row['mod_name']==$value)
{
$customer_type = mysql_evaluate("SELECT lec_id FROM module WHERE mod_name='$value'", "some_one_");
echo "<br/>customer ".$customer_type;
$result=mysql_query($customer_type);
if (!empty($result))
{
echo '<br/><br/>Ok,'. $name.',you are now registered';
$querys = "UPDATE module SET lec_id='$name' WHERE mod_name='$value'";
$results = mysql_query($querys);
}
else
{
echo "<br/>Could not register you";
}
}
}
print "</br></br></br></br>";
}