Jump to content

xkklxl

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Everything posted by xkklxl

  1. It's because I'm getting the file from a Google Docs spread sheet. The spreadsheet has a lot more values. I'm just using this tiny file as an example.
  2. Basically what I'm trying to do is list the top voted item for each letter. Here's what I have so far. <?php $filename = 'db.txt'; $handle = fopen($filename, 'r'); $data = fread($handle, filesize($filename)); $rows = explode("\n", $data); $top = array(); $top2 = array(); for($x = 0; $x < count($rows); $x++) { $line = explode("\t", $rows[$x]); for($y = 0; $y < count($line); $y++) $top[$x][$y] = $line[$y]; } for($i = 0; $i < count($top[0]); $i++) { for($j = 0; $j < count($top); $j++) { $top2[$i][] = $top[$j][$i]; } } ?> db.txt: voter a b c d person 1 apple banana cantaloupe date person 2 asparagus broccoli carrot dandelion person 3 apple brownie chocolate danish person 4 apple broccoli carrot date What I want the output to be is for each letter in html or w/e: <?php echo '<table> <tr><td><u>a</u></td></tr> <tr><td>apple - 3 votes</td></tr> <tr><td>asparagus - 1 votes</td></tr> </table>'; ?> I cannot think of a way to do this at all. I tried fooling around with array_count_values but it loses the key, and I can't think of a way to call it without knowing what people voted for. Thank you.
  3. Yeah, I'm not that good with SQL either, but I test my queries on phpMyAdmin to see if it works before I use them in my code with the SQL tab. Probably not the best way, but hell, I'm learning from it.
  4. Nailed it. Thank you so much.
  5. If I understand your question correctly, you'd simply use WHERE. Something like: SELECT * from table WHERE username='person'
  6. Say, I have a multidimensional array named Array. Array[0] = "apple", "banana", "cantaloupe", "date" Array[1] = "asparagus", "broccoli", "carrot", "dandelion" How would I make a new multidimensional array from this multidimensional array with all the 0's from say "apple" and "asparagus?" Like I'd like my new array to look like this: Array[0] = "apple", "asparagus" Array[1] = "banana", "broccoli" Array[2] = "cantaloupe", "carrot" Array[3] = "date", "dandelion" My brain seems dead right now. I can't think of a way to do it. 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.