Jump to content

aussiefly

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

aussiefly's Achievements

Member

Member (2/5)

0

Reputation

  1. thanks mate that worked brilliantly....cant beleive i forgot the set cheers
  2. yup you guys are totally correct...dont know whay i was trying to insert those details rather than update Anyway, even with update it throws an sql syntax error...this seems to happen when im trying to insert multiple values in my query...anyone know where im going wrong ???
  3. Hey everyone! I've got a query that im running to stick multiple values into a table ina mysql database. $schedule_insert ="INSERT INTO `days` (monday, tuesday, wednesday, thursday, friday, saturday, sunday) VALUES ('$monday','$tuesday','$wednesday','$thursday','$friday','$saturday','$sunday') WHERE userid = $_SESSION[id]"; $schedule_update = mysql_query($schedule_insert); Now is that the best way to do it and will it work fine??? I've been using the query without the `WHERE` conditional and it works...im just wondering if ive got the WHERE conditional in the right spot. Any ideas
  4. awesome! That did the trick perfectly! Thanks for the help aussie
  5. hi guys, i'm putting together a little referrer script for my site and I was just wondering if there is some simply way to 'grab' the variables listed in a URL. So for instance if a client was sending people to www.somerandomURL.com?refer=101 is there a way that when a new member then registers i can grab that account no out of the URL and store it in a variable for later use??
  6. Thanks everyone...i managed to get there with your help. cheers aussie
  7. hey guys, for some reason im getting a funny return from this query: $query = mysql_query("SELECT `balance` FROM `members` WHERE userid = '415'"); echo $query; now it just keeps echoing Resource #6. So I thought it was obviously a problem with my query...but when i go and run the query in phpmyadmin it brings up the result no problems. Its freaking driving me nuts...ive been screwing with it for 2 hrs now. Anyone know why ???
  8. I managed to work around the problem and solved the cockup in my awfull code lol Thanks everyone
  9. ok this is my first go at php pagination and its working.....sort of Here is the guts of my pagination and query code (ive still got things to change like the count rather than just selecting all rows etc). // check to see if page number is set and if not set it. if(isset($_GET[’pagenum’])) { $pagenum = $_GET[’pagenum’]; } else { $pagenum = 1; } //Here we count the number of results //Edit $data to be your query $data = mysql_query("SELECT * FROM `transactions` where `user_id` = $_SESSION[userid]") or die(mysql_error()); $rows_count = mysql_num_rows($data); //This is the number of results displayed per page $page_rows = 6; //This tells us the page number of our last page $last = ceil($rows_count/$page_rows); //this makes sure the page number isn't below one, or more than our maximum pages if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } //This sets the range to display in our query $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; // query transactions database for user history $trans_query = "SELECT * FROM `transactions` where `user_id` = $_SESSION[userid] $max"; $trans_result = mysql_query($trans_query); php?> <h1> User Account History </h1><table cellpadding="10" border="1" rules="rows" frame="void"> <tr> <td>Trans #</td><td>Date</td><td>Liberty #</td><td>Amount</td><td>Type</td><td>Status</td></tr> <?php while ($row = mysql_fetch_assoc($trans_result)) { php?> <tr> <td><?php echo $row['trans_id']; php?></td> <td><?php echo $row['date']; php?></td> <td><?php echo $row['liberty_acc']; php?></td> <td><?php echo $row['amount']; php?></td> <td><?php echo $row['type']; php?></td> <td><?php echo $row['status']; php?></td> </tr> <?php } // end loop php?> </table> <?PHP // This shows the user what page they are on, and the total number of pages echo " --Page $pagenum of $last-- <p>"; // First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page. if ($pagenum == 1) { } else { echo " <a href='history1.php?pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='history1.php?pagenum=$previous'> <-Previous</a> "; } //just a spacer echo " ---- "; //This does the same as above, only checking if we are on the last page, and then generating the Next and Last links if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='history1.php?pagenum=$next'>Next -></a> "; echo " "; echo " <a href='history1.php?pagenum=$last'>Last ->></a> "; } php?> The problem is that it seems to display the results fine...but when i go to click next page etc...nothing happens and it just sits there. The problem is clearly somewhere in the updating of the $max variable which is actually the limit....it doesnt seem to be updating from what i can see...and i just cant see what to fix. Any ideas p.s im really going to have to donate to the site after all the time you guys have been putting into helping me learn some scripting. Cheers
  10. ahhh thats it...now i'm getting it!!! Thanks guys...this place is an awesome resource...btw i looked up print_r in the php manual and me using it was why it was printing out all the extra data cheers again aussie
  11. actually the clearer questions is....is there a way to display the assoc array without it listing the database field or row tags? so that it would just print out the actual field data ???
  12. Ok that seems to work really well without having to specify the databse fields It's displaying: Array ( [trans_id] => 22 [user_id] => 415 [amount] => 125.00 [acc] => 2456743 [type] => withdrawal [date] => Sun, 24 Feb 2008 21:32:43 -0600 [status] => pending ) Any idea how I can format that to look good and without the [] => symbols etc? Thanks again aussie
  13. hey guys, I'm still coming to grips with some fo the php basics and although I have queries down and am able to grab details from the database...i need some help on grabbing multiple data. So say I have a transaction table with data in it...lets say 7 different fields etc and I want to select whole rows when it relates to my userid and then display it how would i go about it? $normal_query = "SELECT * FROM `transactions` where `user_id` = '415'"; $result = mysql_fetch_array($normal_query); php?> <?php echo $result; php?> So pretty much I want to see al the transactions from a specific user etc and then display them on a page...Now I was sticking it into an array but how then do i display it all without having to name each field from the table??? Any ideas for a complete newb ???
  14. Thanks everyone. I managed to get around it and get the script to work. I apologise for all my newbyness
  15. yup i've tried all of those solutions and im still getting a syntax error when i click the submit. 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 '(email, password, phone) VALUES (randomemail@email.com,'c5dedfe8df822a7d3d9103' at line 1 any ideas why i suck at SQL
×
×
  • 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.