Connecting Tech Pros Worldwide Help | Site Map

problem with fetch rows

Newbie
 
Join Date: Aug 2006
Posts: 11
#1: Aug 30 '06
hi to all
i have some problem with fetching my form enteries. the problem is when i post some enteries through a form to a databse called 'applicant' and try to fetch and print it nothing appears.it seems that nothing has passed to the databse. but i think i`ve written the code correctly.can you please tell me what you think about my problem.there`s sth i should note:some of my text fields in the form are disabled and if the user checks sth they will be abled else no.
i`m getting these enteries in persian format(not in english)...should it be some problem with the encoding?
here`s the databse code(and thanks a lot)

<?php
if(isset($_POST['submit']))
{
$national=$_POST['Nationalnum'];
$account=$_POST['Accountnum'];
$wifename=$_POST['Wifename'];
$surname=$_POST['Surname'];
$parent=$_POST['Parentname'];

}

$db = mysql_connect("localhost","administrator", "")or die ("Could not connect to localhost");
mysql_select_db("applicant", $db)or die ("Could not find the database");
$table_name ="personalinfo";
$query="INSERT INTO personalinfo ( nationalnum , accountnum)
VALUES ('$national', '$account')";
mysql_query($query) or die (mysql_error());
$query = "select * from $table_name";
$result = mysql_query($query);
$num_rows=mysql_num_rows($result);
$num_fields = mysql_num_fields($result);
//create table header
echo "<table border = 1>";
echo "<tr>";
for ($i=0; $i<$num_fields; $i++)
{
echo "<th>";
echo mysql_field_name ($result, $i);
echo "</th>";
}
echo "</tr>";
//end table header
//create table body
echo "<tr>";
for ($i=0; $i<$num_fields; $i++)
{
echo "<td valign = top>";
echo mysql_field_type ($result, $i) . "<br> \n";
echo "(" . mysql_field_len ($result, $i) . ")<br> \n";
echo mysql_field_flags ($result, $i) . "<br> \n";
echo "</td>";
}
echo "</tr>";
//*******************enteries******************
for($j=0; $j<$num_rows; $j++)
{
echo "<tr>";
while ($row = mysql_fetch_row($result))
{
///echo "$row['$nationalnum'] $row['$accountnum']<br />";
echo "<th>$row[0]</th> <th>$row[1]</th><br/>";
}
echo "</tr>";

}
echo "</table>";
mysql_close($db);
?>
bevort's Avatar
Member
 
Join Date: Jul 2006
Posts: 53
#2: Aug 30 '06

re: problem with fetch rows


Try to use mysql_fetsh_array instead
Newbie
 
Join Date: Aug 2006
Posts: 11
#3: Sep 2 '06

re: problem with fetch rows


thanx a lot for your reply
i think i have made a mistake somewhere else
bevort's Avatar
Member
 
Join Date: Jul 2006
Posts: 53
#4: Sep 2 '06

re: problem with fetch rows


Hello glad you solved it but?

I may help one of us if you describe what the problem was

regards Vincent
Newbie
 
Join Date: Aug 2006
Posts: 11
#5: Sep 3 '06

re: problem with fetch rows


Quote:

Originally Posted by bevort

Hello glad you solved it but?

I may help one of us if you describe what the problem was

regards Vincent

hi
the problem was that i included "if(isset($_POST['submit']))" at the top of the page to get the previous entreies but when i omitted that part the code started to work correctly.i don`t know what was the problem with submit button.however its name was really 'submit' ;
thanx again
Newbie
 
Join Date: Aug 2006
Posts: 13
#6: Sep 3 '06

re: problem with fetch rows


There are often problems related to submit buttons and posting data back to site. However most of them are due to some minute mistake but there are some which arise as a result of violating a rule in PHP.

If you get stuck anywhere with PHP feel free to PM Me , Email me or just IM me and i will try to help you out the best i can.

Rahul Agrawal
Developer
Web2003 Corporation
www.web2003corp.com
Newbie
 
Join Date: Aug 2006
Posts: 11
#7: Sep 4 '06

re: problem with fetch rows


Quote:

Originally Posted by rkagrawal

There are often problems related to submit buttons and posting data back to site. However most of them are due to some minute mistake but there are some which arise as a result of violating a rule in PHP.

If you get stuck anywhere with PHP feel free to PM Me , Email me or just IM me and i will try to help you out the best i can.

Rahul Agrawal
Developer
Web2003 Corporation
www.web2003corp.com


THANX A LOT i`ll gratefully do that
Reply