0

Hi, I need to use getopt for a program called like myprogram.c file1 file2 file3 -t. Now I've read some examples about how to use switch cases for options with hypens (-t). But I don't get how to write this for my file1, file2, and file3 (they are arguments that must be provided). It would help if someone could explain getopt in simple terms as well, I feel like my brain is fried at this point with all the variables I read about it having. Thank you kindly!

0
<?php
//create a database connection
mysql_connect("localhost", "root","") or die(mysql_error());
//select your database
mysql_select_db("group1");
?>

<html>
<body background="schoolbackground.jpg">
<div style="border-bottom-style: solid; border-bottom-width: 1px; padding-bottom: 1px">
    <font color="#357EC7" size="7" face="century gothic">Student Delinquent List</font></div>
 <p> </p>
<a href="textbook_teachhome.htm">
<p align="right">
<button type="button"><font face="century gothic" size="2" color="#357EC7">Go Back</font></button></a>
</p>
<p align="center">

<?php

$query = mysql_query("SELECT * from r_textbook_info");
$count = mysql_num_rows($query);
?>

<table frame="border" rules="all" cellpadding="5" bgcolor="#FFFFFF">  
<tr>
<th></th>
<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">      
<th>Student Number</th>
<th>Course</th>
<th>Year</th>      
<th>Book ID</th>
<th>Book Name</th>
<th>Cost</th>
</tr>

<?php
//return the array
while ($row = mysql_fetch_array($query, MYSQL_ASSOC)){

    $sn = $row['student_number'];
    $course = $row['course'];
    $year = $row['year'];
    $bid = $row['book_id'];
    $bname = $row['book_name'];
    $cost = $row['cost'];
    $id = $row['id'];
?>
<tr>
 <th><input name="checkbox" type="checkbox" id="checkbox[]" value="<?php echo $id; ?>"/></th>
 <th><?php echo $sn; ?></th>
 <th><?php echo $course; ?></th>
 <th><?php echo $year; ?></th>
 <th><?php echo $bid; ?></th>
 <th><?php echo $bname; ?></th>
 <th><?php echo $cost; ?></th>
</tr>

<?php
}
?>

</table>
<input name="delete" type="submit" id="delete" value="Delete"/>

<?php

// Check if delete button active, start this 
if(isset($_POST['delete']))
{
    if(count($_POST['checkbox']) !=0)
    {
        $array = array("checkbox" => $_POST['checkbox']);
        $ids = implode(',', $array['checkbox']);
        $result = mysql_query("DELETE FROM r_textbook_info WHERE id IN($ids)") or die(mysql_error());
    }

//if successful redirect to teach_delinquentlist.php 
if($result){
 echo "<meta http-equiv=\"refresh\" content=\"0;URL=teach_delinquentlist.php\">";
 }
 }
 mysql_close();
 ?>

</p>
</form>
</html>
0

thanks to both of you guys for explaining that...but the reason i'm not using

checkbox[]

is because i get an error that it is undefined...my program works fine if its just 'checkbox'
i think it might be because you have to give it an index?
but new problem....i'm not able to delete multiple selected rows

0

hey i changed by code a little...now it works :')

if(isset($_POST['delete']))
{
    if(count($_POST['checkbox']) !=0)
    {
        $array = array("checkbox" => $_POST['checkbox']);
        $ids = implode(',', $array);
        $result = mysql_query("DELETE FROM r_textbook_info WHERE id IN($ids)") or die(mysql_error());
    }
}

thanks cereal, i couldn't have figured it out without you

0

hello, i'm having trouble getting my delete selected checkbox working for a code I'm writing:
the trouble is really just in the bottom half of the code after i make the while loop...i made this off of an example that i found on a site but like it was pretty clear that the site's code had many errors for example...the coder made an input tag and later called it as a $variable which i'm pretty sure isn't possible..anyways some help would be much appreciated :)

<?php
//create a database connection
mysql_connect("localhost", "root","") or die(mysql_error());
//select your database
mysql_select_db("group1");
?>

<html>
<body background="schoolbackground.jpg">
<div style="border-bottom-style: solid; border-bottom-width: 1px; padding-bottom: 1px">
    <font color="#357EC7" size="7" face="century gothic">Student Delinquent List</font></div>
 <p>&nbsp;</p>
<a href="textbook_teachhome.htm">
<p align="right">
<button type="button"><font face="century gothic" size="2" color="#357EC7">Go Back</font></button></a>
</p>
<p align="center">

<?php

$query = mysql_query("SELECT * from r_textbook_info");
$count = mysql_num_rows($query);
?>

<table frame="border" rules="all" cellpadding="5" bgcolor="#FFFFFF">  
<tr>
<th></th>
<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">      
<th>Student Number</th>
<th>Course</th>
<th>Year</th>      
<th>Book ID</th>
<th>Book Name</th>
<th>Cost</th>
</tr>

<?php
//return the array
while ($row = mysql_fetch_array($query)){

    $sn = $row['student_number'];
    $course = $row['course'];
    $year = $row['year'];
    $bid = $row['book_id'];
    $bname = $row['book_name'];
    $cost = $row['cost'];
?>
<tr>
 <th><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $bid; ?>"/></th>
 <th><? echo $sn; ?></th>
 <th><? echo $course; ?></th>
 <th><? echo $year; ?></th>
 <th><? echo $bid; ?></th>
 <th><? echo $bname; ?></th>
 <th><? echo $cost; ?></th>
</tr>

<?php
}
?>

</table>

<?php
// Check if delete button active, start this 
if(isset($_POST['delete'])){
 for($i=0;$i<$count;$i++){
    if(isset($_POST['checkbox[]']))
 {$del_id = $bid[$i];
 echo $del_id;
 $sql = ...