PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
boo_lolly
Forum Contributor
Posts: 154 Joined: Tue Nov 14, 2006 5:04 pm
Post
by boo_lolly » Fri Dec 01, 2006 11:50 am
i've got a cms that i'm designing for a client. there is a page that i have that retrieves all the results in a certain SQL table, and spits it out into an HTML table. at the end of each row in the HTML table, there is a delete checkbox... and a delete button at the bottom of the table...
it works great, for me... but i run firefox. when it is opened up in internet explorer... the checkbox doesn't work... where does this problem stem from??? here's the code...
Code: Select all
<?php
@ $db = mysql_connect("yah", "blah", "blah");
mysql_select_db("my_DB", $db);
if(!$db){
echo "Error: Could not connect to the database. Please try again later.";
exit;
}
if($action == "simplesearch"){
trim($lname);
trim($fname);
if (!$lname){
echo "<FONT COLOR=FF0000>You have not filled the required fields. Please try again.</FONT>";
exit;
}
$result = mysql_query("SELECT * FROM my_search_table
WHERE brideLname LIKE '%". $lname ."%' OR groomLname LIKE '%". $lname ."%'
AND event_month ='". $event_month ."'
AND event_day = '". $event_day ."'
AND event_year = '". $event_year ."'")
or die(mysql_error());
}
elseif($action == "view_all"){
$v_a = "Viewing all entries.";
$_POST['delete'];
if($_POST['delete'] != NULL){
foreach($_POST['delete'] as $k => $c){
$sql = "DELETE FROM my_search_table WHERE uID = '". $c ."'";
mysql_query($sql) OR die ("The query:<br>" . $sql . "<br>Caused the following error:<br>" . mysql_error());
$reg = "DELETE FROM my_reg_table WHERE uID = '". $c ."'";
mysql_query($reg) OR die (mysql_error());
}
}
$result = mysql_query("SELECT * FROM my_search_table ORDER BY brideLname") or die(mysql_error());
}
$num_result = mysql_num_rows($result);
if($num_result < 1){
echo "Your search results for:<br />";
echo "First name: ". $fname ." | Last name: ". $lname .
" | Event Date: ". $event_month ."/". $event_day ."/". $event_day ."<br />";
echo "Number of matches: ". $num_result ."<br />";
echo "<FONT COLOR=\"red\">Sorry, there were no matches for your query. Please try again.</FONT><br />";
echo "<form action=\"addCouple.php\" method\"=post\"><input type=\"submit\" value=\"Add Newlywed\"></form><br />";
mysql_close($db);
exit;
}
else{
if(isset($v_a)){
echo $v_a ."<br />";
echo "Number of matches: ". $num_result ."<br />";
}
else{
echo "Your search results for:<br />";
echo "First name: ". $fname ." | Last name: ". $lname .
" | Event Date: ". $event_month ."/". $event_day ."/". $event_day ."<br />";
echo "Number of matches: ". $num_result ."<br />";
}
echo "<form action=\"addCouple.php\"><input type=\"submit\" value=\"Add\"></form><br />";
echo "<form action=\"admin1.php?action=view_all\" method=\"post\">";
echo "<TABLE WIDTH=\"750\" BORDER=\"1\" CELLPADDING=\"2\">";
echo "<form action=\"". $_SERVER['PHP_SELF'] ."?action=view_all\" method=\"post\">";
echo "<TR><TH>Bride</TH><TH>Groom</TH><TH>Event Date</TH><TH>Shipping Address</TH><TH>Edit</TH><TH>Delete</TH></TR>";
for($i=0; $i < $num_result; $i++){
$row = mysql_fetch_array($result);
echo "<TR><TD align=\"center\">". $row['brideFname'] ." ". $row['brideLname'] ."</TD><TD align=\"center\">". $row['groomFname'] ." ".
$row['groomLname'] ."</TD><TD align=center>". $row['event_month'] ."/". $row['event_day'] ."/". $row['event_year'] .
"</TD><TD align=\"center\">". $row['ship_add'] .", ". $row['ship_city'] .", ". $row['ship_state'] .", ". $row['ship_zip']
."</TD><TD align=\"center\" width=\"125\"><A HREF=\"editCouple.php?editID=". $row['uID'] ."\">Couple</A> / <A HREF=\"updateRegistry.php?regID=".
$row['uID'] ."\">Registry</A></TD><TD align=\"center\"><input type=\"checkbox\" name=\"delete[]\" value=\"". $row['uID'] ."\"></TD></TR>";
$_POST['editID'];
$_POST['regID'];
}
echo "</form></TABLE>";
echo "<p align\"=\"right><input type=\"submit\" value=\"Delete\">";
}
echo "</form></form></p>";
mysql_close($db);
?>
need a little help here.
Last edited by
boo_lolly on Fri Dec 01, 2006 1:15 pm, edited 5 times in total.
Burrito
Spockulator
Posts: 4715 Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah
Post
by Burrito » Fri Dec 01, 2006 11:52 am
what do you mean 'the checkbox doesn't work'?
you mean it doesn't show at all on the page, when you submit it, it doesn't submit the value?
we need more information and yes, some code would be good.
boo_lolly
Forum Contributor
Posts: 154 Joined: Tue Nov 14, 2006 5:04 pm
Post
by boo_lolly » Fri Dec 01, 2006 11:59 am
sorry, the code is reposted above... what i mean is, if i'm in internet explorer, and i check a checkbox and press the delete button, it doesn't do anything. not a single thing, like it's a dummy switch...
but in firefox, it works GREAT!
Burrito
Spockulator
Posts: 4715 Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah
Post
by Burrito » Fri Dec 01, 2006 12:01 pm
I dont' even see a checkbox in that code...are you sure you posted the right code?
boo_lolly
Forum Contributor
Posts: 154 Joined: Tue Nov 14, 2006 5:04 pm
Post
by boo_lolly » Fri Dec 01, 2006 1:00 pm
sorry, it's an include... check it now...
Luke
The Ninja Space Mod
Posts: 6424 Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA
Post
by Luke » Fri Dec 01, 2006 1:02 pm
I haven't even looked at it... but once again QUOTE YOUR ATTRIBUTES. IT ISN'T OPTIONAL.
Burrito
Spockulator
Posts: 4715 Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah
Post
by Burrito » Fri Dec 01, 2006 1:09 pm
you have three nested </form> tags.
you can't nest forms. I dont' see why that would prevent IE from submitting the form as you say "nothing is happening", but it's possible. also you have some other issues like <p align"="....>
that might be causing it to blow up.
boo_lolly
Forum Contributor
Posts: 154 Joined: Tue Nov 14, 2006 5:04 pm
Post
by boo_lolly » Fri Dec 01, 2006 1:22 pm
yeah i just caught the valign"\= myself, that didn't change anything. the nested <forms> was a good call. i looked into it further, and it actually WAS kinda the opposite =). kinda. as in, i was closing a form tag too early. i just deleted that part and closed it afterward, and now it works lol! here's the code now...
Code: Select all
<?php
@ $db = mysql_connect("yah", "blah", "blah");
mysql_select_db("my_DB", $db);
if(!$db){
echo "Error: Could not connect to the database. Please try again later.";
exit;
}
if($action == "simplesearch"){
trim($lname);
trim($fname);
if (!$lname){
echo "<FONT COLOR=\"FF0000\">You have not filled the required fields. Please try again.</FONT>";
exit;
}
$result = mysql_query("SELECT * FROM my_search_table
WHERE brideLname LIKE '%". $lname ."%' OR groomLname LIKE '%". $lname ."%'
AND event_month ='". $event_month ."'
AND event_day = '". $event_day ."'
AND event_year = '". $event_year ."'")
or die(mysql_error());
}
elseif($action == "view_all"){
$v_a = "Viewing all entries.";
$_POST['delete'];
if($_POST['delete'] != NULL){
foreach($_POST['delete'] as $k => $c){
$sql = "DELETE FROM my_search_table WHERE uID = '". $c ."'";
mysql_query($sql) OR die ("The query:<br>" . $sql . "<br>Caused the following error:<br>" . mysql_error());
$reg = "DELETE FROM my_reg_table WHERE uID = '". $c ."'";
mysql_query($reg) OR die (mysql_error());
}
}
$result = mysql_query("SELECT * FROM my_search_table ORDER BY brideLname") or die(mysql_error());
}
$num_result = mysql_num_rows($result);
if($num_result < 1){
echo "Your search results for:<br />\n";
echo "First name: ". $fname ." | Last name: ". $lname .
" | Event Date: ". $event_month ."/". $event_day ."/". $event_day ."<br />";
echo "Number of matches: ". $num_result ."<br />\n";
echo "<FONT COLOR=\"red\">Sorry, there were no matches for your query. Please try again.</FONT><br />\n";
echo "<form action=\"addCouple.php\" method\"=post\"><input type=\"submit\" value=\"Add Newlywed\"></form><br />\n";
mysql_close($db);
exit;
}
else{
if(isset($v_a)){
echo $v_a ."<br />";
echo "Number of matches: ". $num_result ."<br />\n";
}
else{
echo "Your search results for:<br />\n";
echo "First name: ". $fname ." | Last name: ". $lname .
" | Event Date: ". $event_month ."/". $event_day ."/". $event_day ."<br />";
echo "Number of matches: ". $num_result ."<br />";
}
echo "<form action=\"addCouple.php\"><input type=\"submit\" value=\"Add\"></form><br />\n";
echo "<form action=\"admin1.php?action=view_all\" method=\"post\">\n";
echo "<TABLE WIDTH=\"750\" BORDER=\"1\" CELLPADDING=\"2\">\n";
echo "<form action=\"". $_SERVER['PHP_SELF'] ."?action=view_all\" method=\"post\">\n";
echo "<TR><TH>Bride</TH><TH>Groom</TH><TH>Event Date</TH><TH>Shipping Address</TH><TH>Edit</TH><TH>Delete</TH></TR>\n";
for($i=0; $i < $num_result; $i++){
$row = mysql_fetch_array($result);
echo "<TR><TD align=\"center\">". $row['brideFname'] ." ". $row['brideLname'] ."</TD><TD align=\"center\">". $row['groomFname'] ." ".
$row['groomLname'] ."</TD><TD align=center>". $row['event_month'] ."/". $row['event_day'] ."/". $row['event_year'] .
"</TD><TD align=\"center\">". $row['ship_add'] .", ". $row['ship_city'] .", ". $row['ship_state'] .", ". $row['ship_zip']
."</TD><TD align=\"center\" width=\"125\"><A HREF=\"editCouple.php?editID=". $row['uID'] ."\">Couple</A> / <A HREF=\"updateRegistry.php?regID=".
$row['uID'] ."\">Registry</A></TD><TD align=\"center\"><input type=\"checkbox\" name=\"delete[]\" value=\"". $row['uID'] ."\"></TD></TR>\n";
$_POST['editID'];
$_POST['regID'];
}
echo "</TABLE>\n";
}
echo "<p align=\"right\"><input type=\"submit\" value=\"Delete\">\n";
echo "</form></p>\n";
mysql_close($db);
?>