View Full Version : delete

02-28-2008, 06:23 PM

02-28-2008, 06:42 PM
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

$name = '';
$con = mysql_connect("localhost", "user", "password") or die('Could not connect: ' . mysql_error());
mysql_select_db("database") or die(mysql_error());
<form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<dt>Pet Name</dt>
<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>
<input type="submit" value="Submit">
<input type="reset"/>
// 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))
<th><?php echo $pets['date']; ?></th>
<th><?php echo $pets['type']; ?></th>
<th><?php echo $pets['remark']; ?></th>

// 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>';

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?

02-28-2008, 06:47 PM