AnyoneThere Posted February 22, 2011 Share Posted February 22, 2011 Hi Guys, I am a bit of a PHP noob and I am hoping for a bit of help. My deadline to have this working is tomorrow. Basically I want to display a table which shows all the events I have signed upto. However, my code is creating windows within itself and separate tables which are all over the place. Here is my code: <?php session_start(); $email = $_SESSION['email']; include '../dbconn.php'; include '../includes/functions2.php'; $query2 = "SELECT * FROM billing where email='$email'"; $result2 = mysql_query($query2); $num_rows = mysql_num_rows($result2); while($row2 = mysql_fetch_array($result2, MYSQL_ASSOC)) { $query3 = "SELECT * FROM events where id='$row2[eventid]'"; $result3 = mysql_query($query3); while($row3 = mysql_fetch_array($result3, MYSQL_ASSOC)) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <link rel="shortcut icon" href="../images/favicon.ico"> <meta http-equiv="Content-Type" content="text/html; charset=iso8859-1" /> <meta name="keywords" content="Ghost Hunts, Ghost Hunting, Ghost Hunt Suppers, Overnight Ghost Hunt, Haunted Nights, Ghost Hunting Weekends, Paranormal Events, Most Haunted Tours, Most Haunted, Haunted Places, Anyone There?, Fright Nights, Haunted Happenings, Haunted Gatherings, The Hoff, Scott Mills, Yvette Fielding" /> <meta name="description" content=" Paranormal team, organising ghost hunts accross the UK. With many famous guests, only at Anyone There?" /> <link href="style.css" rel="stylesheet" type="text/css" /> <title>Anyone There :. Haunted Experiences</title> </head> <script LANGUAGE="JavaScript" SRC="overlib.js"></script> <body> <div id="container"> <div id="header"> </div> <div id="nav"> <ul> <li><a href="cprotected.php" class="selected" title="Events">My Events</a></li> <li><a href="feedback.php">Feedback</a></li> <li><a href="index.php">Logout</a></li> </ul> </div> <div id="content"> <div id="page"> <h2><?php echo "Welcome $row1[fname] $row1[sname]"; ?></h2> <br> <h2> <?php echo "Showing $num_rows events. . ."; ?> </h2> <center> <p> <?php $deposit=$row2[quantity]*10; $total=$row2[quantity]*$row2[ticketprice]; $cancel='http://www.anyonethere.co.uk/main/cprotected.php'; $paid='http://www.anyonethere.co.uk/main/paid.php'; echo " <center> <table width='800' class='reference'> <tr> <th>Venue</th> <th>Date</th> <th>Total Price</th> <th>Deposit</th> <th>Remaining</th> <th>Ticket Quantity</th> <th>Status</th> </tr> "; if ($row2[status]=='0') { echo "<tr>"; echo "<td>$row3[venue]</td> "; echo "<td>$row3[date]</td> "; echo "<td>£$total</td> "; echo "<td>£$deposit</td> "; echo "<td>£$row2[owe]</td> "; echo "<td>$row2[quantity]</td> "; echo "<td>Pay Deposit</td></tr>"; } elseif ($row2[status]=='1') { echo "<td>$row3[venue]</td> "; echo "<td>$row3[date]</td> "; echo "<td>£$total</td> "; echo "<td>£$deposit</td> "; echo "<td>£$row2[owe]</td> "; echo "<td>$row2[quantity]</td> "; echo "<td bgcolor='orange'>PAY OUTSTANDING BALANCE</td></tr>"; } elseif ($row2[status]=='2') { echo "<td>$row3[venue]</td> "; echo "<td>$row3[date]</td> "; echo "<td>£$total</td> "; echo "<td>£$deposit</td> "; echo "<td>£$row2[owe]</td> "; echo "<td>$row2[quantity]</td> "; echo "<td bgcolor='green'>Paid</td></tr>"; }}} echo "</table>"; ?> </p> </div> <div class="clear"></div> </div> <div id="footer"> <p>© 2011 Anyone There: The UK's #1 for Haunted Events</p> </div> </div> </body> </html> Please can somebody give me a pointer in the right direction, it will be a life saver? Thanks in Advance, Dan Quote Link to comment Share on other sites More sharing options...
AnyoneThere Posted February 22, 2011 Author Share Posted February 22, 2011 Any help would be really appreciated guys Quote Link to comment Share on other sites More sharing options...
RussellReal Posted February 22, 2011 Share Posted February 22, 2011 everytime you loop you echo a new "<html>" block.. put the loop where the tables are Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 22, 2011 Share Posted February 22, 2011 Users should not "bump" topics that are still on the first page of the forums. If you bump, you must provide additional information. If you resort to bumping, chances are your question needs to be re-thought and re-described (see Eric Raymond's "How To Ask Questions The Smart Way"). Users will not mark their post as being "URGENT" by either making the post ALL CAPS or adding any hint that they need it done Quick or ASAP. All posts are treated equal, your post is no more important than any other user's post on this forum. If it is "URGENT" pay someone to do it. Quote Link to comment Share on other sites More sharing options...
AnyoneThere Posted February 22, 2011 Author Share Posted February 22, 2011 Sorry for the bump guys :'( Please can you explain further what I need to do? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted February 22, 2011 Share Posted February 22, 2011 Look at the output HTML, View Source. You'll see the top of the HTML is repeated because it's in the while loop. You need to move out of the while loop the parts of the HTML that should only occur once, like the html tag, head, script, body, etc. Quote Link to comment Share on other sites More sharing options...
AnyoneThere Posted February 22, 2011 Author Share Posted February 22, 2011 I know this sounds really dumb, any chance you could change my above code for me??? Quote Link to comment Share on other sites More sharing options...
RussellReal Posted February 22, 2011 Share Posted February 22, 2011 Hey dude, I gave you the solution to your problem.. You could sit here waiting (hopefully) for someone to willingly fix your code for you, or you could attempt to fix it, come back if it doesn't work, and update the post Quote Link to comment Share on other sites More sharing options...
AnyoneThere Posted February 22, 2011 Author Share Posted February 22, 2011 Sorry mate, not being a lazy bas*****, just been trying to get this working all day lol and it's really getting to me now Quote Link to comment 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.