Jump to content

mikosiko

Members
  • Posts

    1,327
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by mikosiko

  1. with different aliases x.uname, y.uname, z.uname; matching the aliases used for JOINing the table users... in your case you should have x.firstname, x.lastname, y.firstname, y.lastname, z.firstname, z.lastname
  2. here is the mock-up of a possible solution (tested)... replace/add your table field names and aliases SELECT a.uid, x.uname, a.fid, y.uname, b.fid, z.uname FROM partners a JOIN partners b ON a.fid = b.uid AND b.fid NOT IN ( SELECT m.fid FROM partners m JOIN partners n ON m.fid = n.uid WHERE m.uid =1) JOIN users x ON a.uid = x.uid JOIN users y ON a.fid = y.uid JOIN users z ON b.fid = z.uid WHERE a.uid =1; Note: uid = user_id uname = users.firstname or users.lastname // add fields as you need fid = friend_id The output of that query (using your data as example) is this 1, 'Jason', 2, 'Chelsea', 6, 'Jim' 1, 'Jason', 2, 'Chelsea', 12, 'Peter' 1, 'Jason', 2, 'Chelsea', 12, 'Cameron' 1, 'Jason', 2, 'Chelsea', 38, 'Felicia' 1, 'Jason', 4, 'Davey', 14, 'Jeffrey' 1, 'Jason', 5, 'Adam', 6, 'Jim' 1, 'Jason', 5, 'Adam', 14, 'Jeffrey' 1, 'Jason', 5, 'Adam', 17, 'Dan' 1, 'Jason', 20, 'Victor', 1, 'Jason' the last record (yourself) could be eliminated easily adding the condition to the last where
  3. some comment added if (isset($_POST['close'])){ $idList = array_keys($_POST['close']); $idList = array_map('intval', $idList); $implValue = implode(',', $idList); $closequery = "UPDATE sellerinfo SET Closed='y' WHERE Index IN ($implValue)"; // Here you echo your raw query to validate if it is well formed and syntactically correct echo "The query is : " . $closequery . "<br/>". // Here you add a basic error control to trap any error during the query execution // die should be replaced for something better while code is in production.. like trigger_error per example mysql_query($closequery) or die("Query Error : " . mysql_error()); }
  4. seems that you are looking for something like this (replace table and columns name for the real ones) SELECT tbl1.horse1, tbl1.horse1_odds, b.fav AS Horse1_fav, tbl1.horse2, tbl1.horse2_odds, c.fav AS Horse2_fav, tbl1.horse3, tbl1.horse3_odds, d.fav AS Horse3_fav FROM tbl1 LEFT JOIN table2 AS b ON tbl1.horse1_fav = b.id LEFT JOIN table2 AS c ON tbl1.horse2_fav = c.id LEFT JOIN table2 AS d ON tbl1.horse3_fav = d.id in a side note; you should normalize your tabla 1 to eliminate the repeating groups (like horse*_odds and horse*_fav) (1NF violation)... examples & some further simple explanation here: http://www.troubleshooters.com/littstip/ltnorm.html
  5. you are the only one that could know how your transaction id field is called... either way.. assuming (for you to check) that your field name is nSTId you can assign it value to some variable here: $this_user = $srow['nUserId']; $other_user = $srow['nUserReturnId']; $transactionId = $row['nSTId']; and use $transactionId in the rest of your code
  6. where in your SELECT are you getting the nTransactionId column (assuming that the column exists in your table users)? $sql = "SELECT vLoginName,vFirstName,vLastName,vAddress1,vAddress2,vCity,vState, vCountry,nZip,vPhone,vFax,vEmail FROM " . TABLEPREFIX . "users U where nUserId='" . $this_user . "' ";
  7. @tjburke79: HINT: explore the GROUP_CONCAT() function (be aware of the size limitations)
  8. @jacbey: error means that your query is failing, a good reason for that is the usage of a mysql reserved word read is one of them.... 2 options: a) change the name of the column (the best long term solution) or b) enclose it in backtics in this way `read`
  9. yes. did you read the UPDATE manual pages? http://dev.mysql.com/doc/refman/5.0/en/update.html the last few paragraphs before the "Users Comments" show you how.... hint: JOIN
  10. no... this is what you have (gif attached)... you will see that the relations are not correct based on your description. Edit: I saw that you added a store entity... good... now think about the item table.... should be the item name (apparently field `item`) be present in that table? [attachment deleted by admin]
  11. I did notice also that in `item` the attribute `item_id` is duplicated, and probably `store` should be a FK to another entity (stores)
  12. the answer depend on what each entity represent and how the relation among them is read (members is clear, item is suspicious, lists no clear) BTW.: The PK on `lists` is incorrect
  13. if the file was encrypted with a key or passcode you need to have it to decrypt.
  14. Yes, that is correct Yes, but that doesn't prevent to use them incorrectly.. that is were you are failing to understand the differences among them, and apply the right one (or combination of them) in your code what it is important for you is understand the differences/similitudes among mysql_fetch_array, mysql_fetch_assoc and mysql_fetch_row and to know exactly what each one is going to return, and how to use that result in the rest of your code... p.e: in your original code you have this lines (forget the errors in the first loop because you already fixed that using mysql_data_seek): while ($tableRow = mysql_fetch_array($results)) { echo "<tr>"; for($i=0; $i<count($tableRow); $i++) { and somebody else told you that you were using the count() incorrectly.... why? if you replaced mysql_fetch_array for mysql_fetch_assoc() in this part of the code it should gave a lot of errors... why? if you replace mysql_fetch_array for mysql_fetch_row now the code works... why? if instead of use count($tableRow) you use count(mysql_num_fields($results)) the code works no matter if you use mysql_fetch_array or mysql_fetch_row().... why? those are the basic questions that you must answer yourself (testing) to gain the understanding for future. hope this help
  15. an alternative solution should be write to second loop in this way $nmr_fields = mysql_num_fields($results); while ($tableRow = mysql_fetch_row($results)) { echo "<tr>"; for($i=0; $i<$nmr_fields; $i++) { /// or use mysql_num_fields($results) directly here instead of $nmr_fields echo "<td>". $tableRow[$i] . "</td>"; } echo "</tr>\n"; }
  16. have you tried GNUPG ? http://www.gnupg.org/
  17. and are you sure that your university web server have MYSQL available for you and that you are allowed to create a DB on it?... you best bet is contact your university IT dept.
  18. I will bet that you: a) replaced the mysql_fetch_array() for mysql_fetch_assoc() in your second while loop too.... or b) you still having mysql_fetch_array() in that loop but still using the counter incorrectly as somebody else told you some posts ago. easy solution.... read mysql_fetch_row() for the second loop
  19. nothing weird with that.... a good read on mysql_fetch_array() is in order.. pay special attention to the "DESCRIPTION:" same answer than before, but now pay attention to the paragraph "RETURN VALUES" finally based on some comments in your code, seems to me that you are tying to print the columns name in the table header row.. is that is case reading about mysql_fetch_fields() should help.
  20. the first rule to follow: - TEST the query before to use it in PHP.... I did and is working you error was that you removed the CAST() function but you did it wrongly .... this sentence SELECT GROUP_CONCAT(system_disk_qty AS CHAR) AS system_disk_qty, GROUP_CONCAT(system_disk_size AS CHAR) AS system_disk_size FROM system_disks WHERE system_id = 2 GROUP BY system_id; should be SELECT GROUP_CONCAT(system_disk_qty) AS system_disk_qty, GROUP_CONCAT(system_disk_size) AS system_disk_size FROM system_disks WHERE system_id = 2 GROUP BY system_id; and are you sure that the field system_disk_qty IS NOT A NUMBER? ... if it IS a number you have to use CAST()
  21. another option.. (replace the field name for the correct ones) SELECT GROUP_CONCAT(CAST(diskqty AS CHAR)) AS diskqty, GROUP_CONCAT(diskmake) AS diskmake, GROUP_CONCAT(diskmodel) AS diskmodel, GROUP_CONCAT(CAST(disksize AS CHAR)) AS disksize, GROUP_CONCAT(CAST(disksrno AS CHAR)) AS disksrno FROM system_disks WHERE system_id = 'aNumber' GROUP BY system_id Notes: - the usage of CAST() is assuming that those fields are numerics... otherwise just remove it - if you don't want to repeat identical values like p.e: diskmodel change that line to: GROUP_CONCAT(DISTINCT diskmodel) AS diskmodel, - and last... be careful with the group_concat_max_len system variable which has a default of 1024
  22. I don't know what you tried to do... but you really screw up your original code... now you have some lines that doesn't make sense at all.. like - the first exit() ... delete that - this 2 lines... out of place and with no sense $str = strip_tags($str); return mysql_real_escape_string($str); - like this lines... with and unclosed { and a variable $errmsg_arr hanging there alone ??? if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); $errmsg_arr - this lines are wrong too ... $result is being used before it is declared/populated by your query... ?? if($result) { $result=mysql_query($qry); echo $result; exit(); }else { die("Query failed"); } better to go to the draw board and think a little better your code again.... look for some examples -
  23. post your actual and complete code again...
×
×
  • 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.