Register | Login | |||||
Main
| Memberlist
| Active users
| ACS
| Commons
| Calendar
| Online users Ranks | FAQ | Color Chart | Photo album | IRC Chat |
| |
0 user currently in Programming. | 3 guests |
Acmlm's Board - I2 Archive - Programming - MySQL. . . | | | |
Pages: 1 2 | Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
User | Post | ||
windwaker Ball and Chain Trooper WHY ALL THE MAYONNAISE HATE Level: 61 Posts: 447/1797 EXP: 1860597 For next: 15999 Since: 03-15-04 Since last post: 4 days Last activity: 6 days |
| ||
Eck, I've been having a lot of problems displaying more than just the bottom row. < mysql_connect("localhost", "root", "" mysql_select_db("news_posts" $recnews = mysql_query("SELECT * FROM `recnews` ORDER BY `id` DESC LIMIT 5"); $ono = mysql_fetch_array($recnews, MYSQL_ASSOC); echo "$ono[recent]"; ?> This *should* echo the last 5 rows, right? (I have id set as Primary and AUTO_INCREMENT). It sure isn't doing what it's supposed to, I suppose . |
|||
neotransotaku Baby Mario 戻れたら、 誰も気が付く Level: 87 Posts: 1713/4016 EXP: 6220548 For next: 172226 Since: 03-15-04 From: Outside of Time/Space Since last post: 11 hours Last activity: 1 hour |
| ||
why don't you try a print_r($ono) to see what is in the array? | |||
DarkSlaya POOOOOOOOOOOORN! Level: 88 Posts: 2530/4249 EXP: 6409254 For next: 241410 Since: 05-16-04 From: Montreal, Quebec, Canada Since last post: 8 hours Last activity: 5 hours |
| ||
Originally posted by windwaker What I added is in bold. By using the while() function, you will get data as long as there is something to extract. |
|||
windwaker Ball and Chain Trooper WHY ALL THE MAYONNAISE HATE Level: 61 Posts: 448/1797 EXP: 1860597 For next: 15999 Since: 03-15-04 Since last post: 4 days Last activity: 6 days |
| ||
The while function didn't seem to work . When I tried to display the raw data in the table with print_r(), it only displayed the last row of the table. |
|||
Black Lord Level: 34 Posts: 90/453 EXP: 235639 For next: 18012 Since: 03-15-04 From: Nebraska, what's a Nebraska Since last post: 8 days Last activity: 1 day |
| ||
< mysql_connect("localhost", "root", ""); mysql_select_db("news_posts"); $recnews = mysql_query("SELECT * FROM `recnews` ORDER BY `id` DESC LIMIT 5"); while($ono = mysql_fetch_array($recnews, MYSQL_ASSOC)){ echo "$ono[recent]; } ?> Try that... it should work... (edited by Black Lord on 11-19-04 11:53 AM) |
|||
neotransotaku Baby Mario 戻れたら、 誰も気が付く Level: 87 Posts: 1716/4016 EXP: 6220548 For next: 172226 Since: 03-15-04 From: Outside of Time/Space Since last post: 11 hours Last activity: 1 hour |
| ||
have you tried the same command in MySQL? if the MySQL client returns the same thing, then you need to redo your query... | |||
DarkSlaya POOOOOOOOOOOORN! Level: 88 Posts: 2533/4249 EXP: 6409254 For next: 241410 Since: 05-16-04 From: Montreal, Quebec, Canada Since last post: 8 hours Last activity: 5 hours |
| ||
Originally posted by Black Lord Looks like I forgot my braces. Anyway, this seems like the good answer to me but only windwaker can tell. |
|||
windwaker Ball and Chain Trooper WHY ALL THE MAYONNAISE HATE Level: 61 Posts: 449/1797 EXP: 1860597 For next: 15999 Since: 03-15-04 Since last post: 4 days Last activity: 6 days |
| ||
OMG guess what. It worked! I have another question... How do I delete certain rows in a table? And how do I display certain rows, like say, rows with id 50-100? |
|||
neotransotaku Baby Mario 戻れたら、 誰も気が付く Level: 87 Posts: 1720/4016 EXP: 6220548 For next: 172226 Since: 03-15-04 From: Outside of Time/Space Since last post: 11 hours Last activity: 1 hour |
| ||
delete from [table] where [qualifying statement] select * from [table] where id>=50 and id <=100 |
|||
windwaker Ball and Chain Trooper WHY ALL THE MAYONNAISE HATE Level: 61 Posts: 450/1797 EXP: 1860597 For next: 15999 Since: 03-15-04 Since last post: 4 days Last activity: 6 days |
| ||
This Rocks Thanks so much, neotransotaku! This is awesome! One more question... I'm adding something in a file that adds to the PMA DB... What I'm adding looks like this: $date = date("m / d / y"); mysql_query("INSERT INTO `recnews` (`recent`, `date`) values ('< Although I want the contents of $summary to be stripslashed. How would I do this? o.o Edit: that was a horrible question that didn't need to be answered XD. (edited by windwaker on 11-19-04 11:23 PM) |
|||
SyntaxLegend Double metal axe Level: 25 Posts: 103/222 EXP: 78264 For next: 11356 Since: 04-21-04 From: Australia Since last post: 20 days Last activity: 10 hours |
| ||
$summary=stripslashes($summary); $date = date("m / d / y"); mysql_query("INSERT INTO `recnews` (`recent`, `date`) values ('< div class=newhead>< a href=$link>$head< /a>< /div> $summary < a href=$link>Read more< /a> -- ', '$date')"); that may work, not sure, else try: $summarya=stripslashes($summary); $date = date("m / d / y"); mysql_query("INSERT INTO `recnews` (`recent`, `date`) values ('< div class=newhead>< a href=$link>$head< /a>< /div>$summarya < a href=$link>Read more< /a> -- ', '$date')"); And If that doesnt work: $date = date("m / d / y"); mysql_query("INSERT INTO `recnews` (`recent`, `date`) values ('".stripslashes(< div class=newhead>< a href=$link>$head< /a>< /div>$summarya < a href=$link>Read more< /a> -- )."', '$date')"); (edited by SyntaxLegend on 11-20-04 01:34 AM) (edited by SyntaxLegend on 11-20-04 01:40 AM) |
|||
Xkeeper The required libraries have not been defined. Level: NAN Posts: -3066/-863 EXP: NAN For next: 0 Since: 03-15-04 Since last post: 2 hours Last activity: -753366 sec. |
| ||
Originally posted by windwaker... Yeah, I think he figured it out; all you'd have to do is stick it into a var, stripslash the var, then put the var in. |
|||
Rydain Ropa Blaze Phoenix Runs With the Dragon Within Level: 42 Posts: 311/738 EXP: 490056 For next: 31306 Since: 03-15-04 From: State College, PA Since last post: 6 days Last activity: 8 hours |
| ||
select * from [table] where id>=50 and id <=100 Or you could select * from [table] where id between 50 and 100; SQL has a bunch of other similarly nifty conditionals that are very good to know. in is another good one because it lets you specify a list of values to look for instead of making a ginormous pile of or's. For instance: select * from [table] where id in (1, 6, 21, 40); (Conversely, use "not in" to exclude the listed ID's.) |
|||
SyntaxLegend Double metal axe Level: 25 Posts: 104/222 EXP: 78264 For next: 11356 Since: 04-21-04 From: Australia Since last post: 20 days Last activity: 10 hours |
| ||
Originally posted by RydainJust clarifying. Would the correct code be set out as: SELECT * FROM [table] WHERE id BETWEEN 50 AND 100; and SELECT * FROM [table] WHERE id NOT IT (1, 6, 21, 40); |
|||
neotransotaku Baby Mario 戻れたら、 誰も気が付く Level: 87 Posts: 1723/4016 EXP: 6220548 For next: 172226 Since: 03-15-04 From: Outside of Time/Space Since last post: 11 hours Last activity: 1 hour |
| ||
actually, case doesn't matter when it comes to MySQL keywords... case only matters when it comes to your column names and data. | |||
windwaker Ball and Chain Trooper WHY ALL THE MAYONNAISE HATE Level: 61 Posts: 452/1797 EXP: 1860597 For next: 15999 Since: 03-15-04 Since last post: 4 days Last activity: 6 days |
| ||
Whoa, I tested those, they all worked. Thanks guys . Another question... how do I add to just specific rows? Like if I wanted to add "zomglol" to row 45, how would I do that? (edited by windwaker on 11-20-04 08:01 PM) |
|||
neotransotaku Baby Mario 戻れたら、 誰も気が付く Level: 87 Posts: 1727/4016 EXP: 6220548 For next: 172226 Since: 03-15-04 From: Outside of Time/Space Since last post: 11 hours Last activity: 1 hour |
| ||
manually write in the id value. insert into [table] (id, col1, col2) values (45, "zomglol", "boo"); |
|||
windwaker Ball and Chain Trooper WHY ALL THE MAYONNAISE HATE Level: 61 Posts: 453/1797 EXP: 1860597 For next: 15999 Since: 03-15-04 Since last post: 4 days Last activity: 6 days |
| ||
ooo, really sweet. now; how would I add to the beginning of a certain row? (edited by windwaker on 11-21-04 01:10 AM) (edited by windwaker on 11-21-04 01:14 AM) |
|||
SyntaxLegend Double metal axe Level: 25 Posts: 105/222 EXP: 78264 For next: 11356 Since: 04-21-04 From: Australia Since last post: 20 days Last activity: 10 hours |
| ||
what do you mean, write to the bigening of a row. you could update the row UPDATE table SET id=1, col1='Hi', col2='there!' WHERE id=1; or somethig else? |
|||
neotransotaku Baby Mario 戻れたら、 誰も気が付く Level: 87 Posts: 1737/4016 EXP: 6220548 For next: 172226 Since: 03-15-04 From: Outside of Time/Space Since last post: 11 hours Last activity: 1 hour |
| ||
I've also noticed that a lot of your question could be answered if you also tried looking a little bit at the reference manual: http://dev.mysql.com/doc/ |
Pages: 1 2 | Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
Acmlm's Board - I2 Archive - Programming - MySQL. . . | | | |