-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
Ok did some testing and the calander loads up fine if you dont strip the quotes from the json echo json_encode($arr); // just echo the json
-
What Javascript errors are being thrown up in the browsers console. And how are you passing the json to the calendar?
-
You are encoding the json again after the preg_replace. You should be echo'ing it. $json = json_encode($arr); // json encode the array $json = preg_replace('/"([^"]+)"\s*:\s*/','$1:',$json); // strip quotes from keys echo $json; // echo the json
-
The json you want doesn't have quotes around the keys. This you cant prevent json_encode from doing. Where is this json being used? I guess this is for a response to an ajax request, but JavaScript is not decoding the json due to the quotes around the array keys. You can use regex to strip the quotes http://stackoverflow.com/questions/8837659/remove-double-quotes-from-a-json-encoded-string-on-the-keys?answertab=votes#tab-top Or if you're using jQuery for the ajax you can use $.parseJSON.
-
PHP selecting a single value from several columns in mysql
Ch0cu3r replied to designsweb's topic in PHP Coding Help
Your database design is not the best, but you'll need to compare each column to $client. $sql=mysql_query("SELECT * FROM routes WHERE client_a = '$client' OR client_b = '$client' OR client_c = '$client' OR client_d = '$client' OR client_e = '$client' OR client_f = '$client' OR client_g = '$client' OR client-h = '$client' ORDER BY date DESC"); Ideally you'll want to redesign your database so each time you add a client to a route you'd create a new row in a different table. Not list each client in individual columns per route. I'd setup three tables, clients, routes and client_routes The clients table stores all the information about that client, such as name, address, username, password, email etc The routes table stores the information about that route, such the location, time of day etc. When you add a client to a route you create a new row in the client_routes table. Here you'll record the primary key for the client and the primary key for the route they are assigned to. You'd then query the client_routes table to get all the routes they are assigned to, you'd use a JOIN to get the details from the client and routes table. Eg SELECT c.name, # get the client name r.area, r.date, r.missed, r.agent, # get the route area, date, missed and agent FROM client_routes cr # query the client_routes table JOIN routes r ON r.id USING(cr.route_id) # get the route that matches the route id JOIN clients c ON c.id USING(cr.client_id) # get the client that matches the client id WHERE cr.client_id = $client_id # select the client_routes that matches the client id -
$Option['agents'] should be $Option['Agents] function extractItem(&$array, $itemkey) should be function extractItem(&$array, $itemKey)
-
You'd use dateTime:diff to get the difference between the two days Have a look at this post for example http://forums.phpfreaks.com/topic/285692-php-math-help/?do=findComment&comment=1466636
-
I didnt notice this earlier your if statement is outside of the <?php ?> tags <?php $count = 1;foreach($classes as $row): if ( $row['status'] != 'completed'): ?> <tr><td><a href="<?php echo $row['deep_link'];?>" target="_blank"> <?php echo get_phrase('launch');?> </a> </td></tr> <?php endif; endforeach;?>
-
$status should be $row['status']
-
You seem to be calling mysql_fetch_row twice $row=mysql_fetch_row($result_id); while ($row=mysql_fetch_row($result_id)) Remove the while loop so you code is $row=mysql_fetch_row($result_id); print "<td>$row[0]</td>"; print "<td>$row[1]</td>"; print "<td>$row[2]</td>"; print "</tr>\n"; While loop is only necessary if your query returns more than one row.
-
Thats fine you can still pass in the id as part of the link. The querystring (the text after ?) in a link can pass more than one piece of info. Could you tell us what $row[1], and $row[2] are and the name of php page you want to display the surname on.
-
By look up I mean loop through the array of carriers within $array['Carriers']. You'd check to see if the Id matches the carrier for the flight Id. The easiest way I found to do this was to create a function. It'll extract the Agents, Carriers, Legs and Places arrays. It'll then loop through these arrays setting the Id as the key for each item. This makes looking up the ids for Agents, Carriers, Legs and Places arrays alot easier as you can just pass in the necessary id to get their data. Example code for getting the agent names $Agents = extractItem($array, 'Agents'); // get array of agents //... foreach ($array['Itineraries'] as $Itineraries) { foreach($Itineraries['PricingOptions'] as $Option) { echo "<b> Agents: </b> "; // loop over agents for current priceOption foreach($Option['agents'] as $agentId) { echo $Agents[ $agentId ]['Name']. ', '; // echo the agent name that matches agentId. } echo " <br> price </b>",$Option['Price'] ,"<br />"; } } The code for extractItem() is function extractItem(&$array, $itemkey) { $data = array(); foreach($array[$itemKey] as $item) { $Id = $item['Id']; // get the id unset($item['Id']); // remove the id from item array $data[$Id] = $item; // set id as the key } unset($array[$itemKey]); // remove item from array. return $data; // return the new item array }
-
The code you posted is incomplete. Is that all your code? Also paste code into tags.
-
The Itinerary array contains a list of flights. Each flight contains a PricesOption array which lists the booking agents and their price. Each agent has their own unique id, to get the agent name/image you need to look up the agent id within the $array['Agents'] array. To get the flight information you need to look up the OutboundLegId and InboundLegId within the $array['Legs'] array. This will return an array of information about depature and arrival airports. The OriginStation (departure) and DestinationStation (arrival) keys return the airport ids. To the get the airport names you need to look up these ids within the $array['Places'] array. You'll also get the flight carrier from the $array['Legs'] array, again each carrier has their own unique id which you you need to loop up within the $array['Carriers'] array. .
-
You need to contain your HTML within CDATA. Otherwise the XML parser thinks it is part of your XML structure and so you'll get validation errors. $str.= '<description><![CDATA['.$row->content. ']]></description>'; Alternatively convert the html to htmlentities
-
show data in search without using submit button
Ch0cu3r replied to eloginko's topic in PHP Coding Help
If you dont want the page to refresh then you'll need to use AJAX. Search google for Ajax live search for examples. -
I guess you're using myArcadePlugin for Wordpress. To make the Related Games games tab show by default you need to set the tigu_related option to true. There should be setting for which tab to show by default in the myArcadePlugin control panel.
-
For displaying the Legs, Carriers and Places you don't need the secondary foreach loop. Also $Option['Agents'] contains an array of agents, to display these implode them. //Itineraries foreach ($array['Itineraries'] as $Itineraries) { foreach($Itineraries['PricingOptions'] as $Option) { echo "<b> Price </b> " .implode(',', $Option['Agents']), " <br> price </b>",$Option['Price'] ,"<br />"; } } //Legs foreach ($array['Legs'] as $Leg) { echo "<b> Departure </b> " .$Leg['Departure'], " <br> <b>Arrival </b>",$Leg['Arrival'] ,"<br />"; } //Carriers foreach ($array['Carriers'] as $Carrier) { echo "<b> Name </b> " .$Carrier['Name'], " <br> Image </b>",$Carrier['ImageUrl'] ,"<br />"; } //Places foreach ($array['Places'] as $Place) { echo "<b> Code </b> " .$Place['Code'], " <br> Name </b>",$Place['Name'] ,"<br />"; } Also checkout the code I sent you in PM
-
If you know where the mic is you should be able to pull the ribbon cable (it will most likely disable the webcam too) out that connects to it from the main board.
-
issue with outputting a text file..please help
Ch0cu3r replied to zoomzoom9's topic in PHP Coding Help
/[^a-zA-Z]+/ is replacing any non letter character into a space, removing all punctuation within the line. -
issue with outputting a text file..please help
Ch0cu3r replied to zoomzoom9's topic in PHP Coding Help
First str_replace does not take a regex pattern for the first (search) argument and the subject string should be the third argument. You should use preg_replace instead for regex $line = trim(preg_replace('/[^a-zA-Z]+/', ' ', $line)); Second you are echo'ing the result of fwrite, which is the number of bytes written. Not the text that was written. Change the if/else to $line .= " - This is " . (($line == $reverse) ? 'a' : 'not a') ." palindrome.\n"; // append this to current line echo "$line<br/>"; fwrite($out, $line); -
You need check the code within your includes. As Mace said that is most probably where it is coming from. To tell which one it could possible be change your your include lines to echo '--'; echo 'db<br>'; include_once 'includes/db_connect.php'; echo 'func<br >'; include_once 'includes/functions.php'; echo 'sess<br >'; include_once 'includes/session_management.php'; echo '--'; Which ever the number 67 appears against that it is file you need to check. Basically look for an any echo/prints's within that file.
-
Try setting json_decode to $array = json_decode($data, true); You'd loop over the itinerary price options using foreach ($array['Itineraries'] as $Itineraries) { foreach($Itineraries['PricingOptions'] as $Option) { echo "<b> Price </b> " .$Option['Price'], " <br> price </b>",$Option['Price'] ,"<br />"; } }
-
You'd store the categories in a separate table. You'd add an extra field to your images table to store the category id. That way you only need to update category name in one place, the categories table. Any image that references that category will also be affected. This is called a 1 to many relationship. You add a WHERE clause condition. Example SELECT c.cat_name, # get category name from category table (c) i.img_path # get the image path from image table (i) FROM images i LEFT JOIN categories c ON c.id = i.cat_id # get category name where the cat id matches in both tables WHERE i.cat_id = $cat_id # only get images that matches this category
-
Upgraded to PHP 5.3 3 and now an error occurs in one bit of code
Ch0cu3r replied to fivebelly's topic in PHP Coding Help
Post lines 145 to 160 (last 15 lines). Not the whole file.