Jump to content

acefirefighter

Members
  • Posts

    33
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

acefirefighter's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I was looking for my two day old post with no replies and I found yours so here is my 2 cents. I am not 100% sure and I may be way off base but it seems to work in my head and my syntax for preg_match may not be right on either. I don't use reg-ex that often. <?php $feed = simplexml_load_file('http://video.news.com.au/feed.atom'); $pattern = '/href="(.)*"/'; $link = preg_match($pattern, $feed->entry->link); echo $link; ?>
  2. I am really not sure if this is a problem with me (probably is), php or mysql. I have a calendar that I am adding events to. If I want to edit only the date I can but only once after I make this update I am out. If I attempt to update the time or event title the database is never updated and I am no longer able to update the date. here is the controller for the save. <?php function eventsave() { $details = $_POST; $this->load->model('eventsmodel'); $this->eventsmodel->eventsave($details,'', TRUE); redirect('/admin/events', 'location'); } ?> I have turned off the redirect to see if I was getting any errors and they seem to be non existent. Here is the model that is used to create a new entry and update a record. <?php function eventsave($event) { $startdate = explode('-', $event['startdate']); $start = mktime($event['starthour'], $event['startmin'], 0, $startdate['0'], $startdate['1'], $startdate['2']); $end = mktime($event['endhour'], $event['endmin'], 0, $startdate['0'], $startdate['1'], $startdate['2']); $name = $event['name']; if (isset($event['id'])) { // if is true then this is an update not a new event $data = array( 'name' => $name, 'start' => $start, 'end' => $end ); $this->db->where('id', $id); $this->db->update('events', $data); }else{ $this->db->set('name', $name); $this->db->set('start', $start); $this->db->set('end', $end); $this->db->insert('events'); } } ?> I am using code igniter if that helps and the information being submitted by the form looks good. This is the submitted update array and the new event array is just missing the "id" Array ( [name] => test [startdate] => 05-14-2011 [starthour] => 1 [startmin] => 0 [endhour] => 1 [endmin] => 0 [id] => 54 [saveevent] => save ) Any suggestions would be appreciated. Thank you.
  3. It's actually not your second HEREDOC; that is the problem, it is your first. The first one has an extra space after the ending semicolon. and that is why you are getting the error. Remember NOTHING can go on the same line as the closing HEREDOC or it is considered to be part of the same statement.
  4. I like that. It is way better than what I came up with. Nice one.
  5. Something like this maybe? not sure if it is necessarily more efficient. Just run something like this in a while loop right after you pull the values from the database they will still be in an array. <?php $array = array( 'first' => 'John', 'middle' => '', 'last' => '' ); // this cycle echoes all associative array // key where value equals "apple" $i = 0; foreach ($array as $row) { // Fixed Problem with array position. if($i == false) { reset($array); $i ++; } // check for empty array values, echo and change value to not assigned if (empty($row)) { $key = key($array); echo $key.' is empty<br />'; $array[$key] = "Not Assigned"; } next($array); } foreach ($array as $row) { echo $row .' '; } ?>
  6. I'm sure we can get this to work for you but I am having a really hard time picturing what you are describing. Can you provide a link or a screen shot of what you have and one of what you are trying to accomplish? I thought I understood but I must have had it wrong.
  7. Ya you can, Try this. I haven't tested but I think it will get you what you are looking for. <?php $i = 0; while($row = mysql_fetch_array($sql)){ $tr = ($i % 2) ? '<tr>' : ''; $trclose = ($i % 2) ? '</tr>' : ''; $id = $row["id"]; $product_name = $row["product_name"]; $price = $row["price"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); $dynamicList .= '<table width="100%" border="2" cellspacing="2" cellpadding="2"> '.$tr.' <td width="17%" valign="top"><a href="product.php?id=' . $id . '"><img style="border:#666 1px solid;" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="77" height="102" border="2" /></a></td> <td width="83%" valign="top">' . $product_name . '<br /> $' . $price . '<br /> <a href="product.php?id=' . $id . '">View Product Details</a></td> '.$trclose.' </table>'. $i++; } ?>
  8. This isn't really a php question but more for JavaScript especially if you aren't wanting the page to reload all of the time. I use what is called jQuery and I have a few pages for you to look at and maybe you can sort out what you want to do. http://api.jquery.com/click/ http://api.jquery.com/show/ http://api.jquery.com/hide/ If you aren't wanting to use a database and aren't wanting to use files you can place all of your information that you want hidden in a div and "hide" it until a user "clicks" on the image and that would trigger the "show" if you were wanting to run from files I would look into jquery's post function but then you are getting into using an xml or json return which might just be overkill unless you have a ton of data. Look at the code on this page too. It is for a tabbed menu but the same concepts can be utilized and the code is easy to sort out. http://yensdesign.com/2008/12/create-a-smooth-tabbed-menu-in-jquery/ and here is one that explains what is happening in the jquery a little better and talks about jquery post http://www.jasonbrennan.com/jquery/jquery-ajax-or-is-it-jquery-json/ Sorry about the rambling. I hope this gets you started. I may be a little slow to respond but I will get back to you.
  9. Try this I added array_pop() it should remove the last element of the array. but I am guessing that submit_query is the last element in the $_POST array. <?php $criteria = array(); if(!empty($_POST)) { array_pop($_POST); foreach ($_POST as $_POST) { if (!empty($_POST)) { array_push($criteria, $_POST); } } $userserch = implode('</strong> > <strong>', array_map('htmlentities', $criteria)); } ?>
  10. Can you post an example of the data you are trying to analyze, It would help greatly.
  11. You could use a foreach loop and empty() to check and see if each element in your $_POST array is empty and if it is don't use it. Maybe even use array_push() to apply the results that aren't empty to a new array and implode that new array with the html you are wanting to use. Something like what is below. I haven't tested it but I think it should work. <?php $criteria = array(); if(!empty($_POST)) { foreach ($_POST as $_POST) { if (!empty($_POST)) { array_push($criteria, $_POST); } } $userserch = implode('</strong> > <strong>', array_map('htmlentities', $criteria)); } ?>
  12. Look here http://php.net/manual/en/function.date.php It is extremely simple.
  13. Something like one of these should work for you. They will alert as soon as the page loads. If you didn't want the $php_value in an input tag for validation reasons you could always place it in a div with display:hidden;. This isn't strictly "javascript" since you can see I loaded jQuery I am using the syntax for that. I like the second option a lot more than the first just because I am not having to send the JS to the view with a variable. <?php // Option One $php_value = 'username'; $script = <<<EOT <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { alert('$php_value'); }); </script> EOT; ?> <html> <head> <?php echo $script; ?> </head> <body> </body </html> <?php // Option Two $php_value = 'username'; ?> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { var alert_value = $("#username").attr('name'); alert(alert_value); }); </script> </head> <body> <input type="hidden" id="username" name="<?php echo $php_value;?>" />
  14. It may be because your file path isn't right ex... if your images are stored at http://www.yourSite.com/_images/ and the page you are on is http://www.yourSite.com/california/shopping/ then your script is looking for the images in http://www.yourSite.com/california/shopping/_images/ Im not sure if that is the case but I would bet on it. your going to have to define more of your path to the image. I pull everything through the my base index.php file so I don't usually have to deal with this. Anyone feel free to chime in if I am wrong.
×
×
  • 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.