Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: delete

  1. #1
    New to the CF scene
    Join Date
    Feb 2008
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    delete

    delete
    Last edited by librarygal; 02-28-2008 at 07:53 PM. Reason: delete

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Why did you post this in the HTML/CSS forum? Sure it will take some HTML but its mostly going to take php. Try this
    PHP Code:
    <?php
    session_start
    ();
    $name '';
    $con mysql_connect("localhost""user""password") or die('Could not connect: ' mysql_error());
    mysql_select_db("database") or die(mysql_error());
    ?>
    <h1>Events</h1>
    <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
        <dl>
            <dt>Pet Name</dt>
            <dd>
                <select name="name">
                    <option value="none">Choose An Event Name</option>
                    <option value="Fluffy">Fluffy</option>
                    <option value="Buffy">Buffy</option>
                    <option value="Chirpy">Chirpy</option>
                    <option value="Slim">Slim</option>
                    <option value="Bowser">Bowser</option>
                    <option value="Fang">Fang</option>
                    <option value="Claws">Claws</option>
                    <option value="Whistler">Whistler</option>
                </select>
                <input type="submit" value="Submit">
                <input type="reset"/>
            </dd>
        </dl>
    </form>
    <?php
        
    // set name to 'none' if there is no name query in url. Use mysql_real_escape_string to protect from injection
        // simply using $name implies that register globals is on and this can be a security issue
        
    $name = (isset($_GET['name'])) ? mysql_real_escape_string($_GET['name']) : 'none';
        
        
    // your method for setting up a query was a little untraditional
        
    $sql "SELECT date, type, remark FROM table where name='$name'";
        
        
    // now we run the query checking for errors
        
    $result mysql_query($sql) or die(mysql_error());
        
        
    // if we get matches from the database then we can do somethign with the data
        
    if(mysql_num_rows($result) > 0)
        {
            
    // this assigns evtname to the original name=name in the url
            
    $evtname $_GET['name'];
            
            
    // echo out the beginning of the table
            
    echo '<table id="eventtable">';
            echo 
    '<caption>';
            echo 
    'Events for '.$evtname;
            echo 
    '</caption>';
            
            
    // now we loop through the records printing out each event under that name to the screen
            
    while($pets mysql_fetch_array($result))
            {
        
    ?>
                <tr>
                    <th><?php echo $pets['date']; ?></th>
                    <th><?php echo $pets['type']; ?></th>
                    <th><?php echo $pets['remark']; ?></th>
                </tr>
        <?php
            
    }
            
            
    // echo the end of the table
            
    echo '</table>';
        }
        else 
    // if no results were found then we tell them this
        
    {
            echo 
    '<p>There are no events with that name.</p>';
        }
    mysql_close($con);
    ?>
    Out of curiosity why are you taking a crash course on server side programming? If its for a job can they not hire someone who knows what they are doing?
    Last edited by _Aerospace_Eng_; 02-28-2008 at 06:46 PM.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New to the CF scene
    Join Date
    Feb 2008
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    delete
    Last edited by librarygal; 02-28-2008 at 07:54 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •