Jump to content

woolyg

Members
  • Posts

    254
  • Joined

  • Last visited

    Never

Everything posted by woolyg

  1. Thanks for that - much obliged. -Woolyg.
  2. Hi all, I'd like to be able to display mypage.php?categoryid=1, and I got that working ok. However, when I now try to just go to mypage.php on its own, I get an error (supplied argument is not a valid mySQL resource). Here's the code: if(isset($_GET['categoryid']) && !empty($_GET['categoryid'])){ $q = "SELECT * FROM `doc_content` WHERE `categoryid`=".$_GET['categoryid']; $r = mysql_query($q); $categoryid = $_GET['categoryid']; } while($row = mysql_fetch_array($r)){ echo $row['id']; echo $row['categoryid']; echo $row['question']; echo $row['answer']; } ..do I need to add something in for the standard page to display normally? Wooly
  3. Ahhhh I found it guys - One of my columns on the table was called 'group' - mySQL thought I was using the command 'GROUP' - I've changed the column name and it goes in fine.. Wooly
  4. Just get an error 1064 when I put in the mysql error handling - I know my syntax is incorrect.. Form code: <body> <form name="submitdoco" id="submitdoco" method="post" action="submitdoco.php"> <table width="100%" border="0"> <tr> <td>Username here </td> </tr> <tr> <td><select name="group" class="pg" id="group"> <option value="Rules" selected="selected">Rules</option> <option value="Club">Club</option> <option value="Other">Other</option> </select> Subject Group </td> </tr> <tr> <td><input name="title" type="text" class="pg" id="title" size="40" maxlength="255" /> Document Title </td> </tr> <tr> <td><input name="caption" type="text" class="pg" id="caption" size="40" maxlength="255" /> Caption (for quick & easy search reference) </td> </tr> <tr> <td><textarea name="full_body" cols="120" rows="10" class="pg" id="full_body">Main document body goes here. Try to be consice and to the point.</textarea></td> </tr> <tr> <td><input name="Submit" type="submit" class="pg" value="Submit for publishing" /></td> </tr> </table> </form> </body> And here's the processing PHP, after DB connection: <? $group = $_POST['group']; $title = $_POST['title']; $dts=time(); $timestamp=date('l M dS, Y, H:i:s'); $caption = $_POST['caption']; $full_body = $_POST['full_body']; $query = "INSERT INTO documentation (id, full_body, caption, timestamp, dts, title, group) VALUES ('null', '$full_body', '$caption', '$timestamp', '$dts', '$title', '$group')"; mysql_query($query) or die ("The document could not be added - ".mysql_errno()." - please contact the documentation administrator"); echo "Went in OK"; ?> For some reason it's not accepting the data from the dropdown part of the form. I've doublechecked all spelling..
  5. Hey all, I have a simple form, with a dropdown menu as one of the sources of data. Sources: Title (textfield) Group (dropdown menu) Body (textfield) In the processing PHP file, i connect to the db and specify <? $title = $_POST['title']; $group = $_POST['group']; $body = $_POST['body']; $query="INSERT INTO documentation (title, group, body) VALUES ('$title', '$group', '$body')"; mysql_query($query) or die ("That did not work"); ?> ..but the problem lies in trying to insert the group dropdown selection into the DB - when I remove it from the insert command, the data inserts OK. Have I used $_POST incorrectly? Cheers, Woolyg
  6. It's only ever 2 rows (or 2 corresponding values in 2 rows) - I would like to basically use such a utility to show which row entry has the greater value. Example table: Row | Name | Age | Salary 1. | John | 26 | 55000 2. | Henry | 28 | 60000 - I'd like to specify it to show which Age and Salary is higher, or a graphical interpretation of the same (I'll be using it for rows that have up to 200 columns, so manually checking it won't be possible:) )
  7. Hi all, Just a non-urgent conversation piece more than anything: I'm looking around for some sort of app/utility that will take data from 2 rows in a MySQL table, and compare them, populating a visual or numeric report on the data. Has anyone here ever used/seen/developed such an app? I'd be mighty interested in hearing from anyone that has. Cheers all, Woolyg
  8. eh? I just used the code button.. but thanks a million for that - I am learning, slowly but surely.. Woolyg
  9. Noobie Q here, but I just couldnt find it anywhere..! Say if I ran a query that called all rows from a table: $display = mysql_query("SELECT * FROM table"); $show = mysql_fetch_array($display); And that returned ID Name Surname Level 1 John Smith 10 2 Barry Manilow 8 3 James Brown 6 ...how would I form the PHP to display all of the above info in bold? Can someone help? I'm embarrassingly noobalicious.
  10. To explain above: The query returns a row, from which I select returned values 1, 2, 3 and 4 If $show[1] returned the value 5, I'd like to display the word "Useless" If $show[2] returned the value 15, I'd like to display the word "Average" If $show[3] returned the value 25, I'd like to display the word "Awesome" .. get me? I hope my code-addled brain is able to explain properly..
  11. Cool, thanks guys - I'll put it into practise and see what I can come up with. Do you think this would work for multiple populated numbers? Say, if I had a table with a number of entries that I was calling: ID Name Value1 Value2 Value3 1 Woolyg 14 7 28 and used $query = mysql_query(SELECT * FROM table"); $show = mysql_fetch_ros($query); if($show){ echo "$show[1]<br>"; echo "$show[2]<br>"; echo "$show[3]<br>"; echo "$show[3]<br>"; } ..would that work? - And additionally, would I be able to use the same code barand posted above and link it to a different query?
  12. Hi all, I've got a function in PHP that calls values from a MYSQL DB, and it returns numbers. (eg. - Woolyg - 14) Is there a way in PHP to substitute these numbers for worded values? So say if the function returned values 1-10 it displays the word 'Useless'... 10-20 displays 'Average'... and 20-30 displays 'Awesome'..? Anyone got any idea? Cheers, Woolyg
  13. Sorry for the confusion. I want to achieve a table of 20 players from a certain team to be populated, displayed by number. If I select all players from a certain team, it displays their stats fine. When I try to incorporate numbering their entries from 1 to 20, thats where I'm hitting the wall..
  14. Thanks, I've pared it down to the following code: SELECT * FROM counttotwenty INNER JOIN player_stats WHERE player_stats.player_statsTeamID='1'; ..and what I'm getting is this: But what I'd really like is this (excuse the patched together image): ..showing player details in columns 2-15 for 20 rows, with the numbers 1-20 in column 1. So basically, I'd like not to have duplicated player entries. All info appreciated again - thanks. Woolyg
  15. MySQL client version: 5.0.33 Statement: REPLACE INTO teamdata_table1 (Number, TeamPlayerID, player_statsFirstname, player_statsLastname, player_statsAge, player_statsFitness, player_statsSpeed, player_statsStrength, player_statsHandling, player_statsAttacking, player_statsTackling, player_statsTactics, player_statsPassing, player_statsImage, player_statsTeamID) SELECT counttotwenty.number, player_statsID, player_statsFirstname, player_statsLastname, player_statsAge, player_statsFitness, player_statsSpeed, player_statsStrength, player_statsHandling, player_statsAttacking, player_statsTackling, player_statsTactics, player_statsPassing, player_statsImage, player_statsTeamID FROM player_stats, counttotwenty WHERE player_stats.player_statsTeamID='1'; Hi all, What I wanna do with the above code is refresh a table (teamdata_table1) with information from tables player_stats and counttotwenty. Table counttotwenty is one column - the numbers 1 to 20. Table player_stats is the statistics of 20 players - 14 columns. Table teamdata_table1 is a mixture of both, with 15 columns - the column from counttotwenty marking the player number in column 1, and columns 2-14 are the player data. When I run the query, it runs OK, and displays the info from table counttotwenty (ie, a column showing numbers 1 to 20) but the rest of the table only shows info from player with playerstatsID of 20. All I would like to do is pack everything from the 2 tables into teamdata_table1, and have it refresh each time I run the script. Can anyone see what I'm doing incorrectly? All help appreciated! Cheers - woolyg
  16. Beautiful. Thanks a million HeyRay2!
  17. I'm trying to use the following: <?php $no = array (1,2,3,4,5,6,7,8,9); if ($_GET['lookup'] == $no) { //conect to database $result = mysql_query("SELECT * FROM table_1 WHERE id='$no"'); $row = mysql_fetch_row($result); echo "ID: $row[0]<br>"; echo "ID: $row[1]<br>"; } ?> .. but it's not displaying when a user goes to http://localhost/players.php?lookup=2 Is it possible to specify an array variable in this manner (where I've specified $no and used it to look up the id of the table)..?
  18. Thanks bobleny, I'll put that into practise and see how I get on. I'm mainly looking to short-circuit having to manually enter variable details. I have a single mySQL table with 12 columns and 950 rows, sorted by ID. What I'd like to do is display this: User enters URL http://localhost/players.php?lookup=23 Page Displays the following: - player name (column 2 of row 23) - player age (column 3 of row 23) - etc ...I shall continue! If you have any pointers, let me know. Woolyg
  19. Hi, I have almost 1000 entries on a table in a MySQL DB. What I want to do is to display items from a row, depending on the URL. For Example, I want this url: http://localhost/players.php?lookup=23 to display certain attributes set into the table (ID,Firstname,Lastname), etc. I'm using the following code for http://localhost/players.php?lookup=23 and it's not working: <?php include("maincore.php"); //maincore is connecting to the mySQL DB. global $lookup; $result = mysql_query("SELECT * FROM player_stats WHERE player_statsid='$lookup'"); $row = mysql_fetch_row($result); echo "Name: $row[1]<br>"; ?> When I use this code for http://localhost/players.php and it functions fine: <?php include("maincore.php"); $result = mysql_query("SELECT * FROM player_stats WHERE player_statsid='1'"); $row = mysql_fetch_row($result); echo "Name: $row[1]<br>"; ?> Can anyone tell me how I can define the content of a page depending on the lookup value in the URL? Cheers Woolyg
  20. Thanks dsaba, I'm on the right track now, all of the form processing was pointing in at itself. I've divided the pages into 'form fill-out' and 'form processing' now. Thank you very much for all your help everyone. Woolyg
  21. Hey all, I'm not sure if anyone is following this at this stage, but I'll document it anyway, see if anyone can help. I'm running the code: $formid = "2"; $userid = $userdata['user_name']; $query = "INSERT INTO forms VALUES ('$formid','$userid')"; mysql_query($query); mysql_close(); with this code: $query1 = mysql_query("SELECT * FROM forms WHERE formid='$formid' AND userid='$userid'"); if (!$query1) { echo 'Could not run query: ' . mysql_error(); exit; } $row = mysql_fetch_row($query1); if ($row == TRUE) { echo "You have already folled out this form"; } else { echo "You have NOT filled this form out - Please do so!"; } - so that a query is run when a user gets to a page, telling them whether they have filled out a form or not. What I'm finding is that if they do NOT go ahead and fill out the form at that time, and decide to leave the page and return to it, the PHP page sends the formid and userid data to the MySQL DB (from the code in the top query, above) when they refresh the page. So basically the page tells them they have filled the form out, when they have only visited that page. (Looks like I've coded a 'you have already visited this page' script!) I shall battle onwards. If anyone can see what I'm doing wrong, then please let me know! Woolyg
  22. Thanks for your help everyone - ALMOST there! - I've created a table with 2 fields - formid and userid - formid and userid are variables set into the PHP page - each column of the table is populated when users fill out the form eg: FORMID | USERID _______________ 1 | woolyg 1 | admin 2 | JohnP Now, if woolyg returns to the page with the form of formid "1" on it, I'd like a message to display saying 'you have already filled out this form' Could someone help me with that query please? I really appreciate all your help so far.. Woolyg
  23. Thanks Greaser9780, In test: echo $userid; - Works, it displays the userid on the page echo $formid; - Does not work - it displays blank I have specified formid in a hidden value of the form: <input type='hidden' name="formid" value="1" /> .. but the echo is not displaying the specified variable value for it. I'm perplexed! any ideas?
  24. On the page I have: $formid = $_POST['formid']; $userid = $userdata['user_name']; (Where $userdata['user_name'] is the nickname of the user, as defined by their signup & login) and under that: <form name='userform' method='post' action='".FUSION_SELF."'> <input type='hidden' name='formid' value='1'> ..Is the above correct? I have created a 'forms' table and populated it with 2 columns - formid and userid. - How do I know that the formid and userid values are being posted to the 'forms' table? Woolyg
  25. Thanks for that dsaba The thing is, I have no idea how i would even begin coding what i need! - I have a way of identifying userid - I can trawl through the PHP for how the PHPfusion installation identifies that - I can give the forms identifying tags within the html coding of them .. but how would I go about creating the code to get the DB to log if a form has been filled out? -Woolyg
×
×
  • 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.