Jump to content

JohnnyKennedy

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

JohnnyKennedy's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hey, Thanks for looking at my post. I have a quick question about how I could manage my Conversation (iPhone Style) messaging system - i.e. a private message is displayed in a stream of replies between each of the users involved. So, I have two users - A and B, who are chatting with each other. In the inbox, I'd like to have the conversation displayed but I am unsure of how to group them in a query without having each reply repeated in the result. I guess, I'm asking how can I grab all rows that have the same conversation id, and display only one result in the users inbox. The structure of my table is this: mid (unique) | title (subject) | msg (body) | from | to | to_viewed | from_viewed | to del | from_del | sendtime | readIP | sendIP | conversation Regards, Jonathan
  2. Never mind buddy, fixed it it was on the $query_sellsearch line. Thank you so much for your help - it's working great now. I honestly love you right now! Have a great day! VERY Warm Regards, Jonathan
  3. Thanks again Keith! Do you know why I would be getting this error using the code you provided for me: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%isearchedforthis%' at line 1 then it obviously dies. Regards, Jonathan
  4. Keith, Thanks for replying! Unfortunately, that code isn't really working for me at the moment I'm afraid -- it's not return any rows at all.. $sort is sanatized - and is basically determined by a <select> field where the values are btitle ASC or btitle DESC etc. etc. $range on the other hand is in an If() statement and if it's present, it will determine the highest price.. For example: where high is the input field, $rangeh = addslashes($_POST['high']); if ($rangeh > 0) { $range = "AND `price`<=$rangeh"; } else { $range = ""; } Basically, this is what I'm looking at - which isn't returning any results.. $maxRows_sellsearch = 20; $pageNum_sellsearch = 0; if (isset($_GET['pageNum_sellsearch'])) { $pageNum_sellsearch = $_GET['pageNum_sellsearch']; } $startRow_sellsearch = $pageNum_sellsearch * $maxRows_sellsearch; $colname_sellsearch = "-1"; if (isset($_POST['s'])) { $colname_sellsearch = trim($_POST['s']); } mysql_select_db($database_scholarexpress, $scholarexpress); $query_sellsearch = sprintf("SELECT * FROM selltable WHERE ((`btitle` LIKE '%2$s') OR (`bisbn` LIKE '%2$s') OR (`bauthor` LIKE '%3$s') OR (`bpubyear` LIKE '%4$s') OR (`bpublisher` LIKE '%5$s')) AND `archive`=0 ", "%".mysql_real_escape_string($colname_sellsearch)."%", "%".mysql_real_escape_string($colname_sellsearch)."%", "%".mysql_real_escape_string($colname_sellsearch)."%", "%".mysql_real_escape_string($colname_sellsearch)."%", "%".mysql_real_escape_string($colname_sellsearch)."%", $sort, $startRow_sellsearch, $maxRows_sellsearch); $query_limit_sellsearch = sprintf("%s LIMIT %d, %d", $query_sellsearch, $startRow_sellsearch, $maxRows_sellsearch); $sellsearch = mysql_query($query_limit_sellsearch, $scholarexpress) or die(mysql_error()); $row_sellsearch = mysql_fetch_assoc($sellsearch); if (isset($_GET['totalRows_sellsearch'])) { $totalRows_sellsearch = $_GET['totalRows_sellsearch']; } else { $all_sellsearch = mysql_query($query_sellsearch); $totalRows_sellsearch = mysql_num_rows($all_sellsearch); } $totalPages_sellsearch = ceil($totalRows_sellsearch/$maxRows_sellsearch)-1; Is there any way to remove unnecessary code - or ultimately - get rid of those annoying %s that DW has put in? --- I appreciate you taking the time to help me, you are literally a life-saver! Warm Regards, Jonathan
  5. Hi, thanks for replying so soon! I'm trying to get a series of results which I've got repeated perfectly (just the query is messed up, my own fault ) from a database - so when the user clicks on one of these results they are taken to the dynamic book page. So, to simplify things i'm having the user search through by using a simple one-field form, which in turn searches the five columns mentioned with that one search string.. This is the error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0, 20' at line 1 Hope this helps - thanks again buddy!
  6. Okay guys here's hoping you can help. Basically, I have a site with a simple search field which is going to search about five columns in a table of mine those columns being: - bisbn - bauthor - btitle - bpubyear - bpublisher using a form variable. So far, I have this block of PHP - the '%s' I'm not really sure what these are, they were added by Dreamweaver. I know I'm going to come across as lazy, but I would be ever so grateful if you could help me out just a little. $colname_sellsearch = "-1"; if (isset($_POST['s'])) { $colname_sellsearch = trim($_POST['s']); } mysql_select_db($database_scholarexpress, $scholarexpress); $query_sellsearch = sprintf("SELECT * FROM selltable WHERE (`btitle` LIKE %s) OR (`bisbn` LIKE %s) OR (`bauthor` LIKE %s) OR (`bpubyear` LIKE %s) OR (`bpublisher` LIKE %s) AND `archive`=0 $range ORDER BY $sort", GetSQLValueString("%" . $colname_sellsearch . "%", "text")); $query_limit_sellsearch = sprintf("%s LIMIT %d, %d", $query_sellsearch, $startRow_sellsearch, $maxRows_sellsearch); $sellsearch = mysql_query($query_limit_sellsearch, $scholarexpress) or die(mysql_error()); $row_sellsearch = mysql_fetch_assoc($sellsearch); if (isset($_GET['totalRows_sellsearch'])) { $totalRows_sellsearch = $_GET['totalRows_sellsearch']; } else { $all_sellsearch = mysql_query($query_sellsearch); $totalRows_sellsearch = mysql_num_rows($all_sellsearch); } $totalPages_sellsearch = ceil($totalRows_sellsearch/$maxRows_sellsearch)-1; ---- These are a few variables I've got going on too: $range = "AND `price`<=$rangeh"; $sort = addslashes($_POST['sort']);
  7. Hey guys! Here's hoping you can help me out, I'm new to the whole rewrite rule, but basically what I'm trying to do is tidy up my URLS and make them more search engine friendly - so, when a user navigates to ../view/book/essentials of economics, they are (behind the scenes) actually visiting ../view.php?book=essentials of economics. I've tried it every way possible, and have spent days researching it - but each time i try write it to .htaccess I get 500 internal errors? Any help would be greatly appreciated. Thanks Again.
  8. Okay, so I'm *trying* to build a site where in which one page allows the user to search through a public database of books ISBNDB.com by title, isbn etc. In this page, the user is allowed to search by title, and what I'd like is for a page to return all of the results so that I can format them, and then link each one to it's own page.. What I'm having trouble doing, is finding out how to get the results to repeat, as right now I'm simply getting (what I assume) is the first record in the DB. Please help me, anything would be appreciated. Here's the code i'm using on the page which is returning results.. --- <?php //search books // Access key $accessKey = "XXXXXXXX"; // Get Post variables $content = $_POST['content']; $query = $_POST['query']; $save = $_POST['save']; if ($save): // Save text file $handle = fopen ("books.txt", 'w'); fwrite($handle, stripslashes($content)); fclose($handle); endif; if ($query): // Check for condition flag switch (strtolower($query{0})) { case "a": $condition = "Like New"; $query = substr($query, 1); $adjustment = .50; break; case "b": $condition = "Very Good"; $query = substr($query, 1); $adjustment = .25; break; case "c": $condition = "Good"; $query = substr($query, 1); $adjustment = .10; break; case "d": $condition = "Acceptable"; $query = substr($query, 1); $adjustment = 0; break; case "f": $condition = "Poor"; $query = substr($query, 1); $adjustment = -.10; break; default: $condition = "Good"; $adjustment = .10; } // Urls $url_details = "http://isbndb.com/api/books.xml?access_key=$accessKey&results=details&index1=title&value1=$query"; $url_texts = "http://isbndb.com/api/books.xml?access_key=$accessKey&results=texts&index1=title&value1=$query"; $url_prices = "http://isbndb.com/api/books.xml?access_key=$accessKey&results=prices&index1=title&value1=$query"; $url_subjects = "http://isbndb.com/api/books.xml?access_key=$accessKey&results=subjects&index1=title&value1=$query"; // API lookup $xml_prices = @simplexml_load_file($url_prices) or die ("File Error: XMLPrice") ; $xml_details = @simplexml_load_file($url_details) or die ("File Error: XMLDetail") ; // Parse Data $isbn = $xml_prices->BookList[0]->BookData[0]['isbn'] ; $title = $xml_prices->BookList[0]->BookData[0]->Title ; $titleLong = $xml_prices->BookList[0]->BookData[0]->TitleLong ; $authors = $xml_prices->BookList[0]->BookData[0]->AuthorsText ; $publisher = $xml_prices->BookList[0]->BookData[0]->PublisherText ; $dewey = $xml_details->BookList[0]->BookData[0]->Details[0]['dewey_decimal_normalized'] ; $lcc = $xml_details->BookList[0]->BookData[0]->Details[0]['lcc_number'] ; // Calculate average price (new) $count = 0; $total = 0; $price = $xml_prices->BookList[0]->BookData[0]->Prices[0]->Price ; foreach ($price as $price) { if ((string) $price['is_new']=="1" and (string) $price['currency_code']=="USD" and (string) $price['price']>0.1): $price = number_format($price['price'],2); $total = $price + $total; $count++; endif; } $priceNew = number_format(($total / $count),2); // Calculate average price (used) $count = 0; $total = 0; $price = $xml_prices->BookList[0]->BookData[0]->Prices[0]->Price ; foreach ($price as $price) { if ((string) $price['is_new']=="0" and (string) $price['currency_code']=="USD" and $price['price']>0.1): $price = number_format($price['price'],2); $total = $price + $total; $count++; endif; } $priceUsed = number_format(($total / $count),2); // Calculate estimated value based on current prices and condition $value = number_format(($priceUsed+($adjustment*($priceNew-$priceUsed))),2); // Write to text file//cancelled endif; ?> I thought that simply printing the $title variable would work, and it is - but, obviously, that's not repeating it. Thanks in advance you guys.
  9. Okay, so I have a friend request system on my website and part of my website requests information from two tables and displays it together. E.G: my 'ACCOUNT' table holds Fn, Ln, Username, and password. And my friend request table (FRIEND) holds data which fit into the columns user1, user2, confirmed. (confirmed being either 1 for YES, 0 for NO or NOT FRIENDS YET). I can successfully return the values of the friend request table - ignoring my username using this line: //my variables $me = $_SESSION['MM_Username']; $zero = "0"; mysql_select_db($database_NewConnection, $NewConnection); $query_rqs = "SELECT *, IF (usera = '$me', userb, usera) AS Other FROM buddies WHERE '$me' IN (usera, userb) AND confirmed='$zero'"; $rqs = mysql_query($query_rqs, $NewConnection) or die(mysql_error()); $row_rqs = mysql_fetch_assoc($rqs); $totalRows_rqs = mysql_num_rows($rqs); --------- Then, to get the full name of the person who sent the request I use a variable $un = $row_rqs['Other']; and then use this variable to run another query on the accounts table. like this: mysql_select_db($database_NewConnection, $NewConnection); $query_getfullname = sprintf("SELECT * FROM accounts WHERE `username`='$un'", GetSQLValueString($colname_getfullname, "text")); $getfullname = mysql_query($query_getfullname, $NewConnection) or die(mysql_error()); $row_getfullname = mysql_fetch_assoc($getfullname); $totalRows_getfullname = mysql_num_rows($getfullname); My problem is this; when I repeat region (in DW) the entire table which holds the results of the first query - I can successfully get the username of the person who sent the request, but when I use that username in the second query - it doesn't repeat -- it simply returns the first result of the query every single time. Any help would be appreciated.. Let me know if you need more code - here is the code I'm using to repeat region the table. <?php do { ?> <table width="440" border="0"> <tr> <td height="22"><img src="user.png" width="20" height="20" /></td> <td height="22" colspan="5"><?php echo $row_getfullname['fn']; ?> <?php echo $row_getfullname['ln']; ?> (<?php echo $row_rqs['Other']; ?>)</td> </tr> <tr style="font-size:11px;"> <td width="22" height="22"><span style="font-size:11px; vertical-align:;"><img src="clock.png" width="19" height="19" /></span></td> <td width="27" valign="middle">Sent:</td> <td width="89" valign="middle"><?php echo $row_rqs['rsendtime']; ?></td> <td width="24" valign="middle"><a><img src="nect.png" width="22" height="22" /></a></td> <td width="63" valign="middle"><a style="text-decoration:none; color:#555; font-size:11px;" href="http://www.google.com/" target="_parent">View Profile</a></td> <td width="202" valign="middle"><span style="font-size:14px;"> <img src="ignore.gif" width="77" height="22" /> <img src="approve.gif" width="78" height="22" /></span></td> </tr> <tr style="font-size:11px;"> <td height="20" colspan="6" align="left">...</td> </tr> </table> <?php } while ($row_rqs = mysql_fetch_assoc($rqs)); ?>
  10. OMG I LOVE YOU! That 'other friend' trick solved like 90% of my other problems!!!!
  11. Okay, so I have a basic table set up with ID, Friend1, Friend2, Confirmed etc. With ID auto_incrementing, & confirmed being 0 or 1 (1 confirmed 0 pending). MySQL script is working great and is returning the appropriate rows: mysql_select_db($database_NewConnection, $NewConnection); $query_buddy = "SELECT * FROM buddies WHERE `usera`='$me' AND `confirmed`='$one' OR `userb`='$me' AND `confirmed`='$one'"; $buddy = mysql_query($query_buddy, $NewConnection) or die(mysql_error()); $row_buddy = mysql_fetch_assoc($buddy); $totalRows_buddy = mysql_num_rows($buddy); however, what I can't seem to figure out is how to display the username of a users friend in the dynamic field without displaying my own. For example: I add a friend, my Username JOHN is added as friend1 and the other users name (KATE) is added into friend2 - assuming the relationship is confirmed and the value of confirmed is 1, the friendship is returned as a MySQL result. I would like to display values from the query (from either Friend1 or Friend2) where my username is not included. So in this example I only want to display the value of KATE (from friend2) and not my name (from friend1) - essentially display all of my friends.. Is this possible? Can you please lead me to the right track. ANY help would be appreciated.
  12. Hey, Yep, sorry I forgot to mention that I figured that part out too. It's the IF statement that I'm confused about - you know, to check and display an image if the value of the Read column is ZERO. Thanks.
  13. Hey There, So I'm building a site, and part of this website allows users to message each other - I'm doing it through a PHP MySQL Database (I know it's probably not the best way :\ ). I've got an inbox, outbox, sent & the actual send function working, but what I can't figure out is how to tell if the message has been read or not. I was thinking of doing an integer kind of thing, for eg. I have a col in my database for 'read' with two possible values of 1 or 0 (1 being read, 0 being new). Then I played around with IF statements, but can't figure out how to do it. If you guys could maybe help me out with an IF statement that would let me show an Image if the value is 0. My Recordset was done using DW, and I have a repeat region included. Let me know what code you need, if you need any more - but heres the most relevant code. Thanks in advance you guys. $colname_inbox = "-1"; if (isset($_SESSION['MM_Username'])) { $colname_inbox = $_SESSION['MM_Username']; } mysql_select_db($database_NewConnection, $NewConnection); $query_inbox = sprintf("SELECT * FROM mailboxes WHERE recipient = %s ORDER BY server_time DESC", GetSQLValueString($colname_inbox, "text")); $query_limit_inbox = sprintf("%s LIMIT %d, %d", $query_inbox, $startRow_inbox, $maxRows_inbox); $inbox = mysql_query($query_limit_inbox, $NewConnection) or die(mysql_error()); $row_inbox = mysql_fetch_assoc($inbox);
  14. Okay, my second post.. Here it goes. *I know a little bit, but not a lot* I have two tables in MySQL: debates_com (comments for debates) AND debates (debate data such as title side1 side2 keywords etc.) Right now I have (this) as my PHP code -- which is working and returning the right values..ß <?php require_once('Connections/NewConnection.php'); ?> <?php mysql_select_db('sprekn'); $query = "SELECT did, owner, COUNT(did) AS didcount FROM debate_com GROUP BY did ORDER BY didcount DESC"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo $row['didcount'].": ".$row[did]."<br />"; } ?> The above code sorts and groups my data accordingly, so that my page displays the number of comments associated with a particular debate. The problem is the row 'did' (e.g. data 32942349234) doesn't mean anything to my viewers - so i'd like to link the DID value to the 'Debate' table which holds this 'did' value as well as the debate name. So that the value returns (COMMENT COUNT): *debate name from debate table* Sorry if this isn't very clear, I'm having a really hard time linking these, and I'm just not sure how to go about it.. Any help would be great, no matter how small. Regards, Jonathan
  15. Ok, I'm new here (first post FTW!) so please help me out. My knowledge of coding is limited so please explain your replies *if you can*. I'm developing a website, for my school - a past pupil one. (stpatricks . me / html) Users have the ability to register their details which is then forwarded to a MySQL database for entry which is working fine - no issues there. Imaginably, I'd like the users to be able to upload an image into their 'profile', I have an uploader script that works great, but the problem is I don't know how to link the image and the record (in the MySQL database) together. What I was thinking, was that if there is a script to rename the image (to a username) and then tell the database the location of the image? For example ../userprofileimagefolder/usernameIMAGEFILE (usernameIMAGEFILE being a file, and not a specific folder). The image should be uploaded after registration is completed, i.e. once the user is logged in using the information in the database. I'm using Session Variables to get to the user actions page - which holds the links to browse other profiles, cancel account, and *soon to be* upload an image. Please forgive my ignorance, I'm just really new. If you need anymore information or scripts, please ask. Thanks, - Confused.
×
×
  • 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.