Jump to content

antfuentes87

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Everything posted by antfuentes87

  1. Thank you jcbones, with the comments I was able to understand exactly what you did.
  2. I was trying to have the below function insert the data just into one row, but instead it is doing (see image below). No idea why it is doing that, if anyone knows and could tell me how to fix it. It would be much appreciated. function set($table){ $result = mysql_query("SELECT * FROM $table"); $i = 0; while ($i < mysql_num_fields($result)) { $meta = mysql_fetch_field($result, $i); $name = $meta->name; $nameB = $_POST[$name]; if($name <> 'id'){ $q = "INSERT INTO $table($name) VALUES ('".$nameB."')"; mysql_query($q); } $i++; } }
  3. So I have a simple php while loop that loops through a table and displays the data. I want to integrate it with AJAX, so every time a new entry is added to the table, it automatically displays without having to refresh the page. $q = mysql_query("SELECT * FROM table"); while($f = mysql_fetch_array($q)){ echo $f['test_col']; } To be honest, I am not even sure if this is possible with AJAX (just started getting into it), but it seems like a good place to start. Any suggestions / help is much appreciated. I did Google this for awhile, but did not find anything (found things close, but nothing exactly like this).
  4. I figured it out guys. Thanks for the help. The solution was: SELECT DISTINCT * FROM jos_kunena_messages GROUP BY thread ORDER BY thread DESC LIMIT 5
  5. I guess I explained it badly. But its for a Forum (Just like these ones). I want to show the most recent post (but I do now want to show 3 post from the same thread). If you go and look at http://www.chicago3media.com/ you will see "Why gas is so expensive" and "Re: Why gas is so expensive" when I only want to display the most recent one which would be "Re: Why gas is so expensive". Now each post, has a thread id (so that means both those post I said above would have the same thread id), so I was thinking if I can just only display the last post in that thread (using order by DESC) and DISTINCT? Did I explain it any better?
  6. How does that help? That just displays all the rows?
  7. So what is the correct way?
  8. I tired exactly what you had in the above post and I get a error. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/c3m/public_html/templates/sunsetter/pages/home.php on line 9
  9. Its from a forum table. I want to just the newest one from each different thread. http://www.chicago3media.com/ You can see it here, where it says "Why gas is so expensive" and "Re: Why gas is so expensive". I just want it to say "Re: Why gas is so expensive". It was a bad example sorry. Hope this makes more sense.
  10. I have a MySQL table like this: id thread name 1 1 bob 2 2 bob 3 3 bob 4 3 bob 5 3 bob I want to loop through the entire table, but only show the most recent thread. So there is 3 threads that all have the number 3, I want to display the latest one in the the table (not all 3). I was looking into DISTINCT but it was not working, anyone have any ideas? What I have right now (just looping through the table): <?php $f_q = mysql_query("SELECT * DISTINCT thread FROM jos_kunena_messages"); while($f_r = mysql_fetch_array($f_q)){ $id = $f_r['id']; $thread = $f_r['thread']; echo $thread; } ?>
×
×
  • 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.