Jump to content

theref

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

theref's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Many thanks. I added the following $checkbox = $_POST['checkbox']; and changed $delete to be $_POST['delete'] and everything works as expected. Many thanks for all your replies
  2. Thanks for that. I corrected the <?php ?> tags but unfortunately that didn't help. With ini_set('display_errors', 'On'); error_reporting(E_ALL); in my page I get the following notice: Notice: Undefined variable: delete in /home/planetca/public_html/refapp/admin/delmess.php on line 77 Does this have anything to do with the page not working? Interestingly the page worked before my web host upgraded to php/mysql 5.x
  3. Hi Please could anyone have a look at the code below and help me figure out why it is not working. A user should be able to tick a box at the side of a row in the results of the query, then click the submit button. The expected outcome is that the selected row is deleted from my db, the page is refreshed and the previously selected row does not appear (because it has been deleted). However the row is not deleting. Please help. Many thanks in advance. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!-- Get Settings Info --> <?php require_once ('../includes/settings.php'); ?> <?php require_once ('../includes/language_en.php'); ?> <head> <link rel="stylesheet" type="text/css" href="<?php echo $stylesheet ?>" /> <?php //define db variables $DBhost = $dbhost; $DBuser = $dbuser; $DBpass = $dbpass; $DBName = $dbname; //define table name for sql query $table = $prefix."messages"; //DBhost connection mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database"); mysql_select_db("$DBName") or die("Unable to select database $DBName"); //define sql query $sql="SELECT *,date_format(date_from, '%d-%m-%Y') as date_from, date_format(date_to, '%d-%m-%Y') as date_to FROM $table order by message_id DESC"; //execute sql query $result=mysql_query($sql); //count rows of result of sql query $count=mysql_num_rows($result); ?> <title><?php echo $league_name ?> - <?php echo $ref_message ?></title> </head> <body> <fieldset><legend><?php echo $delete_message ?></legend> <form method="post" action=""> <table border="1"> <tr> <td> </td> <td><strong><?php echo $ref_message_id ?></strong></td> <td><strong><?php echo $messages ?></strong></td> <td><strong><?php echo $message_date_from ?></strong></td> </tr> <?php //echo result of sql query while($rows=mysql_fetch_array($result)){ ?> <tr> <td><input name="checkbox[]" type="checkbox" value="<?php echo $rows['message_id']; ?>" /></td> <td><?php echo $rows['message_id']; ?></td> <td><?php echo $rows['message']; ?></td> <td><?php echo $rows['date_from']; ?></td> </tr> <?php } ?> <tr> <td colspan="7"><input name="delete" type="submit" id="delete" value="<?php echo $delete_checked_message ?>" /></td> </tr> <? // Check if delete button active, start this if($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $del_id = mysql_real_escape_string($del_id); $sql = "DELETE FROM $table WHERE message_id='$del_id'"; $result = mysql_query($sql); } //close mysql connection mysql_close(); // if successful redirect to delmess.php if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=", $admin , "delmess.php\">"; } } ?> </table> </form> </fieldset> <table> <tr> <td><a href="<?php echo $admin ?>index.php"><?php echo $go_to_admin ?></a></td> </tr> </table> <div id="admin_footer"> <table> <tr> <td><br /> <p> <a href="http://validator.w3.org/check?uri=referer"> <img src="<?php echo $ref ?>images/valid-xhtml10-blue.png" alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a> <a href="http://jigsaw.w3.org/css-validator/check/referer/"> <img style="border:0;width:88px;height:31px" src="<?php echo $ref ?>images/valid-css-blue.png" alt="Valid CSS!" /></a> </p> </td> </tr> <tr> <td> <p> <script type="text/javascript"> <!-- today=new Date(); y0=today.getFullYear(); --> </script> Ref App - <?php echo $version ?> © <a href="mailto:"></a> 2006 - <script type="text/javascript"> <!--- document.write(y0); --> </script> </p> </td> </tr> </table> </div> </body> </html>
  4. Hi all I have a question which i'm sure is easy to answer, but I can't solve it. Please help. I have data in the following mysql tables: referee (name, ref_id), games(team_1, team_2, venue, date, competition), official(game_id, ref_id, official_type), official_type(name_id, name). The links between the tables are: games.game_id - official.game_id official.official_type - official_type.name_id official.ref_id - referee.ref_id In the official table there can be up to four rows with the same game_id but all with different official_type's (1,2,3, or 4) which are drawn from official_type.name_id I want to be able to display the following in a php page all on one row, and make it repeat according to the number of rows in the games table: games.game_id, games.team_1, games.team_2, games.venue, games.date, games.competition, referee.name (where official type = 1), referee.name (where official_type = 2), referee.name (where official_type = 3), referee.name (where official_type = 4) So my query is something like (thanks to MS Access - so it may be wrong!) "SELECT ref_games.game_id, ref_games.team_1, ref_games.team_2, ref_games.venue, ref_games.date, ref_games.competition, ref_official.official_type, ref_referee.name FROM ((ref_games INNER JOIN ref_official ON ref_games.game_id = ref_official.game_id) INNER JOIN ref_officialtype ON ref_official.official_type = ref_officialtype.name_id) INNER JOIN ref_referee ON ref_official.ref_id = ref_referee.ref_id WHERE (((ref_games.game_id)=ref_official.game_id) AND ((ref_official.ref_id)=ref_referee.ref_id))"; Many thanks in advance
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.