473,320 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

MySQL display multiple rows in a table using PHP

I was working on project page where I required to get the row data from mySql db in side the table cells. I knew how to use the php script to get the row data into the table cells like.

Id | Name | Exame | Nos
1 | Nasir | Maths | 25
2 | Abdulla | Maths | 50
3 | Fazalull | Maths | 41
4 | Jaraba | Maths | 05

But what If I want list of students in this order

List of Students4

Nasir | Abdulla
Fazalull | Jaraba


I couldn't do the multi rows even I search alot but couln't find a solution.
But then I found a solution by my self. So here how to do it may be it can help some buddy.

Lets create a table

[PHP]
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td></td>
<td></td>
</tr>

<?php
$query=" SELECT * FROM table order by id ASC";
$result=mysql_query($query);
echo mysql_error();
?>

<tr>

<?php while($ezkez = mysql_fetch_array($result)) { ?>

<td width="41%" ><a href="student.php?Name=<?php echo "$ezkez[Name]" ?>" class="sublink"><?php echo "$ezkez[Name]" ?></a></td>

<?php next($ezkez = mysql_fetch_array($result)); ?>

<td width="41%" ><a href="student.php?Name=<?php echo "$ezkez[Name]" ?>" class="sublink"><?php echo "$ezkez[Name]" ?></a></td>

</tr>
<?php
}

$anymatches=mysql_num_rows($result);
if ($anymatches == 0)
{
?>
<tr >
<td class="sublink" colspan="2" align=left><div align='center'><b>Sorry, no record found</b></div></td>
</tr>

<?php
}
?>
<tr>
<td></td>
<td></td>
</tr>
</table>[/PHP]
Jan 24 '08 #1
1 13579
Markus
6,050 Expert 4TB
You would post this in the 'howtos' section, as this is for questions ;)

Also, that code is ok but not great as you are constantly opening and closing the php parser.

take a look here.

I had the same problem once and pbmods helped me out greatly.
Jan 24 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Lenz Grimmer | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, MySQL 4.0.14, a new version of the popular Open Source/Free Software Database, has been released. It is now available in source and binary...
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
9
by: elyob | last post by:
Hi, I'm looking at storing snippets of details in MySQL about what credit cards a business excepts. Rather than have a whole column for Visa, another for Amex etc ... I am looking at having a...
18
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3 columns. I would like to display 2 of those...
2
by: ameshkin | last post by:
I know this is probably not too hard to do, but how do I display multiple rows of a mysql query/recordset. Im having trouble doing this. I don't just want to display them, but I want to make sure...
9
by: Dejan | last post by:
Hy, Sorry for my terreble english I have this simple code for deleting rows in mysql table... Everything works fine with it. So, what do i wanna do...: my sql table looks something like...
0
by: taras.di | last post by:
I'm trying to understand why MySQL isn't using all parts of the primary key when I add in an OR statement in the query. I have a people database, and a distances database. The people database...
1
by: mpar612 | last post by:
Hi everyone, I'm not sure if this is asking too much or not. I am trying to get the following PHP code to work on my website. It utilizes PHP 5, MySQL 4.1 and the PEAR DB module. I am...
6
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get...
1
ssnaik84
by: ssnaik84 | last post by:
Hi Guys, Last year I got a chance to work with R&D team, which was working on DB scripts conversion.. Though there is migration tool available, it converts only tables and constraints.. Rest of...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.