Location: PHPKode > projects > Computer Service Company Database > SOLOCMS/dogbert/drivers.php
<? include ('db.php'); ?>
<? include ('header.php'); ?>
  <table width="750"  border="0" align="center">
  <tr>
    <td><h3>Here are all the drivers we currently have.</h3>
  <p class="newsbody"><?php
     $msg = ''; // default empty message

 // grab all the current drivers by catagory so you can see what you already have
    
	 $sql = "SELECT id, name FROM drivers WHERE cat='Video'";
     $res_cat = mysql_query($sql); // handle to category set
      $sql2 = "SELECT id, name FROM drivers WHERE cat='MB'";
     $res_cat2 = mysql_query($sql2); // handle to category set
      $sql3 = "SELECT id, name FROM drivers WHERE cat='LAN'";
     $res_cat3 = mysql_query($sql3); // handle to category set
      $sql4 = "SELECT id, name FROM drivers WHERE cat='Sound'";
     $res_cat4 = mysql_query($sql4); // handle to category set
      $sql5 = "SELECT id, name FROM drivers WHERE cat='Modem'";
     $res_cat5 = mysql_query($sql5); // handle to category set
      $sql6 = "SELECT id, name FROM drivers WHERE cat='SCSI'";
     $res_cat6 = mysql_query($sql6); // handle to category set
      $sql7 = "SELECT id, name FROM drivers WHERE cat='Other1'";
     $res_cat7 = mysql_query($sql7); // handle to category set
      $sql8 = "SELECT id, name FROM drivers WHERE cat='Other2'";
     $res_cat8 = mysql_query($sql8); // handle to category set
      $sql9 = "SELECT id, name FROM drivers WHERE cat='Other3'";
     $res_cat9 = mysql_query($sql9); // handle to category set
      $sql10 = "SELECT id, name FROM drivers WHERE cat='Other4'";
     $res_cat10 = mysql_query($sql10); // handle to category set

//below here displays the drivers you already have      
?>
  <table width="100%"  border="0">
    <tr><form action="" method="POST">
      <td> 
        
        <p align="left" class="newsbody">
    <select name="vid">
              <option value="">-</option>
              <?php while ($row = mysql_fetch_assoc($res_cat)) { ?>
              <option value='<?php echo $row['id']; ?>'><?php echo $row['name']; ?></option>
              <?php } ?>
            </select>
    Video Driver </p>
        <p align="left" class="newsbody">
          <select name="mb">
            <option value="">-</option>
            <?php while ($row = mysql_fetch_assoc($res_cat2)) { ?>
            <option value='<?php echo $row['id']; ?>'><?php echo $row['name']; ?></option>
            <?php } ?>
          </select>
  MB Driver </p>
        <p align="left" class="newsbody">
          <select name="lan">
            <option value="">-</option>
            <?php while ($row = mysql_fetch_assoc($res_cat3)) { ?>
            <option value='<?php echo $row['id']; ?>'><?php echo $row['name']; ?></option>
            <?php } ?>
          </select>
  LAN Driver </p>
        <p align="left" class="newsbody">
          <select name="sound">
            <option value="">-</option>
            <?php while ($row = mysql_fetch_assoc($res_cat4)) { ?>
            <option value='<?php echo $row['id']; ?>'><?php echo $row['name']; ?></option>
            <?php } ?>
          </select>
  Sound Driver </p>
        <p align="left" class="newsbody">
          <select name="modem">
            <option value="">-</option>
            <?php while ($row = mysql_fetch_assoc($res_cat5)) { ?>
            <option value='<?php echo $row['id']; ?>'><?php echo $row['name']; ?></option>
            <?php } ?>
          </select>
  Modem Driver</p>
        <p align="left" class="newsbody">
          <select name="scsi">
            <option value="">-</option>
            <?php while ($row = mysql_fetch_assoc($res_cat6)) { ?>
            <option value='<?php echo $row['id']; ?>'><?php echo $row['name']; ?></option>
            <?php } ?>
          </select>
  SCSI Driver</p></td>
      <td valign="top"><p align="left" class="newsbody">
        <select name="other1">
          <option value="">-</option>
          <?php while ($row = mysql_fetch_assoc($res_cat7)) { ?>
          <option value='<?php echo $row['id']; ?>'><?php echo $row['name']; ?></option>
          <?php } ?>
        </select>
  Other Software 1 </p>
        <p align="left" class="newsbody">
          <select name="other2">
            <option value="">-</option>
            <?php while ($row = mysql_fetch_assoc($res_cat8)) { ?>
            <option value='<?php echo $row['id']; ?>'><?php echo $row['name']; ?></option>
            <?php } ?>
          </select>
  Other Software 2 </p>
        <p align="left" class="newsbody">
          <select name="other3">
            <option value="">-</option>
            <?php while ($row = mysql_fetch_assoc($res_cat9)) { ?>
            <option value='<?php echo $row['id']; ?>'><?php echo $row['name']; ?></option>
            <?php } ?>
          </select>
  Other Software 3 </p>
        <p align="left" class="newsbody">
          <select name="other4">
            <option value="">-</option>
            <?php while ($row = mysql_fetch_assoc($res_cat10)) { ?>
            <option value='<?php echo $row['id']; ?>'><?php echo $row['name']; ?></option>
            <?php } ?>
          </select>
  Other Software 4 </td>
    </form></tr>
  </table>
  <p class="newsbody">    
    </td>
  </tr>
       <tr>
         <td><p>&nbsp;</p>
           <p><?php echo $msg; ?></p>
           <?php
		   
// Upload a file.  Works up to 5 megs but isnt reliable after that.  Need to use ftp or something in the future.		   
require ("upload_img.inc.php");

    $title = "Uploading Files";
    $upload = new Upload(&$HTTP_POST_FILES);
    $upload->maxupload_size = 50000000; // 20,000,000 bytes, or 20mb
    $field1_filename = $upload->getFileName("file1");
    
    /*
    This would display the image if used for that.
	echo "<img src=/uploads/$field1_filename>\n\n";
	*/
    echo "<form enctype=\"multipart/form-data\" method=\"post\">
        <input type=\"File\" name=\"file1\">
        <input type=\"submit\" class=\"btnOver\" onmouseover=\"this.className='btnUp'\" onmouseout=\"this.className='btnOver'\" value=\"upload file\">
    </form>";

if ($upload->save($DOCUMENT_ROOT,$field1_filename ,true))
{
    echo "Upload save was successful!!<br>";
} else{
    echo $upload->errors;
}

if ($upload->saveAs("/drivers/".$field1_filename,$DOCUMENT_ROOT,"file1",true))
{
    echo "Uploaded";
} else{
    echo $upload->errors;
}
if ($upload->isPosted)
{
    echo "<br><br><b>Uploaded file detail</b><br>";
    echo "Filename:" . $driver_upload_path .$upload->getFileName("file1")."<br>";
    echo "After uploading a file"."<br>";
	echo "Copy and paste this URL into the URL field"."<br>";

}
//the part below is where you enter in the description and catagory for the driver
?>
           <h1>Upload the driver or software package and then copy and paste the link displayed into the Driver URL area. Then Type in the display name of the driver. Make it descriptive especially if its proprietary software. Then choose the catagory you want it to be in. </h1>
           <h1>Then create the service tag. <br>
           </h1>
           <form action="<? print $_SERVER["../PHP_SELF"]; ?>" method="POST">
             <p>
               <input name="link" type="text" value="<? echo $driver_upload_path.$upload->getFileName("file1"); ?>" size="60">
    Driver URL </p>
             <p><font face="Geneva, Arial, Helvetica, sans-serif">
               <input name="name" type="text" id="name" value="<? print $row["name"]; ?>" size="60">
    Driver Display Name </font></p>
             <p><font face="Geneva, Arial, Helvetica, sans-serif"> </font></p>
             Category
             <select name="cat" size="1">
               <?php $catarr = array ( 'MB' , 'LAN' , 'Sound' , 'Modem' , 'SCSI' , 'Video' , 'Other1' , 'Other2' , 'Other3' , 'Other4');
                     foreach ($catarr as $val) { ?>
               <option value="<?=$val?>">
               <?=$val?>
               </option>
               <?php } ?>
             </select>
             <input type="submit" name="submit" value="Update Drivers">
             <input type="hidden" name="submit" value="Update Drivers">
           </form>
           
      </td>
       </tr>
</table>
<? include ('navigation.php'); ?>
<? include ('footer.php'); ?>	

<?	   
// insert the driver info into the database
		   
include("db.php"); // setup connection to mysql  Do I need to connect again?
if($_POST["submit"]) { // if form submitted
$link = $_POST['link'];
$name = $_POST['name'];
$cat = $_POST['cat'];
$query = "INSERT INTO drivers (link,name,cat) VALUES ('$link','$name','$cat')";

 // update your field in your table
  $result = mysql_query($query) or die(mysql_error()); // exec query
  print "Drivers updated";
}
$r = mysql_query($q) or die(mysql_error()); // exec
$row = mysql_fetch_assoc($r); // fetch the row

?>
Return current item: Computer Service Company Database