![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
how do i echo all rows in php?
Is there a way to show all rows in a database table without having to echo row[0] echo row [1] for each field?
did select * from blah where id=1 but theres about 50 fields (keyword tags) so can i just echo them all? |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Industry Role:
Join Date: Aug 2009
Location: me at smellynose.com
Posts: 206
|
It depends what you're using to get your data.
You could do Code:
foreach($data as $v) { echo $v; } Code:
$r = mysql_fetch_assoc($mysql_resource_link_doo_dar_thing); while($r) { echo $r['tag']; // Use $r[index_of_Tag] if you are using _array $r = mysql_fetch_array($mysql_resource_link_doo_dar_thing); } |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
thx dude, ill give it a try
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
hmm cant figure it out, heres my code:
Code:
$alltags = mysql_query("SELECT * FROM tags WHERE user_id=$id"); while($row1 = mysql_fetch_array($alltags)) { echo $row1['tag_cen']; //i want to echo fields here instead of just tag_cen } |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Beer Money Baron
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
|
Code:
while($row = mysql_fetch_array($alltags)) { echo implode(', ',$row); }
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 | |
Confirmed User
Industry Role:
Join Date: Aug 2009
Location: me at smellynose.com
Posts: 206
|
Quote:
And add: Code:
if($alltags === false) { die("Query failed"); } And $id is definitely numeric isn't it? Code:
$id = preg_replace('/[^0-9]/', '', $id); |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
that works good, thanks very much guys,
btw, is there anyway to skip the first field from echoing? since the first field is the id and i dont want to echo it. the 30 fields that follow are tags |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Confirmed User
Industry Role:
Join Date: Aug 2009
Location: me at smellynose.com
Posts: 206
|
You could do it in MySQL, but I'd probably do it in the PHP as MySQL limits are usually what break things.
You could use an int to see where you are, like this: Code:
$c=0; while($row) { if($c==0) { break;} echo $row['tag']; $c++; } |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
thanks again
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 |
Confirmed User
Industry Role:
Join Date: Aug 2009
Location: me at smellynose.com
Posts: 206
|
No problem. Anybody looking for a web developer, ICQ Me: 594086663
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 | |
Confirmed User
Join Date: Aug 2003
Posts: 915
|
Quote:
Thanks. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |