Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

database array

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
asd_pl
Smarty n00b


Joined: 09 Nov 2003
Posts: 2

PostPosted: Sun Nov 09, 2003 3:47 pm    Post subject: database array Reply with quote

How to display results of this code using smarty?



[php:1:6aa225f577]<?php
$query = "SELECT * FROM ug_users";
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
while($row = mysql_fetch_array($result)){
echo "<hr>";
echo "<span class=\"style1\"><b>ID</b>: $row[ug_id]<BR>";
echo "<b>Login</b>: $row[ug_login]<BR>";
echo "<b>Nick</b>: $row[ug_nick] <BR>";
echo "<b>Level</b>: $row[ug_level] <BR>";
echo "<b>Pass</b>: $row[ug_pass] <BR><BR>";
echo "<b>Data Rejestracji:</b> $row[ug_reg_date]<br><BR>";
echo "<b>Opis</b>:<BR><BR> $row[ug_about]<br><BR>";
echo "<b>Administracja:</b><BR>";
echo "<a href=\"asd?action=user_edit&id=$row[ug_id]\">Edit</a> <a href=\"asd?action=user_delete&id=$row[ug_id]\">Delete</a> <a href=\"asd?action=user_ban&id=$row[ug_id]\">Ban</a><BR>";






}

?>[/php:1:6aa225f577]

Thanks for help
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sun Nov 09, 2003 4:35 pm    Post subject: Reply with quote

Hi asd_pl!

Please, read the docs before asking and try a few tutorials. You should find that there is a very short learning curve to getting started. If you look at Smarty's home page you will see a few handy links in the left-hand navigation bar including: documentation and even a crash course.

There are many tutorials already available on the web. Virtually all of the popular PHP/coding sites (and many less pouplar sites) have at least one Smarty sample. For example, try this tutorial at CodeForSoup -- it seems to be fairly much in the same range as what you are looking for.

This is what google says about smarty mysql tutorial.

There are also several examples right here at the forum if you do a search on mysql such as this one: foreach of section, that is the question.

HTH
Back to top
View user's profile Send private message
corre
Smarty n00b


Joined: 09 Nov 2003
Posts: 1

PostPosted: Sun Nov 09, 2003 11:28 pm    Post subject: Please... Reply with quote

To use echo like this is hard work, especially as you wont see a thing in a editor

Code:

<?php
$query = "SELECT * FROM ug_users"; 
$result = mysql_query($query); 
$numrows = mysql_num_rows($result); 
while($row = mysql_fetch_array($result)){ 
    echo "<hr>";
   echo "<span class=\"style1\"><b>ID</b>: $row[ug_id]<BR>"; 
    echo "<b>Login</b>: $row[ug_login]<BR>"; 
   echo "<b>Nick</b>: $row[ug_nick] <BR>";
   echo "<b>Level</b>: $row[ug_level] <BR>";
    echo "<b>Pass</b>: $row[ug_pass] <BR><BR>";
   echo "<b>Data Rejestracji:</b> $row[ug_reg_date]<br><BR>";
   echo "<b>Opis</b>:<BR><BR> $row[ug_about]<br><BR>";
   echo "<b>Administracja:</b><BR>";
   echo "<a href=\"asd?action=user_edit&id=$row[ug_id]\">Edit</a> <a href=\"asd?action=user_delete&id=$row[ug_id]\">Delete</a> <a href=\"asd?action=user_ban&id=$row[ug_id]\">Ban</a><BR>"; 


?>


Use this method instead;
Code:

<?php
$query = "SELECT * FROM ug_users"; 
$result = mysql_query($query); 
$numrows = mysql_num_rows($result); 
while($row = mysql_fetch_array($result)){
?> 
    hr>
   <span class="style1"><b>ID</b>: <?PHP echo $row[ug_id]?><BR>
  ....
  ....
<?PHP } ?>

This way you will se all the html in any editor.
I don't know a shit about smarty (yet) but as understand it one wants to keep the dirty code out of the html. Much like the .net framework (5% knowledge of that)

Hopes this makes your files more editable
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP