Re: [PHP] Generating HTML table from MySQL table based on some criteria

2007-11-03 Thread Jim Lucas

Sudheer Satyanarayana wrote:



Wolf wrote:

Sudheer,

Post the code you are using and we'll better be able to point you in 
the right direction to get your code working.
  
Thanks Jim Lucas, Wolf and Jay Blanchard for your suggestions. Here is 
the code I am using

[code]
print '';
$result = mysql_query("SELECT * FROM users where status=1 AND picture <> 
'' ORDER BY created DESC limit 20");

 while ($user_info = mysql_fetch_object($result)) {
   $output .= '
http://example.com/'.$user_info->picture.'"  height="90" 
 >
' .''. $user_info->name 
.'';

 }
 print $output;
print  '';
[/code]

The above code prints the pictures of last twenty users who have 
uploaded their pictures.  Each picture is printed in an HTML table cell. 
The table has only one row.


I want to split the HTML table into 4 rows each containing 5 cells. Each 
table cell should contain one user picture. How can I do this?


PS: The DB column names are slightly different than I mentioned in my 
previous message.


You forgot your ...  html tags.  This will break it up into 
different rows




Wolf

 Sudheer Satyanarayana <[EMAIL PROTECTED]> wrote:  

Hello,

I have a MySQL table with four columns - userid, created_date, 
username and path_to_picture. path_to_picture column contains the 
path to the image files of those users who have uploaded pictures. An 
example path stored in path_to_picture column is 
picture/username.png.  There are  some  users that don't have their 
pictures uploaded. The column contains nothing for these usernames.


I want to generate an HTML table with 20 recent users who have 
uploaded their pictures. Each row in the HTML table should contain 5 
columns. Thus the HTML table would contain 4 rows.


How can I accomplish this?

I hope I have provided enough information to describe my problem. I 
would be glad to provide more details if required.


I tried few permutations and combinations with ORDER BY and LIMIT 
clauses to no avail. I have been scratching my head from few hours to 
get this to work. Any help would be greatly appreciated.





--
With Warm Regards,
Sudheer. S
http://www.binaryvibes.co.in

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



  




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Generating HTML table from MySQL table based on some criteria

2007-11-03 Thread Sudheer Satyanarayana



Wolf wrote:

Sudheer,

Post the code you are using and we'll better be able to point you in the right 
direction to get your code working.
  
Thanks Jim Lucas, Wolf and Jay Blanchard for your suggestions. Here is 
the code I am using

[code]
print '';
$result = mysql_query("SELECT * FROM users where status=1 AND picture <> 
'' ORDER BY created DESC limit 20");

 while ($user_info = mysql_fetch_object($result)) {
   $output .= '
http://example.com/'.$user_info->picture.'"  height="90" 
>
' .''. $user_info->name 
.'';

 }
 print $output;
print  '';
[/code]

The above code prints the pictures of last twenty users who have 
uploaded their pictures.  Each picture is printed in an HTML table cell. 
The table has only one row.


I want to split the HTML table into 4 rows each containing 5 cells. Each 
table cell should contain one user picture. How can I do this?


PS: The DB column names are slightly different than I mentioned in my 
previous message.

Wolf

 Sudheer Satyanarayana <[EMAIL PROTECTED]> wrote: 
  

Hello,

I have a MySQL table with four columns - userid, created_date, username 
and path_to_picture. path_to_picture column contains the path to the 
image files of those users who have uploaded pictures. An example path 
stored in path_to_picture column is picture/username.png.  There are  
some  users that don't have their pictures uploaded. The column contains 
nothing for these usernames.


I want to generate an HTML table with 20 recent users who have uploaded 
their pictures. Each row in the HTML table should contain 5 columns. 
Thus the HTML table would contain 4 rows.


How can I accomplish this?

I hope I have provided enough information to describe my problem. I 
would be glad to provide more details if required.


I tried few permutations and combinations with ORDER BY and LIMIT 
clauses to no avail. I have been scratching my head from few hours to 
get this to work. Any help would be greatly appreciated.





--
With Warm Regards,
Sudheer. S
http://www.binaryvibes.co.in

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



  


--
With Warm Regards,
Sudheer. S
http://www.binaryvibes.co.in

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Generating HTML table from MySQL table based on some criteria

2007-11-01 Thread Jim Lucas

Jay Blanchard wrote:

[snip]
I have a MySQL table with four columns - userid, created_date, username 
and path_to_picture. path_to_picture column contains the path to the 
image files of those users who have uploaded pictures. An example path 
stored in path_to_picture column is picture/username.png.  There are  
some  users that don't have their pictures uploaded. The column contains


nothing for these usernames.

I want to generate an HTML table with 20 recent users who have uploaded 
their pictures. Each row in the HTML table should contain 5 columns. 
Thus the HTML table would contain 4 rows.


How can I accomplish this?

I hope I have provided enough information to describe my problem. I 
would be glad to provide more details if required.


I tried few permutations and combinations with ORDER BY and LIMIT 
clauses to no avail. I have been scratching my head from few hours to 
get this to work. Any help would be greatly appreciated.

[/snip]

SELECT * FROM table WHERE path_to_picture IS NOT NULL ORDER BY
created_date LIMIT 20






Then to take this to the next step


 0 ) {
echo '';
echo ' ';
echo 'User ID';
echo 'Date Created';
echo 'Username';
echo 'Picture';

$id = 1;
while ( list($userid, $created_date, $username, $path) = 
mysql_fetch_array($results) ) {
echo '';
echo ''.($id++).'';
echo ''.$userid.'';
echo ''.$created_date.'';
echo ''.$username.'';
echo '';
echo '';
}
echo '';
} else {
echo 'No results found';
}

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Generating HTML table from MySQL table based on some criteria

2007-11-01 Thread Wolf
Sudheer,

Post the code you are using and we'll better be able to point you in the right 
direction to get your code working.

Wolf

 Sudheer Satyanarayana <[EMAIL PROTECTED]> wrote: 
> Hello,
> 
> I have a MySQL table with four columns - userid, created_date, username 
> and path_to_picture. path_to_picture column contains the path to the 
> image files of those users who have uploaded pictures. An example path 
> stored in path_to_picture column is picture/username.png.  There are  
> some  users that don't have their pictures uploaded. The column contains 
> nothing for these usernames.
> 
> I want to generate an HTML table with 20 recent users who have uploaded 
> their pictures. Each row in the HTML table should contain 5 columns. 
> Thus the HTML table would contain 4 rows.
> 
> How can I accomplish this?
> 
> I hope I have provided enough information to describe my problem. I 
> would be glad to provide more details if required.
> 
> I tried few permutations and combinations with ORDER BY and LIMIT 
> clauses to no avail. I have been scratching my head from few hours to 
> get this to work. Any help would be greatly appreciated.
> 
> 
> 
> 
> -- 
> With Warm Regards,
> Sudheer. S
> http://www.binaryvibes.co.in
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Generating HTML table from MySQL table based on some criteria

2007-11-01 Thread Jay Blanchard
[snip]
I have a MySQL table with four columns - userid, created_date, username 
and path_to_picture. path_to_picture column contains the path to the 
image files of those users who have uploaded pictures. An example path 
stored in path_to_picture column is picture/username.png.  There are  
some  users that don't have their pictures uploaded. The column contains

nothing for these usernames.

I want to generate an HTML table with 20 recent users who have uploaded 
their pictures. Each row in the HTML table should contain 5 columns. 
Thus the HTML table would contain 4 rows.

How can I accomplish this?

I hope I have provided enough information to describe my problem. I 
would be glad to provide more details if required.

I tried few permutations and combinations with ORDER BY and LIMIT 
clauses to no avail. I have been scratching my head from few hours to 
get this to work. Any help would be greatly appreciated.
[/snip]

SELECT * FROM table WHERE path_to_picture IS NOT NULL ORDER BY
created_date LIMIT 20



-- 
With Warm Regards,
Sudheer. S
http://www.binaryvibes.co.in

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Generating HTML table from MySQL table based on some criteria

2007-11-01 Thread Sudheer Satyanarayana

Hello,

I have a MySQL table with four columns - userid, created_date, username 
and path_to_picture. path_to_picture column contains the path to the 
image files of those users who have uploaded pictures. An example path 
stored in path_to_picture column is picture/username.png.  There are  
some  users that don't have their pictures uploaded. The column contains 
nothing for these usernames.


I want to generate an HTML table with 20 recent users who have uploaded 
their pictures. Each row in the HTML table should contain 5 columns. 
Thus the HTML table would contain 4 rows.


How can I accomplish this?

I hope I have provided enough information to describe my problem. I 
would be glad to provide more details if required.


I tried few permutations and combinations with ORDER BY and LIMIT 
clauses to no avail. I have been scratching my head from few hours to 
get this to work. Any help would be greatly appreciated.





--
With Warm Regards,
Sudheer. S
http://www.binaryvibes.co.in

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php