GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 02-Jul-2003, 23:13
skyloon skyloon is offline
Junior Member
 
Join Date: Jun 2003
Posts: 53
skyloon is an unknown quantity at this point

Show result in table


I have tried to modify this coding, but also cannot show the result,
what is the problem? The error message is "Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:\phpweb/account.php on line 26"

Thank you for your help.
-------------------------------------




<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<? $Connect = mysql_connect("localhost","root","");
mysql_select_db("mw");
$result=mysql_query("select * from account");
$number_of_rows = mysql_num_rows($result);

print "<TABLE CELLSPACING=\"0\" CELLPADDING=\"0\" BORDER=\"1\">\n";
print " <TR><TD height=\"45\">Username</TD><TD>Password</TD><TD>Email</TD></TR>\n";


while ($number_of_rows = mysql_fetch_row($result)){

echo "<tr>\n";

echo "<TD>$number_of_rows["username"]"</TD>\n";
echo "<TD>$number_of_rows["password"]"</TD>\n";
echo "<TD>$number_of_rows["email"]"</TD>\n";
echo "<tr>\n";
}
mysql_close();
?>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>
</body>
</html>
  #2  
Old 03-Jul-2003, 19:30
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough

PHP Variable parsing


This bit here:
PHP Code:

<?php
echo "<TD>$number_of_rows["username"]</TD>\n";
echo "<TD>$number_of_rows["password"]</TD>\n";
echo "<TD>$number_of_rows["email"]</TD>\n";
?>


You could do either instead:
PHP Code:

<?php

// One way...
echo "<TD>$number_of_rows[username]</TD>\n";
echo "<TD>$number_of_rows[password]</TD>\n";
echo "<TD>$number_of_rows[email]</TD>\n";

// Another way... note the curly braces aka 'complex syntax'
echo "<TD>{$number_of_rows['username']}</TD>\n";
echo "<TD>{$number_of_rows['password']}</TD>\n";
echo "<TD>{$number_of_rows['email']}</TD>\n";

// Or what I personally prefer
echo '<TD>'.$number_of_rows['username']."</TD>\n";
echo '<TD>'.$number_of_rows['password']."</TD>\n";
echo '<TD>'.$number_of_rows['email']."</TD>\n";
?>

 
 

Recent GIDBlogOnce again, no time for hobbies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP script to show last referrer url and top referrer to your site jrobbio MySQL / PHP Forum 6 22-May-2006 02:06
Recall table row misunderstood MySQL / PHP Forum 3 23-Aug-2003 09:56
top of table Charlie Web Design Forum 7 27-Mar-2003 03:21
[Tutorial] MySQL Basics nniehoff MySQL / PHP Forum 15 23-Mar-2003 20:42
table question smoky Web Design Forum 1 05-Jan-2003 03:45

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 15:56.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.