• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

php and phpmyadmin

unlisted80

New Member
$sqlTotal = "SELECT * FROM `user_info` ORDER BY `total` ASC LIMIT 0 , 10";
$result = @mysql_query($query);
if ($result) {
while ($row = @mysql_fetch_array($result, MYSQL_NUM)) {

the quote above is pull up from my database (hopefully it work :) ) my question is how do i display this in my page.
 
PHP:
<?
$sqlTotal = "SELECT * FROM `user_info` ORDER BY `total` ASC LIMIT 0 , 10";
$result = @mysql_query($query);
if ($result) {

echo "<table>\n";
echo "<tr>\n";
// You need to set these
echo "<th>First field heading</th>\n";
echo "<th>Second field heading</th>\n";
echo "<th>Third field heading</th>\n";
echo "<th>Fourth field heading</th>\n";
echo "</tr>\n";
$data = @mysql_fetch_assoc($result);
$i = 0;

while ($i <= mysql_num_rows($result)) {
// You need to set these
echo "<tr>\n";
echo "<td>\n";
echo "<td>{$result['firstfield']}</td>\n";
echo "<td>{$result['secondfield']}</td>\n";
echo "<td>{$result['firstfield']}</td>\n";
echo "<td>{$result['thirdfield']}</td>\n";
echo "<td>{$result['fourthfield']}</td>\n";
echo "</tr>\n";
$i++;
}
echo "</table>\n";
} else {
   echo "Some sort of error has occured..."; 
 }
?>

a lot like that
 
Replace that else statement with this:

PHP:
else {
   die("The query could not execute because ".strtolower(mysql_error())); 
 }
 
yep do that paste result, I wrote the above code on the forum itself, it's margainly possible it has a syntax error....
 
Thanks all :)

Somehow i got this to work :) but look very messy now i try to display in col instead row. i try to display 6 in col and there are 24 in once page if more than that go to next page. so i am thinking i have to write a if statement right? i really hope someone could help me in this

many thanks adavance :)
<?php
#############################
include("inc/config/connect.inc");
#############################
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
echo "<html><head><title>Users Rating</title>";
if(is_readable("MostViewed.css")){echo "<LINK REL=StyleSheet HREF=\"MostViewed.css\" TITLE=\"Contemporary\">\n";}
echo "</head><body>";

echo "<table id=\"Container\" width=80% cellspacing=2><tr><td width=50% class=\"Container\">";

//Most viewed user
$query = "SELECT `user`, `total` FROM `user_info` ORDER BY `total` DESC LIMIT 0 , 50";
$result = @mysql_query($query);

if ($result) {
while ($row = @mysql_fetch_array($result, MYSQL_NUM)) {

print '<tr><td style="width:75%;font-size:8pt;text-align:left;">';
print "<a href=/user/?P=$row[0]>$row[0]</a>";
print '</td><td style="width:25%;font-size:8pt text-align:left;">';
print "$row[1]";
print '</td></tr>';
}
}

?>
 
Your code is inconsistent. You should really just use 'print' as a function, or 'echo' as a language construct. It works best to be consistent.
 
Back
Top