Jump to content

nortksi

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

nortksi's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Just thought, Should I try passing the variables in the URL with the form? Is that even possible? Thanks, Mark.
  2. Hi ZulfadlyAshBurn, sorry for the late reply, I've been out of the office over the weekend. I am assuming that the variables have been set as I can display the data being retrieved from my 'businesses' table in the MySQL database. For example; I can display the company name and postcode that these variables hold. Could it be something to do with where abouts in my code these variables are placed? I am in a difficult position because I am signed into a non-disclosure agreement with my employers so I can not reveal to much of my code. Kind regards, Mark.
  3. Hi. Yes an error is reported: Notice: Undefined variable: ii in /content/Hosting/p/l/web/eventresults.php on line 25 Notice: Undefined variable: sr in /content/Hosting/p/lweb/eventresults.php on line 25 Notice: Undefined variable: ii in /content/Hosting/p/l/web/eventresults.php on line 26 Notice: Undefined variable: sr in /content/Hosting/p/l/web/eventresults.php on line 26 These lines are: $Code = $sr[$ii]['postcode']; $Company = $sr[$ii]['company_name']; I hope this can shed some light Regards, Mark.
  4. Hi ZulfadlyAshBurn, thanks so much for taking the time help me! I have implemented the changes you suggested. Unfortunately; it still does not work I have checked the variable and field names which all appear correct. Any other thoughts? Kind regards, Mark.
  5. Ok, having reading up on the suggested material I have gave it a go. However; I am unable to get this working. This is what I have so far: HTML FILE: <script type="text/javascript" src="prototype.js"></script> <script> function sendRequest() { new Ajax.Request("test.php", { method: 'post', postBody: '<?php $Company;?>'+$F('<?php $Company;?>')+'&<?php $Code;?>='+$F('<?php $Code;?>') onComplete: showResponse }); } function showResponse(req){ $('pr_likes').innerHTML= req.responseText; } </script> <body> <div class="pr_thumb"> <?php $Code = $sr[$ii]['postcode']; $Company = $sr[$ii]['company_name']; ?> <form id="test" onsubmit="return false;"> <input type="hidden" name="<?php $Company;?>" id="<?php $Company;?>" > <input type="hidden" name="<?php $Code;?>" id="<?php $Code;?>" > <input type="submit" value="submit" onClick="sendRequest()"> </form> </div> </body> TEST.PHP <?php $companyName=($_REQUEST['$Company']); $postCode=($_REQUEST['$Code']); // connect to the database mysql_connect("*****", "*****") or die(mysql_error()); mysql_select_db("******") or die(mysql_error()); mysql_query("UPDATE businesses SET number_likes = number_likes+1 WHERE company_name = '$companyName' AND postcode = '$postCode'"); ?> It is no doubt incorrect on so many levels. Any helpful pointers will be greatly appreciated Regards, Mark.
  6. Hi voip03, thanks for your reply. Ah right, I'm afraid my knowledge of Ajax is even less than my knowledge of PHP. Just a quick note, I also need to add to the number of likes once the button has been pressed. Regards, Mark.
  7. Hi guys, I am hoping someone can help me with this. I am pretty new to PHP and MySQL but I am learning all the time; however I have become stuck. I am developing a business directory and need to be able to let the user click a 'like' button which will then add to the total number of 'likes' for that business. At the moment I am able to retrieve all businesses and output them to the screen, the current number of likes is also displayed. The brief code for displaying th number of likes is: <div class="pr_likes"><?php echo $sr[$ii]['number_likes'];?> likes</div> <a href="#"><div class="pr_thumb"></div></a> Underneath the pr_likes class is a div that displays a roll over 'thumbs up' image. I realise that instead of this being a hyperlink it will most probably be a form? If possible I want it to add to the total number of 'likes' without leaving the current page as the retrieved businesses are returned randomly and I do not want to scramble the results. All help will be greatly appreciated. Kind regards, Mark.
  8. Thanks for your reply guys! I tried cyberRobot's second suggestion and that worked a treat! Thanks again guys! Mark
  9. Hi guys, may I request some help with a problem I'm having trying to pass results retrieved from a mySQL database as variables in a URL within a loop. At the moment the connection to the database and the query work fine and I can display these results to the screen. Now I want to be able to click on one of these results to query the database again. However the URL being created is: http://www.domainname.co.uk/script.php?event=Array[event_name]&town=middlesbrough As you can see the town is being passed fine but the event name is not. Below is my code: $results=@mysql_num_rows($rt); if ($results > 0) { for ($ii = 0; $ii < $results; $ii++){ $data = mysql_fetch_array($rt); $dr [] = $data; } } if ($results > 1) { $location = $postLoc; for ($ii = 0; $ii < $results; $ii++){ echo '<a href="script.php?'."event=$dr[$ii][event_name]&town=$location".'">'.$dr[$ii]['event_name'].'</a>';?><br /><?php } } I am just a novice so this is probably easily fixed, I would greatly appreciate any help offered. Kind regards, Mark.
  10. OK I couldn't resist, I took my work home and tried removing one of the $nt=mysql_fetch_array($rt); and this did the trick! Thanks PFMaBiSmAd and everyone else for their help, much appreciated If you get time, PFMaBiSmAd, will you be able to explain why having 2 arrays would dicard the first row? Kind regards, Mark.
  11. Thanks for you help guys, I finished work early today and wont be back in until Monday morning. I'll get onto your suggestions first thing monday morning and I'll post the results. Thx again guys. Mark.
  12. Hi, OK I tried this, exactly the same result Thx Mark.
  13. Hi. The first row is not empty. This has really confused me as I know 4 results have been retrieved from the database because I tested it by echoing $results which displayed 4. I have to be careful what I write on here as I'm signed into a non-disclosure agreement so I don't know how much of the code I can put on here. Kind regards, Mark.
  14. Hi WebStyles, thanks for the reply, and tip. However; it still only displays 3 out of the 4 results, again it is the first result in the mySQL database that isn't being displayed. Regards, Mark.
×
×
  • 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.