so I know basic PHP, I coded a basic mysql/php inventory system awhile ago. I want to get more experience. My idea is to grab reddit comments, display them on a page, and then save them in a database. My problem is I don't know how to grab and make sense of JSON data.
For example, here is a JSON link to a reddit thread: http://www.reddit.com/r/blog/comments/117ckb/introducing_three_new_hires/.json
Goal:
INPUT BOX -> reddit unique thread id in input box (http://www.reddit.com/r/blog/comments/<6 digit unique ID>) -> loads reddit comments on the page
That's my current goal, would really appreciate a nudge in the right direction with processing JSON. I know I COULD just Google it, but I'm posting in hopes of someone having experience with the above and offering their expertise on the topic.
Here's a starting point:
$download=json_decode(file_get_contents('http://www.reddit.com/r/blog/comments/117ckb/introducing_three_new_hires/.json'));
foreach ($download as $articles){
foreach ($articles->data->children as $article){
print_r($article);
}
}
Please note: I recommend using Curl instead of get_file_contents() - it's a lot faster!
Related
I have little experience with mysql, I wouldn't be asking this question if I knew how to actually store the searches in the first place. I basically have a simple search bar that's not a "real search engine" it just redirects you to an already existing page under the name of what you searched using header('location: $term').
Anyway what I'm aiming to do is store the searches in a database and echo the most recent 5 on a different html page. If anybody could help I'd very much appreciate it, thanks!
Sorry if this wasn't explained very well, I'm kind of new to coding.
I'm new at php so maybe this question looks dull but i hope everybody can help me.
This is original link
I want to get data from Odds Column as attached picture
When i Choose Crow or Sbobet or Bet365... data of Odds Column will change. I want to collect data of each column and put it into an different array.
I actually don't need a code, just need a solution or recommendation. Thank guys for reading my question.
I am trying to create a forum on my page. I need some advice. I have MySQL database and I am able to to work with it. Yet as far as I can make is playing with POST. I mean on click submit a $_POST['submit']) becomes set and so on. Then connect to database, get info and display.This way of making a forum is bad, because it all happens on a single page. As far as I seen any other forum when entering one and so on has it's unique Uri (what comes after domain.com/) so you can simply send someone full url and they are in that thread (unlike if you play with $_POST['submit']).
Sorry if my question is not accurate and I am not asking to write me code. I just need someone to direct me to the right place and any advice would be helpful. Thanks !
Your question is difficult to understand, but I think you are confused about how data and pages are dynamic using GET/POST.
The URLS with different IDs are like an illusion. Really, its the same page, however the page is dynamically taking that ID from the URL, and using it to output certain data.
For example, say we habe the URL: www.example.com/show_thread.php?thread=3
The php would look like
if(isset($_GET['thread'])){
$data = $db>query("SELECT thread_title,thread_text FROM threads WHERE thread_id = $_GET['thread']");
print($data);
}
*Warning: do not use this exact code, it is an example, not secure, etc
Then the database would look like
thread_id thread_title thread_text
1 kngwihywoihwy kngwihywoihwykngwihywoihwy
2 vyfngoieyoiehyon ieonuwrtoi hunwrmt jirwyji
3 nuoaiefguneoihn eoithneiotheo
and the page would show
nuoaiefguneoihn eoithneiotheo
POSTing data is for sending it to the server, and doing something with it. Just like GET. However, GET is helpful for passing things around as they are accessible in links. Like this example.
This is kinda confusing, so forgive me if you don't understand what I am asking. I'm trying to develop my skills and I wanted to move onto images as a next step. I did a bit of searching and I thought a good way to try this would maybe be to generate military ribbon racks depending on the options the user selects.
(See something like this as an example: http://www.ribbon-rack-builder.com/ribbons/build/4)
Now, from looking at the source code I can see that the creator of that website creates a form with all of the different ribbons and allows the user to select the ones they want with checkboxes. This form is then posted to some PHP on the page somewhere.
Being new to the image concept I have no idea what kind of PHP this would be. Could anyone give me an idea of how this website could do this and where I should start should I want to create something similar?
Thanks very much!
First, you'll need to get which checkboxes were checked:
Set the name in the form to check_list[] and you will be able to
access all the checkboxes as an array($_POST['check_list'][])
Second, you'll most likely want to use the GD and Image Functions built into PHP.
There is a lot there, and it can be confusing, so I suggest you do some reading through questions on SO on the subject: https://stackoverflow.com/search?q=merge+image+[php]
http://developers.facebook.com/docs/reference/rest/links.getStats/
Okay I have looked at the site above. but im still having some trouble.
I have formated what I need like this
http://api.facebook.com/restserver.php?method=links.getStats&urls=dogtags.com.com,http://www.petsmart.com
My only issue is I need this data to be picked by the zip code another words I only want to see how many likes are on the url http://www.petsmart.com in the zip code 66614. How can I add that variable to the xml data displaying
Thank you all help is greatly appreciated
You are using an outdated facebook API. I would recommend implementing:
http://developers.facebook.com/docs/reference/api/insights/
However, I do not believe there is any way to to look at data from a specific zip-code using the facebook insight API