All i want to do is create something like a phpmyadmin in which the table can be edited. $q = mysql_query("SELECT * FROM `".$db_table_site."`") or mysql_error(); $n = 0; while($row = mysql_fetch_assoc($q)){ $key = $row['key']; $site = trim($row['site']); $delkey = $row['key']; echo '<tr>'; echo'<td width="10%" valign="bottom" align="center"><form name="frmdel" method="POST" action="'.$_SERVER['PHP_SELF'].'?page=site"><input name="delkey" type="hidden" value="'.$row['key'].'"><input name="delsite" type="hidden" value="'.$row['site'].'"><input type="image" src="admin/del.png" align="middle"></form></td>'; echo'<td width="90%">'.$n.'<form name="edit" method="POST" action="'.$_SERVER['PHP_SELF'].'?page=site"><input name="editkey" type="hidden" value="'.$row['key'].'"><input type="text" name="site" value="'.$row['site'].'" size="40"> <input name="edit" type="submit" value="Edit"></form></td>'; echo'</tr>'; PHP: For this simple code I am getting a weird range of problems... the while loop stops half way without any error message. The table is not properly displayed and also get strange characters such as ðXT€ðXT€����d in output ! Any solutions ?
What's the character encoding of the database table? Also what data type are the columns that are outputing like this?
aside from the DB stuffs ( after you've fixed the character encoding issues as what jestep said ), you might also want to try <?php header('Content-Type: text/html; charset=utf-8'); ?> PHP: for your page to properly display those *nasty* characters.
there are no special character only plain english.. site url. The while($row = mysql_fetch_assoc($q)) stops midway. Is there any bugs with this method ? total number of record is just 300+ the records are properly show if i don't echo forms !
All I can see from a quick glance that the loop isn't closed and maybe its exiting the script due to memory issues. Try... $q = mysql_query("SELECT * FROM `".$db_table_site."`") or mysql_error(); $n = 0; while($row = mysql_fetch_assoc($q)){ $key = $row['key']; $site = trim($row['site']); $delkey = $row['key']; echo '<tr>'; echo'<td width="10%" valign="bottom" align="center"><form name="frmdel" method="POST" action="'.$_SERVER['PHP_SELF'].'?page=site"><input name="delkey" type="hidden" value="'.$row['key'].'"><input name="delsite" type="hidden" value="'.$row['site'].'"><input type="image" src="admin/del.png" align="middle"></form></td>'; echo'<td width="90%">'.$n.'<form name="edit" method="POST" action="'.$_SERVER['PHP_SELF'].'?page=site"><input name="editkey" type="hidden" value="'.$row['key'].'"><input type="text" name="site" value="'.$row['site'].'" size="40"> <input name="edit" type="submit" value="Edit"></form></td>'; echo'</tr>'; } // This wasnt there Code (markup): Also, what's the n=0 for? I don't see it being incremented anywhere in that script so $n will always equal 0.
You do mean that you want to edit the contents of the tables? Not the tables or structure. Do you need to see all 300 records at the same time? Are you trying to run this on localhost or on a shared server? I can post a routine that will allow you to edit a single item for multiple fields. I'm not real experienced but I think you are timing out or do not have the query structured correctly.
Thanks for the kind replies ! Here is full code that iam using <?php $q = mysql_query("SELECT * FROM `".$db_table_site."`") or mysql_error(); $n = 1; while($row = mysql_fetch_assoc($q)){ $key = $row['key']; $site = trim($row['site']); $delkey = $row['key']; echo '<tr>'; echo '<td>'.$n.'</td>'; echo '<td><a href="'.$_SERVER['PHP_SELF'].'?page=site&delkey='.$key.'&delsite='.$site.'"><img border="0" src="admin/del.png"></a></td>'; echo'<td><input name="editkey" type="hidden" value="'.$key.'">'.$site.'<a href="'.$_SERVER['PHP_SELF'].'?page=editsite&key='.$key.'"><img border="0" src="admin/edit.png"></a></td>'; echo'</tr>'."\n"; $n++; } ?> PHP: There weird error still there in my localhost but is not there in a hosting server, could a memory or a timeout issue ! When I run the loop without the form or the table there error is not there !
Whats the actual error? Change "or mysql_error()" to "die(mysql_error())" or echo it so we can see if there any problems there.