登录 | 注册 | FAQ
Anonymous

How to retrieve data from a database using a web form

+ 发表回复

18 篇帖子 1, 2


Re: How to retrieve data from a database using a web form

smutolo » 周二 4月 22, 2014 5:05 pm

XainPro 写道:Use loop statement to show your record in table

<table border="1">
<tr>
<th>Sr.</th>
<th>Name</th>
<th>Field 1</th>
<th>Field 2</th>
<th>Field 3</th>
<th>Field 4</th>
<th>Field 5</th>
<th>Field 6</th>
</tr>

<tr>
<?php
while($row = mysql_fetch_array($result)):
?>
<td><?=$row['fieldname'];?></td>
<?php
endwhile;
?>
</tr>

</table>

Replace fieldname with your field names is database this is just an idea there are lots of way for doing this simple task.


Thanks alot XainPro. Sure, it looks easy for a pro, but for me who is just beginning to learn these things, it is a bit confusing. However, it's always impossible till its done!

Now, I used the code here:

代码: 全选
Generate Class List For  <?=$search->fieldSelect()?> Of Admission That Is

<?=$search->whereSelect()?> To
<?=$search->fieldText(10,20)?>
<input type="submit" name="submit" value="submit" />
</form>   
<br><br><br>
<strong>
<?=$search->result($result)?>
<table border="1">
<tr>
<th>Admission No.</th>
<th>Last Name</th>
<th>First Name</th>
<th>Gender</th>
<th>County</th>
<th>District</th>
<th>Orphan Status</th>
</tr>
<tr>
<?php
while($row = mysql_fetch_array($result)):
?>
<?=$search->result($result)?>
<td><?=$row['Admission'];?></td>
<td><?=$row['last_name'];?></td>
<td><?=$row['first_name'];?></td>
<td><?=$row['Gender'];?></td>
<td><?=$row['County'];?></td>
<td><?=$row['District'];?></td>
<td><?=$row['Orphan'];?></td>
<?php
endwhile;
?>
</tr>

</table>


and what I get is http://www.onlinestudentsadmission.com/schooldemo/dataform.php

I have seen different ways of displaying the results in a table but I think it depends on how the querrying is done!

Where should I place the code? In the search.class.php?

Thanks once more. Am sure with your help, I will learn faster.
头像

smutolo

  • 帖子: 14
  • 注册: 周六 4月 19, 2014 7:49 pm

Re: How to retrieve data from a database using a web form

smutolo » 周三 4月 23, 2014 7:22 pm

smutolo 写道:
XainPro 写道:i am afraid you can not do this with just changing a line of code in this class.
you need to develop a custom function and or class for this or extend your query in single search form.



Thanks XainPro. For now, I will be content with searching only one column ( year) then displaying the associated data as I look for a better way of accomplishing this task.

One thing though, I want to display the data output in a clean table. How do I achieve this?

The output data contains the fields: Admission No., First Name, Last Name, Gender, County, District and Orphan Status. ( i.e. 7 columns) The rows will be dynamically determined after the querry. What code can I use and where could I place it in the php class?

Thanks once more for your advice.


It seems to me that displaying data in a table using PDO is different from doing the same using mysql commands.

If you get a way of doing that before I do, I will forever be grateful!
头像

smutolo

  • 帖子: 14
  • 注册: 周六 4月 19, 2014 7:49 pm

Re: How to retrieve data from a database using a web form

XainPro » 周四 4月 24, 2014 2:58 pm

so what's the issue you have the code to display the data in table
is it not working or what ?
头像

XainPro

  • 帖子: 3933
  • 注册: 周五 2月 17, 2012 8:10 pm

Re: How to retrieve data from a database using a web form

smutolo » 周四 4月 24, 2014 3:26 pm

XainPro 写道:so what's the issue you have the code to display the data in table
is it not working or what ?


Yeah, it ain't working!
头像

smutolo

  • 帖子: 14
  • 注册: 周六 4月 19, 2014 7:49 pm

Re: How to retrieve data from a database using a web form

XainPro » 周五 4月 25, 2014 10:42 am

paste the code of dataform.php file let me see
what error is it producing ?
头像

XainPro

  • 帖子: 3933
  • 注册: 周五 2月 17, 2012 8:10 pm

Re: How to retrieve data from a database using a web form

smutolo » 周二 4月 29, 2014 9:52 am

XainPro 写道:paste the code of dataform.php file let me see
what error is it producing ?


XainPro, can I set up a FTP account for you to see the code output and see how you could make it work?

Am willing to trust you.
头像

smutolo

  • 帖子: 14
  • 注册: 周六 4月 19, 2014 7:49 pm

Re: How to retrieve data from a database using a web form

XainPro » 周三 4月 30, 2014 6:32 am

I am a professional developer i charge for this kind of service :)
头像

XainPro

  • 帖子: 3933
  • 注册: 周五 2月 17, 2012 8:10 pm

Re: How to retrieve data from a database using a web form

smutolo » 周三 4月 30, 2014 6:56 am

XainPro 写道:I am a professional developer i charge for this kind of service :)


Ok. I understand. I will continue searching for a solution. If I get stuck completely, I could hire you! Thanks XainPro.
头像

smutolo

  • 帖子: 14
  • 注册: 周六 4月 19, 2014 7:49 pm


+ 发表回复

1, 2