Jump to content

Zharvek

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Zharvek's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Well, I know how to count the number of rows a query returns, but Im looking for something a little more in depth and I can't figure it out, nor do I know exactly what to serach for. Here is what I'm trying to do, I hope somebody has done this before, or can help. Say I have a bunch of rows in a table, these are news posts by many users. I want to do a query that says how many posts each user has. My table looks like, ID | Username | Date | Data 1 | Bob | Today | Testing 2 | Bob | Today | Testing 3 | Bob | Today | Testing 4 | Bob | Today | Testing 5 | Bob | Today | Testing 6 | Tom | Today | Testing 7 | Tom | Today | Testing 8 | Tom | Today | Testing Thats fake of course, but that is a good example. I want to say: Bob has 5 posts and Tom has 3. I can use a count of rows but that will return 8, and there are more users then those 2 and names cannot be hardcoded in, so a WHERE username= wont work. I hope somebody can help, thanks for looking! :-)
  2. Hello all, I have (think it is) an array problem. I am trying to create an component for a CMS system, but thats not what matters... I have collected some information, and code examples, and found some scripts to read an bookmark XBEL xml file, and output it nicely, using no XSL stylesheet, just PHP. My problem is that I cannot find out how to modify this script to pull more data available from the file. Currently it will pull, the title, url, and folder the link resides in, and prints it to the browser nicely. I need it to also grab and print the description. Here is what I have now: [code] <?php global $database; $query = "SELECT * FROM jos_ablinks"; $database->setQuery( $query ); $rows = $database->loadObjectList(); $row = $rows[0]; $simple=@join('',@file($row->filepath)); $p = xml_parser_create(); xml_parse_into_struct($p, $simple, $vals, $index); xml_parser_free($p); $bm=array(); foreach ($index['FOLDER'] as $k=>$v) { $bm[$v]='DDDODDD'; } foreach ($index['TITLE'] as $k=>$v) { $bm[$v]=$vals[$v]['value']; } foreach ($index['BOOKMARK'] as $k=>$v) { if (is_array($vals[$v]['attributes'])) { $bm[$v]=$vals[$v]['attributes']['HREF']; } } ksort($bm); $l=true; foreach ($bm as $k=>$v) {     if ($v=='DDDODDD') { if (!$l) { $l=true; } } else { if (substr($v,0,4)=='http') { $lastlink=$v; } else { if (strlen(trim($v))>0) { if ($l) { $l=false; if ($v==$row->ignored){}else{ echo '<tr><td><h4>'.htmlspecialchars($v).'</h4></td><tr>'; } } else { echo '<tr><td><a href="'.$lastlink.'">'.htmlspecialchars($v).'</a></td></tr>'; } } } } } $vals=array(); $index=array(); ?>[/code] Sorry if that was long, I have tried adding an [code]foreach ($index['DESC'] as $k=>$v) { $bm[$v]=$vals[$v]['value']; }[/code] Under the one with $index['TITLE'] and after playing around with some code, I got it to print the very last DESC in the XML file, but not a DESC for each item in the xml file. I hope I am being clear with it, I just want to be able to put the DESC in here [code]<tr><td><a href="'.$lastlink.'">'.htmlspecialchars($v).'</a></td></tr>[/code] to look something like [code]<tr><td><a href="'.$lastlink.'">'.htmlspecialchars($v).'</a><br />'.$desc.'</td></tr>[/code] Thanks in advance if anyone can help. :-)
  3. Thank you very much, that solves a big part of the problem. Now that the time is removed, I can work on getting the parts into their variables correctly.
  4. Hello, I have a odd situation in PHP where I need to convert an date to a different format... I have a date like, 2006-03-19 16:42:01 and I would like to "convert" it into something like... $year = "2006"; $month = "03"; $day = "19"; I don't need the time at all. I just need the year, month, and day from that long string into some variables so I can pull data from the MySQL server correctly. I was guessing that I could use a trim of some sort, but is this the best way? I cannot change the long date format above because it is already in wide spread use on the site. Thank you in advance to anyone who can help.
×
×
  • 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.