Jump to content

allydm

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Everything posted by allydm

  1. Hi there. I have a select query pulling information from my table correctly on most pages apart from a few, and my problem has really confused me. Basically, the pages contain a sports league tables and the info is pulled out on every page load. To best explain the problem, i've taken a screen shot of it... [img]http://www.allydm.co.uk/images/php-problem.gif[/img] Now, the problem is that it is falsly executing, as i specify that the home_team_score should be greater than the away team score...HOWEVER as you can see in the result that it gets, the home_team_score is 3 whereas the away_team_score is infact 12. Any ideas why this is happening?
  2. Yes, the first bit would go on the login page....in the part of the code where you telling the php what to do if the user logs in correctly.
  3. Have you set the variable $Courriel, because i don't see it anywhere in the code above.
  4. Well as you havn't mentioned if you have built a login form or not, i'm going to leave that stage out for the moment. Basically, you need a user to enter there information, check it and then if its true set session variables. So, presuming that you know how to check that a users password matches the one they've entered, the next stage would be [code]<?php session_start(); if ($submitted_password = $_POST['password']) { $_SESSION['user_id'] = $login_info['user_id']; } ?> [/code] That would then set a session variable. Remember: you should [b]never[/b] store a users password in a session variable. Then, at the start of each page you need to check if $_SESSION['user_id'] is set or not, and if its not then tell them to login. Such as this: [code] <?php session_start(); if (empty($_SESSION['user_id'])) { header("Location: login.php"); } ?> [/code] That would send a user to login.php if they havn't logged in. Its not 100% secure, but its a good start for you.
  5. You could use a combination of [b]$_SERVER['PHP_SELF'][/b] and [b]preg_replace()[/b]. The $_SERVER['PHP_SELF'] would tell you the url, excluding the www.phpfreaks.com (for example), and then you could just tell the preg_replace() function, to look for /somefolder/thispage.php in the $_SERVER['PHP_SELF'] result, and then replace if with nothing. The result would be that you have the anotherpage.php?stuff here Just incase i wasn't too clear (i got lost with myself above  :)) It would be something like. [code]$full_file_name = $_SERVER['PHP_SELF']; $file_name = preg_replace('/somefile/, '', $full_file_name);[/code] That would remove any proceeding folder name (which i have called somefile) and leave you with the file name. That won't work, but it hopefully shows you a process that you could go through.
  6. Hi people. Basically, i'm building a gallery which pulls 9 images per page. I've coded the pages so that 9 results are displayed per page and thats all working marvelous. However at the moment they're all one after the other going vertically down the page via a loop. I'd like to make it look nicer, by creating a 3 x 3 table and having the results display in the box. Heres an image of what i'd like to achieve. [img]http://www.allydm.co.uk/images/demo1.jpg[/img] I'm not sure how to go about doing this, have any of you got any ideas? I started off with two loops, one going horizontally while the other goes down vertically however that got messy and didn't work. Thanks for any suggestions. Alex
  7. Hi. Unfortunatly it is still not showing even when the 'Other' option is selected. Any ideas? Thanks.
  8. Hi there. I have a form with a drop down selection box, and if someone selects the option in it called 'Other' then i would like a text entry box to appear. So far i have... [code]<select name="subject" id="subject">     <option value="Purchasing Artwork">Purchasing Artwork</option>     <option value="Viewing Artwork">Viewing Artwork</option>     <option value="Commissions">Commissions</option>     <option value="Other" onSelect="document.getElementById('iAmHidden').style='visibility:visible;';" />Other</option> </select> <div style="visibility:hidden; display:none;" id="iAmHidden"> <input name="reason" type="text" id="reason" value="Please Specify"> </div>[/code] However this isn't achieving the effect i'm after (the box won't display!). Can anyone see why? Or suggest a better code. Thanks for any help guys/gals. Alex.
  9. You could use Javascript to do it instantly on the page as it's entered. Depending on how you 'define' the $_POST variables on the form you could have it do the calculations on loading the page (which i presume is a shopping basket or something). If you could use the code for the page that posts the data we may be able to give you some code.
  10. Hi. I have a table, which contains 'setting' information for my website. The table has the following columns: setting_id, setting_name and setting_value. Now there are currently 30 rows stored in this table, however i am having trouble pulling rows out on a 'as needed' basis. At the moment i have this select query:     $settings_query = "SELECT * FROM `robin_settings`";     $settings_result = mysql_query($settings_query); And from that, i would like to pull individual results, for example... I have a setting which has a 'setting_id' of "4", a 'setting_name' called "banner_on" and a 'setting_value' of  "1". How am i able to pull that information from the results i get? I know i could pull it by putting a WHERE clause on the SQL query, however that would mean having 30 select queries per page and i don't really fancy that! Thanks for any help! (i'm new at this :) ) Alex.
  11. Here is the section of code: [code] $i = 1; $product_query1 = "SELECT * FROM `robin_basket` WHERE session_id = '".session_id()."'"; $product_result1 = mysql_query($product_query1) or die (mysql_error() ); $product_info1 = mysql_fetch_assoc($product_result1); while($product_info1 = mysql_fetch_assoc($product_result1)) {   echo "<input type='hidden' name='item_name_$i' value='{$product_info1['product_name']}' />         <input type='hidden' name='amount_$i' value='{$product_info1['product_price']}' />";   $i++;   } [/code] I have changed the name of the variables from $product_info to $product_info1,  just so that i could differenciate between them. I really do appreciate your help with this
  12. We have progressed! Okay, now i'm getting two of the three items information sent through, however one of the items isn't. Items: item_name_1 item_name_2 i am getting, but i'm not getting: item_name_3 Now i've tried all sorts of combinations (been up to item_name_11), tried item_name, item_name_, item_name_0 however the third item just dosn't seem to appear. Any ideas why? There are 3 rows fetched by the query, and 3 items are shown by the same query earlier in the page, but not here.
  13. [quote author=Barand link=topic=106879.msg428089#msg428089 date=1157410728] Are you looping through the query results in the code before getting to this bit? [/quote] I am, as it displays the current cart contents in a table further up the page...is this a problem?
  14. That outputs... "There are 3items"
  15. Hi. $product_query is being executed correctly, and the query is returning results. Is there any more information i should provide to help with this?
  16. No i hadn't! Sorry. Basically, non of the php generated stuff is showing on the form. The entire code for the form is... [code] <form name="_xclick" action="test1.php" method="post"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="upload" value="1"> <input type="hidden" name="business" value="******"> <input type="hidden" name="currency_code" value="GBP"> <?php while($product_info = mysql_fetch_assoc($product_result)) { echo "<input type='hidden' name='item_name_[$i + 1]' value='{$product_info['product_name']}' /> <input type='hidden' name='amount_[$i + 1]' value='{$product_info['product_price']}' />"; $i++; } ?> <input type="image" src="******" border="0" name="submit"> </form>[/code] However only this... [code]   <form name="_xclick" action="test1.php" method="post"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="upload" value="1"> <input type="hidden" name="business" value="*******"> <input type="hidden" name="currency_code" value="GBP"> <input type="image" src="*******" border="0" name="submit"> </form>[/code] is there on the page source. Any ideas why? I can't see...the echo seems valid. *edit* The rest of the code is further up the page, and reads as... [code] $i = 1; $product_query = "SELECT * FROM `robin_basket` WHERE session_id = '".session_id()."'"; $product_result = mysql_query($product_query);[/code]
  17. I understand that, and when i inputted the code i changed the "name" and "price" to the correct column values. The two columns are called product_name and product_price. However the code still does not seem to work.
  18. Thankyou for the replies, unfortunatly the code above dosn't seem to work. The contents of the cart arn't sent to the page (i have checked and its not the 3rd party payment processor not working). The post data (that the php code above generates) isn't sent, i have added another field to the form to see if the form completely wasn't working, but the other field does work. Any ideas?
  19. Hi there. I'm building a shopping cart, and it needs to be intergrated into another piece of software (not made by me so i can't change how it works). Basically, when someone clicks 'Buy' on the shopping cart on my site, i need all the information on that shopping cart to be passed to the payment processor made by the other company. They require post information, to be sent in this format: <input type="hidden" name="item_name_X" value="Item"> <input type="hidden" name="amount_X" value="Price"> This information is required for each individual item, so say someone bought 2 items, the form would have to look like this: <input type='hidden' name='item_name_1' value='Medium Ceramic Pot' /> <input type='hidden' name='amount_1' value='18.00' /> <input type='hidden' name='item_name_2' value='Small Ceramic Pot' /> <input type='hidden' name='amount_2' value='14.00' /> Notice how the item_name_1 changes to item_name_2 for the second item. All the information on the items in the cart is collected from this query: [code]$product_query = "SELECT * FROM `robin_basket` WHERE session_id = '".session_id()."'"; $product_result = mysql_query($product_query); $product_info = mysql_fetch_assoc($product_result);[/code] So i need the form to be automatically generated for each item in the cart, with the item_name and amount incrementing by 1 for each new item. Hope you understand, if you don't just tell me which bit you need clarification on (would really like to get this sorted). allydm
  20. Thankyou! Works like a charm. Think i'll go check out all the mysql functions now see if there are any more gems to make the coding easier. Thanks again.
  21. Hi there. I have a select query [code] $total_query = "SELECT `product_price` FROM `robin_basket` WHERE session_id = '".session_id()."'"; $total_result = mysql_query($total_query); $total = mysql_fetch_assoc($total_result); [/code] Now this query returns 3 results (as it should). However i need to add those three results together, and i'm not sure how to do this. The results are: 105 105 105 So the total of them all should be 315. I have attempted to solve this problem, by using the following code: [code] do { $total_minus_shipping = array_sum($total); } while ($total = mysql_fetch_array($total_result)); [/code] However, this only adds two results (giving me a total of 210) and not all three added together (which would result in 315). If someone could explain to me how to get the results to add up correctly i'd be greatful. Allydm.
×
×
  • 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.