Jump to content

headmine

Members
  • Posts

    40
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

headmine's Achievements

Member

Member (2/5)

0

Reputation

  1. Exactly what I needed. I knew about spaces and a str_replace is exactly what I was going to do. Thanks so much for your help.
  2. I have a string of Data. Inside this string there is a line of text that says Where: 1234 Main Street. What I would like to do is grab the address that comes after "Where:" and have the output with a link to google maps ex Where: <a href="http://maps.google.com?q=1234+Main+Street">1234 Main Street</a> Would I use preg_replace for this? Or am I attacking this the wrong way?
  3. Ok. I got it. So here it is for anyone else that might run into this problem $sql = "SELECT value2, COUNT(value2) as total FROM mydb WHERE value1 = 'state' GROUP BY value2" foreach ($sql as $state) { echo $sql->meta_value . ' (' . $sql->total .')<br />'; } This would echo: state (count) CA (3323) NV (93) etc.
  4. OK. I've gotten it this far. SELECT value1, COUNT(value2) FROM mydb WHERE value1 = 'state' GROUP BY value1" foreach ($v as $vn) { echo $vn->value1 . '<br />'; } This prints out each state listed . How do I get the numbers next to it? Any help would be appreciated!
  5. OK! Breakthru! I was able to do this within the SQL database. SELECT value2, COUNT(value1) As total FROM mydb WHERE value1 = 'state' GROUP BY value2 When I do this in SQL it works beautifully! It breaks down the states and how many records there are for each. When I do this in php. I only get the first Value! =( How do I get it to display all the values? THANKS!
  6. I have a database with 4 fields. Primary Key, Userid, Value1, Value2 Userid holds the User Id for the site. Value one is basically anything. It could be state, zip, phone etc. Value2 relates to Value1. I would like to make an sql query that would echo each UNIQUE Value2 and display a Count next to it which represents how many times it's duplicated. Example: CA(200) NY(300) TX(250) etc. Here's what I have so far. SELECT COUNT(DISTINCT value2) FROM mydb WHERE value1 = 'state' This returns 43 Which is probably correct because there are only 50 states in the U.S. Do I need a foreach loop? Please help. Thanks in Advance!
  7. Sorry output is: <?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Headmine</title><description>Example of a RSS feed.</description><link>http://headmine.org</link><copyright>Copyright (C) 2009 headmine.org</copyright><item><enclosure length="1234567" type="image/jpeg" url="http://johnregalado.com/the-test/a-river-runs-though-it.jpg" /><url>http://headmine.org/the-test/a-river-runs-though-it.jpg</url></item><item><enclosure length="1234567" type="image/jpeg" url="http://johnregalado.com/the-test/mark-ruhi.jpg" /><url>http://headmine.org/the-test/mark-ruhi.jpg</url></item><item><enclosure length="1234567" type="image/jpeg" url="http://johnregalado.com/the-test/mark.jpg" /><url>http://headmine.org/the-test/mark.jpg</url></item><item><enclosure length="1234567" type="image/jpeg" url="http://johnregalado.com/the-test/namrok.jpg" /><url>http://headmine.org/the-test/namrok.jpg</url></item></channel></rss>
  8. I've made a few edits.... Here is the link to the page: http://headmine.org/the-test/index.php I've only been able to get the icons to show with links. I'd like the images to display. here is the updated code <?php $channel = array("title" => "Headmine", "description" => "Example of a RSS feed.", "link" => "http://headmine.org", "copyright" => "Copyright (C) 2009 headmine.org"); foreach (glob("*.jpg") as $filename) { $items[] = array("img" => $filename); } $output = '<?xml version="1.0" encoding="ISO-8859-1"?>'; $output .= '<rss version="2.0">'; $output .= "<channel>"; $output .= "<title>" . $channel["title"] . "</title>"; $output .= "<description>" . $channel["description"] . "</description>"; $output .= "<link>" . $channel["link"] . "</link>"; $output .= "<copyright>" . $channel["copyright"] . "</copyright>"; foreach ($items as $item) { $output .= "<item>"; $output .= "<enclosure length=\"1234567\" type=\"image/jpeg\" url=\"http://johnregalado.com/the-test/". $item["img"] ."\" />"; $output .= "<url>http://headmine.org/the-test/". $item["img"] ."</url>"; $output .= "</item>"; } $output .= "</channel>"; $output .= "</rss>"; header("Content-Type: application/rss+xml; charset=utf-8"); echo $output; ?>
  9. I don't understand? Like this foreach ($items as $item) { $output .= "<items>"; $output .= "<item>"; $output .= "<content><img src=\"http://LOCATION/" . $item["img_local"] . "\" /></content>"; $output .= "</item>"; $output .= "</items>"; }
  10. When you view the file through a web browser it looks like a feed but no images show up. If I remove <img src= etc then the name of the files will appear. But as soon as I add img tags everything disappears.
  11. What im trying to do is create a dynamic rss image feed based on images within a folder. Your array fix helped me but its . Still not working foreach (glob("*.jpg") as $filename) { $items[] = array("img_local" => $filename); } $output = '<?xml version="1.0" encoding="ISO-8859-1"?>'; $output .= '<rss version="2.0">'; $output .= "<channel>"; $output .= "<title>" . $channel["title"] . "</title>"; $output .= "<description>" . $channel["description"] . "</description>"; $output .= "<link>" . $channel["link"] . "</link>"; $output .= "<copyright>" . $channel["copyright"] . "</copyright>"; foreach ($items as $item) { $output .= "<item>"; $output .= "<content><img src=\"http://LOCATION/" . $item["img_local"] . "\" /></content>"; $output .= "</item>"; } $output .= "</channel>"; $output .= "</rss>"; header("Content-Type: application/rss+xml; charset=ISO-8859-1"); echo $output;
  12. Is there an easier way to do this? I am trying to get create a dyamic array based on files within the folder. foreach (glob("*.jpg") as $filename) { $items = array("title" => $filename) } $output = '<?xml version="1.0" encoding="ISO-8859-1"?>'; $output .= '<rss version="2.0">'; $output .= "<channel>"; $output .= "<title>" . $channel["title"] . "</title>"; $output .= "<description>" . $channel["description"] . "</description>"; $output .= "<link>" . $channel["link"] . "</link>"; $output .= "<copyright>" . $channel["copyright"] . "</copyright>"; foreach ($items as $item) { $output .= "<item>"; $output .= "<title>" . $item["title"] . "</title>"; $output .= "</item>"; } $output .= "</channel>"; $output .= "</rss>"; header("Content-Type: application/rss+xml; charset=ISO-8859-1"); echo $output; ?> This doesn't even work correctly.
  13. Never mind. I've asked about this before and just found my answer. Anyway to delete this?
  14. Ok new problem... The form Needs to collect Company Name, and Contact Number(s). So Here is the form. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Insider Tips and Updates</title> <script> function addElement() { var ni = document.getElementById('myDiv'); var numi = document.getElementById('theValue'); var num = (document.getElementById('theValue').value -1)+ 2; numi.value = num; var newdiv = document.createElement('div'); var divIdName = 'my'+num+'Div'; newdiv.setAttribute('id',divIdName); newdiv.innerHTML = '<input name="aNumber[]" type="text" id="aNumber" size="12" /> <select name="aNumber[]"> <option value="Option">Option</option> <option value="Extension" selected="selected">Extension</option> </select> <input name="extOp[]" type="text" id="extOp" size="6" /><a href=\'#\' onclick=\'removeElement('+divIdName+')\'>Remove this number</a>'; ni.appendChild(newdiv); document.getElementByID('howMany').value = num; } function removeElement(divNum) { var d = document.getElementById('myDiv'); var olddiv = document.getElementById(divNum); d.removeChild(olddiv); } </script> </head> <body> <form id="form1" name="form1" method="post" action="process.php"> Company Name<br /> <label> <input name="company" type="text" id="company" /> </label><br /> Contact Numbers <br /> <div id="myDiv"></div> <label> <input type="submit" name="Submit" value="Submit"/> </label> </form> <input name="hidden" type="hidden" id="theValue" value="0" /> <p><a href="javascript:;" onclick="addElement();">Add contact number</a></p> <p> </p> <p> </p> </body> </html> If there is more than one contact number the user can click "ADD CONTACT NUMBER" and another dynamic field is added. There is an input for: Phone Number, Option for Extension/Option, and the Extension/Option Number. I added a drop down menu for the user to select weather they need an extension or option number. its named select[] So there are 3 different form variables being passed here. aNumber[], select[], and extOp[] So what I need the php script to do is create a string for each dynamic field that looks something like this $contact = aNumber[] . select[] . extOp[]; if there are more than one contact number then i'd like them to be added to $contact but seperated by comma's because they will be inserted into a database. So I tried $i = 0; foreach ($_POST["aNumber"] as $key) $i++; echo $i; $j = 0; while ($j<=$i) { $content = $_POST["aNumber"] . "," . $_POST["select"] . "," . $_POST["extOp"]; $j++; } echo $content; That didn't work. So I am stuck... Thanks in advance for any help
  15. @mikr WOW! Thanks soo much for that! It does exactly what I need it to do! PERFECTION! and no I did not know about elements[] You've opened up a world of possibilities for me now! THANK YOU THANK YOU THANK YOU
×
×
  • 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.