Jump to content

whelpton

Members
  • Posts

    107
  • Joined

  • Last visited

Everything posted by whelpton

  1. Thank you very much, that worked beautifully! One final question, as it stands right now, this sql will echo product names that are like bread, is there any way to also echo the butter products? Thanks once again! =D
  2. I'm still not getting any data or errors from that statement :/ $result = mysql_query("SELECT * FROM sample WHERE `nice_date` >= '2010-01-01' and `nice_date` < '2012-01-31' AND `product_name` LIKE '%a%' INNER JOIN ( SELECT user_id FROM sample WHERE `nice_date` >= '2010-01-01' AND `nice_date` < '2012-01-31' AND `product_name` LIKE '%b%' ) as brand2 USING (user_id)"); while($row=mysql_fetch_array($result)) { echo "<tr>"; echo "<td align='center' width='200'>" . $row['user_id'] . "</td>"; } echo "</table>"; I've opened the query up to just A & B so it theoretically should match most products, but I'm not getting anything at all. Thanks for your help so far though, Like I said earlier on, I don't have much experience with sql statements such as these. EDIT- on second thoughts, it looks like its bugging out with the query.
  3. Barand, Unfortunately I don't seem to be able to run that Query, I've modified it to fit the characteristics of my DB and it dies: SELECT * FROM sample WHERE `nice_date` >= "2012-01-01" and `nice_date` < "2012-01-31" AND `product_name` LIKE "%bread%" INNER JOIN ( SELECT user_id FROM sample WHERE `nice_date` >= "2012-01-01" and `nice_date` < "2012-01-31" AND `product_name` LIKE "%butter%" ) as product_name USING (user_id)
  4. Hey Jazzman1, thanks for replying. There are no errors occuring and echoing the statement comes back with: SELECT * FROM sample WHERE `nice_date` >= "2012-01-01" and `nice_date` < "2012-01-31" AND `product_name` LIKE "%bread%" AND `product_name` LIKE "%butter%" Where $brand1=bread & brand2=butter
  5. Hey guys, thanks for reading my post. I'm banging my head against a brick wall with this one, I have very limited knowledge of Mysql statements unfortunately. I'm trying to select data from a table that contains product purchases and find out which customers have purchased two seperate products, the code I have for this so far is: $brand = $_GET["brand"]; $brand2 = $_GET["brand2"]; $result = mysql_query('SELECT * FROM sample WHERE `nice_date` >= "'.$year.'-01-01" and `nice_date` < "'.$year.'-01-31" AND `product_name` LIKE "%'.$brand.'%" AND `product_name` LIKE "%'.$brand2.'%" '); However, this simply finds products that contain $brand and $brand2, whereas I'm trying to look for results where both brands were purchased. Once again, thanks for reading and any pointers would be brilliant.
  6. Hey guys, thanks for reading. I feel like I'm banging my head against a brick wall with this one: I've got a CSV file with 9 columns and I have a MySQL table with 11 columns. The CSV file looks like: col1, col2, col3, col4, col5, col6, col7, col8, col9 and the MySQL table looks like: col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11 I need to get the script to ignore the two erroneous (but required) MySQL columns. The mysql columns that need to be ignored in the import are named: db_id & nice_date This is what I have so far: $sql = 'LOAD DATA LOCAL INFILE "../csvtemp/test.csv" INTO TABLE sample FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY """" IGNORE 1 LINES' ;
  7. Thanks for the reply PIkachu2000, Is there a way around this, as the data is imported from a 100/200mb csv file that would be a pain in the arse to manually change and I imagine a pain in my processor's arse to change through code
  8. Hey guys, First of all, thanks for reading my post, its much appreciated. I've been roped into trying to develop a system to work with a large CSV file, which I believe should be ported into a mysql db to start off with then processed via php. The only issue comes into searching through the DB and finding a specific date range, I am trying to use the mysql between code such as this: SELECT * FROM sample WHERE `order_date` >= "01/01/2010" and `order_date` < "30/12/2010" But I still get order_date's that are outside of that date range. Any ideas?
  9. Thank you, thats nearly got it. However now Im getting 0.2.101 or 0.2.10.1 if I use the original 0.0.1. Im just looking to increase the last decimal position by one. Thanks
  10. Hey, just wondering what would be the best way of adding .1 to a string. For example: $newversion = $currentversion + '0.0.1'; $newversion is taken from a db, lets say for this example it is 0.2.1 This code simply outputs 0.2 Any ideas? Thanks =)
  11. @Jnerocorp, still no luck. Script dies after the command.
  12. Hey guys, I have used this code before on a linux server and know that it works, however after porting my site over to a windows server running apache, php and mysql; the following code seems to make one of my scripts crash. $queryfam1 = "SELECT * FROM wp_users WHERE user_login='$username'"; $resultfam1 = mysql_query($queryfam1) or die(mysql_error()); $row21 = mysql_fetch_array($resultfam1) or die(mysql_error()); I have no idea of a result as there is no error reported, it simply dies and does not tell me what is happening with it. Any ideas?
  13. Last question for the week now. Almost finished. All I need to do is: Remove characters from the beginning and the end of a string. Essentially: a:4:{s:4:"full";s:111:"http://www.mothernatureinc.co.uk/wp-content/uploads/2011/02/166637_482678026567_509616567_6394964_6868412_n.jpg";i:96;s:117:"http://www.mothernatureinc.co.uk/wp-content/uploads/2011/02/166637_482678026567_509616567_6394964_6868412_n-96x96.jpg";i:60;s:117:"http://www.mothernatureinc.co.uk/wp-content/uploads/2011/02/166637_482678026567_509616567_6394964_6868412_n-60x60.jpg";i:32;s:117:"http://www.mothernatureinc.co.uk/wp-content/uploads/2011/02/166637_482678026567_509616567_6394964_6868412_n-32x32.jpg";} Needs to become http://www.mothernatureinc.co.uk/wp-content/uploads/2011/02/166637_482678026567_509616567_6394964_6868412_n.jpg Any ideas?
  14. Oh fantastic! Thank you very much, that solved it straight away.
  15. Hi guys, essentially, I have very limited knowledge with mysql and have hit a brick wall. The row that I am trying to select is the following: Now, I am trying to use the following script to achieve that: The $id is being passed as 1 from a cookie, and I know for sure that thats working properly, but I cant figure out the coding to select it correctly. I need the script to search for the ID of the user & then user the simple_user_avatar to find the right entry. Please someone cast your knowledge and help me out! Oh, little adendum. All that happens when the script runs is that the first row of the table is called out, which is:
  16. Yeah session start is there in the code. It was all to do with the reverse row. THanks for your help guys
  17. Hey guys, Currently Im using: $row = mysql_fetch_array($result) or die(mysql_error()); echo $row['user_family']. " - ". $row['user_registered']; $row['user_family'] = $fam; $_SESSION['family'] = $fam; to take data from a mysql table & set it as SESSION family. However, I cant seem to get this to set. The information IS being taken from mysql because its being echo'd earlier up in the code, but its just not passing to the session. Any ideas?
  18. Excellent. Thank you very much for your help altrozero
  19. if the form is used, it automatically sets the session as 7221 instead of the other option & the elseif command doesn't redirect unrecognised users away.
  20. Can anyone explain to me why this system isnt working? I have no clue why it shouldnt be. The pin number is passed from a form to this script, which then determines if a users pin is correct and if so, forwards them onto the relevant page. Otherwise, it returns them to the login. <?php session_start(); $pin=$_POST['pin']; if ($pin='7221') { $_SESSION['pin']='7221'; $_SESSION['name']='Keith D Whelpton'; header('Location: phonesystem.php'); } elseif ($pin='3585') { $_SESSION['pin']='3585'; $_SESSION['name']='Luke S Barnes'; header('Location: phonesystem.php'); } else { header('Location: phonelogin.php'); } ?>
  21. Hey guys, Currently Im using the code: while($row=mysql_fetch_array($nt)){ echo" $row[user_login],$row[user_email],$row[CallHistoryTimes],$row[CallHistoryInfo],$row[CallHistoryLastOp]$row[CallHistoryLastDate],<br>"; } To list a mysql array; what I am trying to do is to use the mysql row ID and turn the entire string above into a list. So for example, the database would get the ID information & create a link of edit.php/?id=3 If someone could help me on this it would be mega appreciated. Thanks
  22. For more information, this is the form that is being sent to the script. <form id="form1" name="form1" method="post" action="creditupdate.php"> : <label> <input name="username" type="text" id="Username" title="username" value="username" /> </label> <label> <select name="way"> <option value="+" selected="selected">+</option> <option value="-">-</option> </select> <input name="ammount" type="text" value="credits" size="10" /> <input type="submit" name="Submit" value="Update" /> </label> </form>
×
×
  • 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.