Jump to content

thunderstorm654

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

thunderstorm654's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. hi, yea still got problems, tried what you saidbut that didnt work either, drop down was empty. atm have the drop down populated correctly, but if u select anything, it gives erorrs Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\program files\easyphp1-8\www\test3.php on line 25 there is no data in table.. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\program files\easyphp1-8\www\test3.php on line 40 heres all my code with lines 25 and 40 highlighted bold , <?php require_once('connection.php'); if (!isset($_POST['submit']))#IT should be $_POST bcoz form method is POST. { $res=mysql_query("select race_name from race"); if(mysql_num_rows($res)==0) { echo "there is no data in table.."; } else { echo '<form action="test3.php" method="post"><select name="race">'; # this is the vlaue after posting we are using to retrieve values from DB. while($row = mysql_fetch_array($res,MYSQL_ASSOC)) { echo"<option value = $row[race_name] >$row[race_name]</option>"; # Here you missed value part in options } // endof while echo'</select><input type="submit" name="submit" value="submit" /> <input type="hidden" name="submitted" value="TRUE" /></form>'; } } elseif ((isset($_POST['submit']))) { $getrace = $_POST['race']; $res=mysql_query("select member.first_name,member.last_name,race.race_name,race.race_date,results.time from member,race,result WHERE race.race_name='".$getrace."'"); } [b]if(mysql_num_rows($res)==0) {[/b] echo "there is no data in table.."; } else { //table header echo'<table align="center" cellspacing="10" cellpadding="5"> <tr><td align="left">First Name</td> <td align="left">Last Name</td> <td align="left">Race Name</td> <td align="left">Race Date</td> <td align="left">Race Time</td></tr>'; echo'</select>'; } // fetch and print all the records [b]while($row = mysql_fetch_array($res,MYSQL_ASSOC)) {[/b] echo'<tr><td align="left">'.$row['first_name'].'</td> <td align="left">'.$row['last_name'].'</td> <td align="left">'.$row['race_name'].'</td> <td align="left">'.$row['race_date'].'</td> <td align="left">'.$row['time'].'</td> </tr> ';}echo'</table>'; ?> any ideas? also the table headings are showing on the page before selecting anything and submitting from the box, they shouldnt be should they?
  2. thanks for that, tried that, the drop down now just has one race name in it repeated 6 times, and the table has got that same race name printed on 6 rows, and before that there loads of php errors saying Notice: Undefined index: last_name in c:\program files\easyphp1-8\www\test2.php on line 44 and so on, basically for every single line in this bit: echo'<tr><td align="left">'.$row['first_name'].'</td> <td align="left">'.$row['last_name'].'</td> <td align="left">'.$row['race_name'].'</td> <td align="left">'.$row['race_date'].'</td> <td align="left">'.$row['time'].'</td> im guessing ive reffered to my fields wrong or something? cos theyre from different tables do i need to take that into account here? thanks for help:)
  3. ah didnt see ur bit there. well what im trying to do is (whether its done right or not, this is what the idea is!) 1) have a form with option box for race names. 2) check if the form has been submitted/ or that a race name has been selected and submit button pressed 3) if it has, display table below on same page with all the required data (thats where the long select query and table bits are) 4) if it hasn't (i.e. when the page loads), just display the drop down box by itself. hope that makes sense :S would i need to take the form out the first if and put it say at the bottom of the page on its own, then do the if bits above it?
  4. what does all this 'getting info from the url' mean? someone else said something about this but i really don't understand how you do this or what its doing?? thanks
  5. well i was trying to post to the same page but ive definitly done it wrong somewhere
  6. Hi, im trying to use a drop down box to select data from my tables in my database that relate to just one column, which populates the drop down. I'm trying to display a drop down box full of race names pulled from a race table in my database, and this works fine, they're all listed correctly. I want to then allow the user to select one, hit submit or whatever, then below, (OR on another page, I don't mind) in a table, display the member first and last names (from member table), the race date, length (from race table) and the result (from result table). At the moment I'm stuck as whatever u select nothing happens. I'm really confused about how to get the race name from the submitted drop down, do you use get or post or what?? Need a simple explanation of what ive done wrong, I KNOW its wrong but just cant figure out how to fix it, getting muddled ??? ! Thanks, and here's my code: <?php require_once('connection.php'); if (!isset($_GET['race'])) { $res=mysql_query("select race_name from race"); if(mysql_num_rows($res)==0) { echo "there is no data in table.."; } else { echo'<form action="bugger.php" method="post"><select name="categories">'; for($i=0;$i<mysql_num_rows($res);$i++) { $row=mysql_fetch_assoc($res); echo"<option>$row[race_name]</option>"; } // endof for echo'</select><input type="submit" name="submit" value="race" /> <input type="hidden" name="submitted" value="TRUE" /></form>'; } } elseif ((isset($_GET['race']))) { $getrace = $_GET['race']; $res=mysql_query("select member.first_name,member.last_name,race.race_name,race.race_date,results.time from member,race,result WHERE race.race_name='".$getrace."'"); } if(mysql_num_rows($res)==0) { echo "there is no data in table.."; } else { //table header echo'<table align="center" cellspacing="10" cellpadding="5"> <tr><td align="left"><b>First Name</b></td> <td align="left"><b>Last Name</b></td> <td align="left"><b>Race Name</b></td> <td align="left"><b>Race Date</b></td> <td align="left"><b>Race Time</b></td></tr>'; echo'</select>'; } // fetch and print all the records while($row = mysql_fetch_array($res,MYSQL_ASSOC)) { echo'<tr><td align="left">'.$row['first_name'].'</td> <td align="left">'.$row['last_name'].'</td> <td align="left">'.$row['race_name'].'</td> <td align="left">'.$row['race_date'].'</td> <td align="left">'.$row['time'].'</td> </tr> ';}echo'</table>'; ?> called the page bugger.php cos i can't get it working
  7. Well, cos it only says in the coursework spec about narrowing them down by race name, thats all i really want.. I'd like to have a entire table displaying of all the results, then a drop down above the table allowing the user to select a race name to narrow them down by that race name and just show those results.. e.g. a race called 'blah', choosing blah from the drop down would just list results for races wth the name blah. hope that made sense. thanks
  8. i know its not too bad, i have done the lot apart from number 4 on part 2 which is what I have been asking about. erm, its quite a lot (numerous pages), do you need to see all the code for the other sections? Here's my code for number 1 of part 2 (allowing users to modify their info..) modify_user.php: <?php session_start(); include('memberlogin.functions.php'); check_user(); $user = $_SESSION['valid_member']; require_once('connection.php'); $get_memberdetails_sql = "SELECT * FROM member WHERE email_address = '{$user}'"; $result = mysql_query($get_memberdetails_sql); $get_memberdetails_res = mysql_fetch_array($result); $first_name = $get_memberdetails_res['first_name']; $last_name = $get_memberdetails_res['last_name']; $gender = $get_memberdetails_res['gender']; $email_address = $get_memberdetails_res['email_address']; $address_line_one = $get_memberdetails_res['address_line_one']; $dob = $get_memberdetails_res['dob']; ?> <!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"> <head> <title>Incredible Shoes Running Club :: Update Your Details</title> <meta http-equiv="Content-Language" content="English" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="style.css" media="screen" /> </head> <body> <div id="wrap"> <div id="top"></div> <div id="content"> <div class="header"> <h1><a href="index.php">The Incredible Shoes Running Club</a></h1> </div> <div class="breadcrumbs"> <a href="index.php">Home </a> · <a href="admin_home.php">Administrators </a> · <a href="#">Members </a> · <b>Today's date is <?php echo date('D j F, Y ');?>· <a href="member_logout.php">Logout</a></b> </div> <div class="middle"> <h2>Welcome.</h2> <form action="do_modify_user.php" id="update" name="update" method="post"> <?php echo "Your Email Address: ".$user; ?> <p>First Name <input name="updateFirstName" type="text" id="updateFirstName" value = "<?php echo $first_name;?>"/> </p> <p>Last Name <input name="updateLastName" type="text" id="updateLastName" value = "<?php echo $last_name;?>"/>" </p> <p>Gender <input name="updateGender" type="text" id="updateGender" value = "<?php echo $gender;?>"/>" </p> <p>Email Address <input name="updateEmail" type="text" id="updateEmail" value = "<?php echo $email_address;?>"/>" </p> <p>Address Line One <input name="updateAddress" type="text" id="updateAddress" value = "<?php echo $address_line_one;?>"/>" </p> <p>Date of Birth (YYYY-MM-DD) <input name="updateDOB" type="text" id="updateDOB" value = "<?php echo $dob;?>"/>" </p> <input name="update" type="submit" id="update" value="Update Details" /> <input type="hidden" name="MM_UPDATE" value="updateForm" /> </p> <p align="center"> </p> </form> <br /> <hr /> <a href="index.php">Back to home page</a> </div> <div id="clear"></div> </div> <div id="bottom"></div> </div> <div id="footer"> Copyright Incredible Shoes Running Club 2007</a> </div> </body> </html> do_modify_user.php: <?php session_start(); include('memberlogin.functions.php'); check_user(); $user = $_SESSION['valid_member']; ?> <!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"> <head> <title>Incredible Shoes Running Club :: Update Your Details</title> <meta http-equiv="Content-Language" content="English" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="style.css" media="screen" /> </head> <body> <div id="wrap"> <div id="top"></div> <div id="content"> <div class="header"> <h1><a href="index.php">The Incredible Shoes Running Club</a></h1> </div> <div class="breadcrumbs"> <a href="index.php">Home </a> · <a href="admin_home.php">Administrators </a> · <a href="#">Members </a> · <b>Today's date is <?php echo date('D j F, Y ');?>· <a href="member_logout.php">Logout</a></b> </div> <div class="middle"> <h2>Modify Your Details.</h2> <?php require_once('connection.php'); $first_name = $_POST["updateFirstName"]; $last_name = $_POST["updateLastName"]; $gender = $_POST["updateGender"]; $email_address = $_POST["updateEmail"]; $address = $_POST["updateAddress"]; $dob = $_POST["updateDOB"]; $sqlquery = "UPDATE member SET first_name='$first_name',last_name = '$last_name', gender = '$gender', address_line_one = '$address', dob = '$dob' WHERE email_address = '$user'"; $update_result = mysql_query($sqlquery); if($update_result) { // if update was successful, echo '<h2 id="mainhead">Thank you!</h2> <p>Your details were updated successfully.</p> <p><a href="admin_home.php">Back to Administrator Home></p>'; } else { // if it did not insert ok echo '<h2 id="mainhead">Error</h2> <p class="error">Your details were not updated successfully due to a system error, please go back and try again.</p>'; echo '<p>' . mysql_error() . '<br /><br />Query: ' . $query_update . '</p>'; // debugging message } ?> </div> <div id="clear"></div> </div> <div id="bottom"></div> </div> <div id="footer"> Copyright Incredible Shoes Running Club 2007</a> </div> </body> if you want to see any other part then let me know... i know its not very good, but tbh our lecturer is shit and wont notice far from perfect coding, as long as I can get the last bit working I don't mind..
  9. Okay I have attached it, unfortunately is a pdf. I have done everything apart from the last bit- Part 2, Number 4., on page 3 of the pdf file. The way I am trying to do it is not necessarily the only way, I just thought it would be the nicest to allow for both parts of that section- viewing results and allowing members to view results of certain races. Cheers [attachment deleted by admin]
  10. I guess don't really need the three, but unfortunately got to keep them.
  11. oh right sorry, No idea, its coursework for uni and we got told the tables and aren't allowed to changed them, so its my lecturers fault!
  12. sorry i think i must have been a bit confusing- i only want one table on the page yes, but the data inside the single table will come from 3 tables in the database.
  13. Hi, i've got three tables, member, race and results. Member primary key is member_no, race is race_no and results is a composite of race_no and member_no. Basically I want a page where users can view race results - i.e. show the members first name and last name (from member table), the race name, race date, race length (from race table), and the result (which is a time, from results table). I want to display all this as column headings and output the relevant data just in a table. BUT, i want to allow the user to be able to view results for certain races, so i thought having a drop down box with race names in then somehow reloading the page and displaying just results for that race name would be the most suitable way. All i've managed to do so far is get a drop down box with the race names in however - eek! i have done the join query yet to get all the data as I was experiementing, i selected everything from race table and stuck the race_name in the combo box, but do i just output the other fields into rows or something in the table? how?? this is my miniscule amount of code so far.. <?php require_once('connection.php'); echo'<select name="categories">'; $res=mysql_query("select * from race"); if(mysql_num_rows($res)==0) echo "there is no data in table.."; else for($i=0;$i<mysql_num_rows($res);$i++) { $row=mysql_fetch_assoc($res); echo"<option>$row[race_name]</option>"; } echo'</select>'; ?> How can i go about making this page how I want? This has been confusing me for days as it surely can't be that hard, i've searched online for hours but not found anything just like i want. Thanks
  14. I have got a login system using sessions, and wanted to have a page where once the user is logged in, they can see and change/edit their details. I have currently got two pages, modify_user.php and do_modify_user.php to try and do this, but i keep getting an error on do_modify_user.php that the query was empty. Below is the code for do_modify_user.php: <?php session_start(); include('login.functions.php'); check_user(); $user = $_SESSION['valid_user']; require_once('connection.php'); $first_name = $_POST["updateFirstName"]; $last_name = $_POST["updateLastName"]; $gender = $_POST["updateGender"]; $email_address = $_POST["updateEmail"]; $address = $_POST["updateAddress"]; $dob = $_POST["updateDOB"]; $query_update = mysql_query("UPDATE member SET first_name = ".$first_name.", last_name = ".$last_name.", gender = ".$gender.", address_line_one = ".$address.", dob = ".$dob." WHERE email_address = '{$user}'"); $update_result = mysql_query($query_update); if($update_result) { // if update was successful, echo '<h2 id="mainhead">Thank you!</h2> <p>Your details were updated successfully.</p> <p><a href="admin_home.php">Back to Administrator Home></p>'; } else { // if it did not insert ok echo '<h2 id="mainhead">Error</h2> <p class="error">Your details were not updated successfully due to a system error, please go back and try again.</p>'; echo '<p>' . mysql_error() . '<br /><br />Query: ' . $query_update . '</p>'; // debugging message } ?> it does not update anything (checked in the database), and the page just says Error Your details were not updated successfully due to a system error, please go back and try again. Query was empty Query: I'm not sure if you need to see the code for modify_user.php or not, so pasted it below anyway, i've put the html in thats for the layout of my site so ignore those bits...: modify_user.php: <?php session_start(); include('login.functions.php'); check_user(); $user = $_SESSION['valid_user']; require_once('connection.php'); $get_memberdetails_sql = "SELECT * FROM member WHERE email_address = '{$user}'"; $result = mysql_query($get_memberdetails_sql); $get_memberdetails_res = mysql_fetch_array($result); $first_name = $get_memberdetails_res['first_name']; $last_name = $get_memberdetails_res['last_name']; $gender = $get_memberdetails_res['gender']; $email_address = $get_memberdetails_res['email_address']; $address_line_one = $get_memberdetails_res['address_line_one']; $dob = $get_memberdetails_res['dob']; ?> <!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"> <head> <title>Incredible Shoes Running Club :: Update Your Details</title> <meta http-equiv="Content-Language" content="English" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="style.css" media="screen" /> </head> <body> <div id="wrap"> <div id="top"></div> <div id="content"> <div class="header"> <h1><a href="index.php">The Incredible Shoes Running Club</a></h1> </div> <div class="breadcrumbs"> <a href="index.php">Home </a> · <a href="admin_home.php">Administrators </a> · <b>Today's date is <?php echo date('D j F, Y ');?>· <a href="logout.php">Logout</a></b> </div> <div class="middle"> <h2>Add Race Results.</h2> <form action="do_modify_user.php" id="update" name="update" method="post"> <?php echo "Your Email Address: ".$user; ?> <p>First Name <input name="updateFirstName" type="text" id="updateFirstName" value = "<?php echo $first_name;?>"/> </p> <p>Last Name <input name="updateLastName" type="text" id="updateLastName" value = "<?php echo $last_name;?>"/>" </p> <p>Gender <input name="updateGender" type="text" id="updateGender" value = "<?php echo $gender;?>"/>" </p> <p>Email Address <input name="updateEmail" type="text" id="updateEmail" value = "<?php echo $email_address;?>"/>" </p> <p>Address Line One <input name="updateAddress" type="text" id="updateAddress" value = "<?php echo $address_line_one;?>"/>" </p> <p>Date of Birth (YYYY-MM-DD) <input name="updateDOB" type="text" id="updateDOB" value = "<?php echo $dob;?>"/>" </p> <input name="update" type="submit" id="update" value="Update Details" /> <input type="hidden" name="MM_UPDATE" value="updateForm" /> </p> <p align="center"> </p> </form> </div> <div id="clear"></div> </div> <div id="bottom"></div> </div> <div id="footer"> Copyright Incredible Shoes Running Club 2007</a> </div> </body> </html> Apologies for the hefty amounts of code, it appears to be do_modify_user.php that is causing me the problem , any ideas? im not very experienced with php and mysql, so I've probably done something obviously wrong with the update query but I just can't see what Any help greatly appreciated
  15. ok, it just says MY SQL: SELECT race_no FROM race WHERE race_name = 'Stratford Half' AND race_date = '2006-04-25' ----END----
×
×
  • 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.