solon Posted October 18, 2008 Share Posted October 18, 2008 hey guys, i am new to this forum so i apologize if this is not the correct section. I am trying to display records from a table but when the records are displayed the first record is not being displayed and it starts from the second. I should tell you that the records i try to display are data that are just inserted in the table so its kind of ("insert this" reload page "display this". Its a bit urgent so i would really appreciate a fast response , Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/128955-php-mysql-records-display-problem/ Share on other sites More sharing options...
JasonLewis Posted October 18, 2008 Share Posted October 18, 2008 Please show some relevant code. Try running the query in phpMyAdmin to see if they are the records that you are after. Quote Link to comment https://forums.phpfreaks.com/topic/128955-php-mysql-records-display-problem/#findComment-668568 Share on other sites More sharing options...
solon Posted October 18, 2008 Author Share Posted October 18, 2008 This is the code for the insertion of the records: session_start(); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Connect to mysql server $link = mysql_connect(host, usrnm); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db('db'); if(!$db) { die("Unable to select database"); } $event = $_POST["event"]; $bet = $_POST["bet"]; $winnings = $_POST["winings"]; $member_id = $_SESSION['SESS_AGENT_ID']; $agent_id = $_SESSION['SESS_MEMBER_ID']; $session_id = session_id(); //Check for duplicate login ID if($event != '') { $qry = "SELECT * FROM `coupons` WHERE `event` = '$event' && `session_id` = '$session_id'"; $result = @mysql_query($qry); if($result) { if(mysql_num_rows($result) > 0) { $errmsg_arr[] = 'You already placed this bet'; $errflag = true; ?> <script> alert('You already placed this bet'); window.location = "game-show.php" </script> <?php } mysql_free_result($result); } else { die("Query failed"); } } //Create INSERT query $qry = "INSERT INTO `coupons`(event, bet, winings, member_id, agent_id, session_id) VALUES('$event','$bet','$winnings','$member_id','$agent_id','$session_id')"; $result = mysql_query($qry); if($result) { ?> <script> alert('Bet placed succesfully'); window.location = "game-show.php" </script> <?php //header("location:game-show.php"); } else { die("Query Failed"); } This is the code i use to display the records: //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Connect to mysql server $link = mysql_connect(host, usrnm); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db('db'); if(!$db) { die("Unable to select database"); } echo "<td><input type='text' name='bets' value='1' onchange='window.reload(true)' /></td>"; $total =1; $bets = $_POST['bets']; $result = mysql_query("SELECT * FROM `coupons` WHERE `session_id` = '$session_id'"); if ($result >= 1) { $row = mysql_fetch_array($result); while($row = mysql_fetch_array($result)) { echo "<tr> <td>$row[event]</td> <td>$row[bet]</td> <td>$row[winings]</td> </tr>"; $total *= $row[winings]; } echo"<td></td><td><b>Total</b></td><td>$total</td></tr>"; } else { echo "Query Failed"; } ?> Edit - [ code ] tags added. Please use them when posting code Quote Link to comment https://forums.phpfreaks.com/topic/128955-php-mysql-records-display-problem/#findComment-668593 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.