[PHP-DB] editing, deleting records
Here's a part of my code, which is retrieving player records from mysql and displaying them in a table: - if($queryChk3 !== 0){ print(form action='$_SERVER['PHP_SELF']' method='POST' input type='hidden' name='teamID' value='$teamID' input type='hidden' name='pwd' value='$pwd' table border='1'tr td colspan='7'bPlayer Roster for $teamName/b/td/tr trtdbLast Name/b/tdtdbFirst Name/b/td tdbDOB/b/tdtdbTelephone/b/td tdbAddress/b/tdtdbEmail/b/td tdbSex/b/td/tr); while($row = mysql_fetch_array($query3)) { print(tr); $lname = $row['lname']; $fname = $row['fname']; $dob = $row['dob']; $phone = $row['phone']; $address = $row['address']; $email = $row['email']; $sex = $row['sex']; print(td . $lname . /tdtd . $fname . /tdtd . $dob . /tdtd . $phone . /tdtd . $address . /tdtd . $email . /tdtd . $sex . /td); print(/tr); } print(/tableinput type='submit' name='Submit'/form); } -- I'd like to add buttons to edit this record and delete this record to each row but I'm not sure how to get it done. It seems like I'd have to add a hidden variable (playerID, which is my primary key for the table players) to each row printed but how do I manage unique submits since I'm already inside a form? I must be missing something obvious - please help! Thanks, Kirk -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] need help with a query
RE c1: I do not know how I was going to record the records of one team vs another in a specific series. That is a very good point and I don't have an answer. I realize this is getting more OT, but if anyone has a nice table structure for handling team v. team series stats I'd like to hear it. Thanks, Kirk -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] need help with a query
If (in MySQL) I have to select 'playerID' from the table soccer.players based on lname='smith', fname='john', and dob='1988-12-02' and THEN update soccer.teams 'coachID' equal to the result of the select statement, can I do it all in one query? Or must I let my PHP script execute a select, grab the result, and then run the update statement? The scenario is this: I've just created the player record in soccer.players (it's an adult league, so a player could also be the coach) and need to grab that playerID to insert into the coachID section of soccer.teams. Here's the definitions for my tables if it would help you follow my question (with thanks to Micah for the structural assistance): divisions Table comments : league division names with identifier Field Type Null Default divisionID int(11) No division_name varchar(15) No players Table comments : player registration and statistical info Field Type Null Default playerID int(11) No lname varchar(20) No fname varchar(20) No teamID int(11) No 0 dob date No -00-00 address varchar(40) No telephone int(9) No 2147483647 email varchar(40) No sex enum('m', 'f') No m yellow int(2) No 0 red int(2) No 0 disc_notes text Yes NULL goals_scored int(2) No 0 own_goals int(2) No 0 teams Table comments : Team registration and statistical info Field Type Null Default teamID int(11) No team_name varchar(20) No pwd varchar(7) No coachID int(11) No 0 divisionID int(11) No 0 paid enum('y', 'n') No n pmnt_notes text Yes NULL win int(2) No 0 loss int(2) No 0 tie int(2) No 0 goals_for int(2) No 0 goals_against int(2) No 0 Thanks for your help! Kirk -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] need help with a query
Mihail Bota [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I do not think it is going to work, you may want to stick with the PHP script. MySQL says that is going to enable subqueries from version 4.1 and the most recent release is 4.0.16 or 4.0.17. A question and 2 comments: q: the teams are fixed within league? c1: it is not clear how you record the goals of a team against of another. 2. you may want to check the sizes of some fields; some are too big, or too small. Mihai Thanks, Mihail. I'm using PHP 4.3.3 and MySQL 4.0.15-standard (stuck with what my ISP is providing). RE q: I don't understand your question. Do you mean, the teams are fixed for each season? The answer is yes. RE c1: I do not know how I was going to record the records of one team vs another in a specific series. That is a very good point and I don't have an answer. RE c2: I'll check the field sizes, thanks. Regards, Kirk -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] table structure question
Hi everyone, I would like to set up the following two tables inside a db for a soccer league, but wanted to run their structure by you guys first. Here it is: dbname: soccer_stats tables: teams, players teams -- name | captain | division | paid | pmnt_notes | win | loss | tie | goals_for | goals_against players -- lname | fname | team_name | dob | address | telephone | email | sex | yellow | red | disc_notes | goals_scored | own goals I've never split the info over multiple tables, but this way made sense to me for some reason. I've been thinking, and if, for example, I want to (using mysql) pull the captain of a specific player, how would I do that? Is this a good table design in the first place? Comments and criticisms are welcome! Thanks - Kirk -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Strange bahavior with mysql_fetch_array($result)
Hi Evan, Try something like this instead: $query = mysql_query(SELECT product_id, product_name, purchase_date from MyTable ORDER BY product_id DESC); if(!$query) { echo mysql_errno() . : . mysql_error() . \n; die; } else { //Now, for fun, display the results in a table with the results linked to a product information page print table; while($row=mysql_fetch_array($query)) { print tr; print tda href=product_details.php?product_id=$row[product_id] . $row[product_name] . . $row[purchase_date] . /a/td; print /tr; } print /table; } ? NOTE: this is not a tested example, and I didn't check it for accuracy. I just threw something together to give you some good ideas of where to go with your code. I strongly urge you to use the manual (php.net) just to browse through the available functions. Good luck! HTH, Kirk Evan Panagiotopoulos [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I am searching a table and have the following php code with my comments: $result = mysql_query($query); print The result == $result; // it returns The result == Resource id #2 if (!mysql_fetch_array($result)) { ... } else { while ($row = mysql_fetch_array($result)) { ... } } Neither the if nor the while get executed. Can you make any suggestions? Obviously I'm new to this. Evan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] problem - query inside a function
Hi, I'm having trouble with a query inside a function. I thought I'd written this so that the function would fail if email and zipcode supplied were not in the same row (trying to use those two things to identify the user), but I don't think that is what is happening because I can enter the wrong zipcode and it will return data based on the email. Any suggestions or corrections? Thanks! -Kirk [code snippet] function getEditData($email,$zipcode) { $sql = SELECT * FROM contact_info WHERE zipcode='$zipcode' AND email=\{$email}\; $query = mysql_query($sql); if (mysql_affected_rows()==0) { $this-sendResult(Fail,We do not have the given email and zipcode on file. Please go to the menu and start again.); } [end snippet] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] [SOLVED] Re: problem - query inside a function
Thanks to Karen and Richard for your help! I removed the quotes around 0 in the comparison for mysql_affected_rows. That was definitely important. I then added the echo $sql; statement Richard recommended, and saw the following: (save some time and just look at the end of the string) SELECT * FROM contact_info WHERE zipcode='86345' AND email=[EMAIL PROTECTED]result=FailerrorMsg=We+do+not+have+the+given+email+and+zi pcode+on+file.++Please+go+to+the+menu+and+start+again.result=Edit I had completely missed that! That was overriding my result=Fail earlier in the string, so naturally it was going to the edit page. Doh! Looking thru my code I had a hard time figuring it out (although it's seems simple now): 1 function getEditData($email,$zipcode) { 2 $sql = SELECT * FROM contact_info WHERE zipcode='$zipcode' AND email=\{$email}\; 3echo $sql; 4$query = mysql_query($sql); 5if (mysql_affected_rows()==0) { 6 $this-sendResult(Fail,We do not have the given email and zipcode on file. Please go to the menu and start again.); 7} else { 8 //a bunch of variables declared here so I pulled them out for space 9$this-sendResult(Edit,$varsToEdit); 10 } Even though I was invoking the function sendResult for the failure, the code was continuing on to the NEXT sendResult which was giving the Edit message. Here is the sendResult function: 11 function sendResult($result,$txtMsg) { 12switch ($result) { 13case Okay: 14$txtMsg = urlencode($txtMsg); 15 print result=OkaysuccessMsg= . $txtMsg; 16break; 17 case Fail: 18$txtMsg = urlencode($txtMsg); 19print result=FailerrorMsg= . $txtMsg; 20break; 21 case Edit: 22print result=Edit . $txtMsg; 23break; 24} 25 } So result was being sent twice, and the second value(sent on line 22) for result overrode the first (on line19) The Solution? Add a break; inside the first if after line 6. Problem solved because the script stops (which it should at that point). WOW, I hope you guys don't mind me sharing all of that, maybe it will help somebody else in the future - make sure you terminate your failure cases if you're calling another function to handle the job. Thanks again for the help :) Kirk -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] [CLARIFICATION on SOLUTION] Re: problem - query inside a function
Lines 7-11 should actually read as the following and then what I was saying makes sense 7} else { 8 //a bunch of variables declared here so I pulled them out for space 9} 10$this-sendResult(Edit,$varsToEdit); 11 } I had accidentally erased the curly bracket on line 9. This made me realize, though, that I should have included $this-sendResult inside the else statement and none of this would have happened in the first place! (sheepish grin) Thanks, Kirk -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] db list problem
I keep getting this message in Italian every time I post to php.db, does anyone else have this problem? when I click on the link provided in the msg, it takes me to some page and asks for my email address so that my email could be sent to the user fsoto. I didn't do it. Can we get rid of this guy somehow? It's pretty annoying to get this every time I post. Thanks, Kirk The 2nd message I've received in 20 minutes (immediately after I post) is below if anyone wants to see it: From [EMAIL PROTECTED] Sent Wednesday, October 15, 2003 3:08 pm To [EMAIL PROTECTED] Cc Bcc Subject [QRfsoto]: [PHP-DB] [CLARIFICATION on SOLUTION] Re: problem - query inside a function FILTRO-QUIK ha rechazado su mensaje de correo electrónico enviado a un cliente de Quik, con el tema [PHP-DB] [CLARIFICATION on SOLUTION] Re: problem - query inside a function debido a la privacidad y las políticas de spamming, usted necesitara solicitar autorización para continuar enviando correos electrónicos a esta persona. Usted puede hacerlo fácilmente con solo seleccionar en el curso de las próximas 48 horas, la siguiente liga http://mailbox2.quik.com/cgi-bin/spamweb.pl?user=fsoto[EMAIL PROTECTED] e incorporando su dirección de correo electrónico en donde se indica. NO es necesario reenviar el correo, ya que, el correo electrónico que usted envió, será entregado. Usted especificó la dirección(es) a TO y de CC en su correo electrónico: [EMAIL PROTECTED] begin 666 all-0.gif M1TE[EMAIL PROTECTED])'_`,# P9FF3,[EMAIL PROTECTED]'Y! $`+ ```L```(2 M%'YB*+'07 K4Q'IMG4\A^ $%`#L`+ ```L```08T Q @9'3%CQ, 1V4/[EMAIL PROTECTED](HEX854$`#L` ` end -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: db list problem
Thanks for hijacking my thread - I guess nobody else is having this problem? I don't understand how I can post to php.db and receive notices and autoresponders from Italy (2 different guys now). -Kirk -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: db list problem
Ah, I just read Richards note on the same problem. Let's get rid of these guys, please. -Kirk -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] bouncing an idea...
I'm a grad student with a university medical research lab, and they have thousands of samples coming through. They want to integrate a web-based tracking system using barcodes and scanners to trace the samples through the different processing points in the lab. And they don't want to pay for a commercial system - they want something homegrown to be cooked up. I think I can handle this, but I haven't found any info about sending data into a php/mysql system from a scanner. I've come across some scanners which handle DDE (dynamic data exchange - sends data directly to a windows program) Does anybody out there do anything like this using php and mysql? If so, please send some suggestions my way. Thanks!!! -Kirk -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: bouncing an idea...
My apologies for these posts, I'm just not sure where to start I'm asking for info more from the standpoint of finding someone who is using php mysql to accept the info from a scanner rather than wanting info about scanners. Thanks! Kirk -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] about MySQL config for PHP on regular user accounts
Good afternoon everyone, I have a site running on Apache 1.3.24, PHP 4.2.0, and MySQL 3.23.49 all done on a W2K box. Whenever I run as regular user instead of admin, my site runs but cannot make any db connections through the PHP scripts. I installed MySQL as a service, but it won't run when I switch from admin to joe blow user accounts. Why is the Apache service able to run on other user accounts but MySQL is not? I remember the option enable for all users when Apache installed, but MySQL gave no such option on install that I noted. Has anybody else had this problem? The site doesn't get enough hits to warrant a single-use computer, so I need to be able to have multiple user accounts. I looked at the service properties of mysql in control panel but found no options which could make a difference (or so I think). My apologies for posting this problem to the group. I realize it is off-topic, but I'm not sure where to post it after reviewing the MySQL faq at mysql.com and not finding anything. To Summarize, HERE'S THE QUESTION: How do you configure the mysql daemon to run under any user account on Windows? thanks, Kirk -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] select and sort question
I have a db table which holds news in the following manner: ID (auto-increment), newsdate (DATE), newstitle, and newstext I have been displaying them by ID, and would like instead to sort them by date (descending). Since I'm using Flash I have been doing mysql_fetch_array for each ID query and then separating the fields out for placement in the dynamic text fields (has to be done for formatting), like so: $news_details1 = mysql_query(SELECT * FROM newsitems where ID='1'); $headlines1 = mysql_fetch_array($news_details1); then populate the fields with echo newstitle1= . $headlines1[newstitle] etc. Can I do this in a better way (more efficient)? and sort by date? I haven't done any sorting before, and if it pulls all the data into an array wouldn't that really be a 2D array? How do I handle that? Thanks for any help or suggestions, Kirk -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php