Location: PHPKode > projects > Music and Discography Database > music_db/repairs.php
<?
session_start();

require("common_funcs.php");
connectSQL();

print_r($_POST);
if (isset($_POST[update])) 
{
   $en = ucfirst(trim($_POST[en]));
   $hu = ucfirst(trim($_POST[hu]));
   query("SELECT instruments_id FROM instruments_en WHERE instruments_id={$_POST[id]}");
   if ($nur)
        sqlcmd("UPDATE instruments_en SET name='$en' WHERE instruments_id={$_POST[id]}"); 
   else
        sqlcmd("INSERT INTO instruments_en (instruments_id,name) VALUES ({$_POST[id]},'$en')");


   query("SELECT instruments_id FROM instruments_hu WHERE instruments_id={$_POST[id]}");
   if ($nur)
        sqlcmd("UPDATE instruments_hu SET name='$hu' WHERE instruments_id={$_POST[id]}"); 
   else
        sqlcmd("INSERT INTO instruments_hu (instruments_id,name) VALUES ({$_POST[id]},'$hu')");
}
if ($_GET[order]) $order = $_GET[order];
else $order = 'eid';
query("SELECT ie.name AS en, ih.name AS hu, ie.instruments_id AS eid, ih.instruments_id AS hid FROM instruments_en ie LEFT OUTER JOIN instruments_hu ih ON (ie.instruments_id=ih.instruments_id) ORDER BY $order");

?>
<HTML>
<HEAD>
    <TITLE>::: instruments database :::</TITLE>
    <LINK REL='stylesheet' HREF='styles_alter.css' TYPE='text/css'>
    <SCRIPT>
        function submit(id) {
            var id_en = id + '_en';
            var id_hu = id + '_hu';
            document.sform.id.value=id;
            document.sform.en.value=document.getElementById(id_en).value;
            document.sform.hu.value=document.getElementById(id_hu).value;
            document.sform.submit();
        }
    </SCRIPT>
</HEAD>
<BODY>

<FORM NAME='sform' METHOD=post>
    <INPUT TYPE=hidden NAME=id>
    <INPUT TYPE=hidden NAME=update>
    <INPUT TYPE=hidden NAME=en>
    <INPUT TYPE=hidden NAME=hu>
</FORM>
<TABLE>
<FORM METHOD=get NAME=lform>
   <TR><TD><a href='?order=eid'>id</a></TD><TD><a href='?order=en'>en</a></TD><TD><a href='?order=hu'>hu</a></TD></TR>
</FORM>
<?
while ($row = mysql_fetch_assoc($res)) 
{
    if ($row[eid] != '') $id = $row[eid];
    #else $id = $row[hid];
    
    $id_en = $id.'_en';
    $id_hu = $id.'_hu';

    print "<TR><TD><INPUT TYPE=button NAME=id VALUE=$id onClick='submit(\"$id\")'></TD>
               <TD><INPUT ID=$id_en TYPE=text VALUE='{$row[en]}'></TD>
               <TD><INPUT ID=$id_hu TYPE=text VALUE='{$row[hu]}'></TD></TR>";
}

?>
</TABLE>
<BODY>
</HTML>
Return current item: Music and Discography Database