Hi, iam trying to display student names along with their course selected and status of their selection, from mysql db, the result has to be in tabular format, with alternate row bg color, here is my code, please help me out...
Please share a complete code, i will be very thankful -
<?
-
include('config.php');
-
-
echo "<a href='Student Details Form.php'>New Record</a>";
-
-
echo "<table border=2 >";
-
echo "<tr>";
-
echo "<td><b>Sl No.</b></td>";
-
echo "<td><b>Student Name</b></td>";
-
echo "<td><b>Course Applied</b></td>";
-
echo "<td><b>Status</b></td>";
-
echo "</tr>";
-
-
$result = mysql_query("SELECT `stud_name` AS 'Student Name', `course_studying` AS 'Course Applied', `status` AS 'Status' FROM `cjet`.`student_details` WHERE `status` = 'Selected'") or trigger_error(mysql_error());
-
while($row = mysql_fetch_array($result)){
-
-
foreach($row AS $key => $value) { $row[$key] = stripslashes($value);
-
}
-
echo "<tr bgcolor= '$bgcolor'>";
-
echo "<td valign='top'>" . nl2br( $row['stud_id']) . "</td>";
-
echo "<td valign='top'>" . nl2br( $row['stud_name']) . "</td>";
-
echo "<td valign='top'>" . nl2br( $row['course_studying']) . "</td>";
-
echo "<td valign='top'>" . nl2br( $row['status']) . "</td>";
-
echo "<td valign='top'><a href=edit.php?id={$row['stud_id']}>Edit</a></td><td><a href=delete.php?id={$row['stud_id']}>Delete</a></td>";
-
echo "</tr>";
-
}
-
echo "</table>";
-
echo "<a href='Student Details Form.php'>New Record</a>";
-
?>
-
4 4041 - <?
-
include('config.php');
-
-
echo "<a href='Student Details Form.php'>New Record</a>";
-
-
echo "<table border=2 >";
-
echo "<tr>";
-
echo "<td><b>Sl No.</b></td>";
-
echo "<td><b>Student Name</b></td>";
-
echo "<td><b>Course Applied</b></td>";
-
echo "<td><b>Status</b></td>";
-
echo "</tr>";
-
-
$result = mysql_query("SELECT `stud_name` AS 'Student Name', `course_studying` AS 'Course Applied', `status` AS 'Status' FROM `cjet`.`student_details` WHERE `status` = 'Selected'") or trigger_error(mysql_error());
-
$i=0;
-
while($row = mysql_fetch_array($result)){
-
($i%2 == 0) ? $bgcolor = "#ff0000" : $bgcolor = "#0000ff";
-
foreach($row AS $key => $value) { $row[$key] = stripslashes($value);
-
}
-
echo "<tr bgcolor= '$bgcolor'>";
-
echo "<td valign='top'>" . nl2br( $row['stud_id']) . "</td>";
-
echo "<td valign='top'>" . nl2br( $row['stud_name']) . "</td>";
-
echo "<td valign='top'>" . nl2br( $row['course_studying']) . "</td>";
-
echo "<td valign='top'>" . nl2br( $row['status']) . "</td>";
-
echo "<td valign='top'><a href=edit.php?id={$row['stud_id']}>Edit</a></td><td><a href=delete.php?id={$row['stud_id']}>Delete</a></td>";
-
echo "</tr>";
-
$i++;
-
}
-
echo "</table>";
-
echo "<a href='Student Details Form.php'>New Record</a>";
-
?>
-
Change the colors as you like.
Thank you boss,
well i have one more question, how do i display Sl No., right now as you can see i am using the following code to display Serial Number - 'stud_id' -
echo "<td><b>Sl No.</b></td>";
-
corresponding to -
echo "<td valign='top'>" . nl2br( $row['stud_id']) . "</td>";
-
the stud_id value changes if i delete a student from the table, or when the list has only 'Selected' students name, how to implement a Sequential numbering.
I hope iam clear with the above question
Hi,
you can simply show the looping variable as serial number. - echo "<td><b>". $i ."</b></td>";
Hi, i tried both the above solutions - 1) to change the alternate row bg color & 2) serial number,
doesn't work,
can anybody please look into this here is my updated code -
<style type="text/css">
-
table.tbg {
-
text-align:center;
-
}
-
</style>
-
<?
-
include('config.php');
-
-
echo "<a href='Student Details Form.php'>New Record</a>";
-
-
echo "<table border=2 class='tbg'>";
-
echo "<tr>";
-
echo "<td><b>Sl No.</b></td>";
-
echo "<td><b>Student Name</b></td>";
-
echo "<td><b>Course Applied</b></td>";
-
echo "<td><b>Status</b></td>";
-
echo "</tr>";
-
-
$result = mysql_query("SELECT stud_id, stud_name, course_studying, status FROM cjet.student_details WHERE status = 'Selected' ") or trigger_error(mysql_error());
-
-
$i=0;
-
-
while($row = mysql_fetch_array($result)){
-
-
($i%2 == 0) ? $bgcolor = "#ff0000" : $bgcolor = "#0000ff";
-
-
foreach($row AS $key => $value) { $row[$key] = stripslashes($value);
-
}
-
echo "<tr bgcolor= '$bgcolor'>";
-
echo "<td valign='top'><b>". $i ."</b></td>";
-
echo "<td valign='top'>" . nl2br( $row['stud_name']) . "</td>";
-
echo "<td valign='top'>" . nl2br( $row['course_studying']) . "</td>";
-
echo "<td valign='top'>" . nl2br( $row['status']) . "</td>";
-
echo "<td valign='top'><a href=edit.php?id={$row['stud_id']}>Edit</a></td><td><a href=delete.php?id={$row['stud_id']}>Delete</a></td>";
-
echo "</tr>";
-
}
-
echo "</table>";
-
echo "<a href='Student Details Form.php'>New Record</a>";
-
?>
-
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Antoni |
last post by:
Hello,
I wondered if anyone could offer some guidance, I trying to write a
php script to connect to a database, and display the records in a
table.
I found the code here in a php4 text, and...
|
by: Anthony Williams |
last post by:
Good morning,
I'm currently designing a site, using CSS, and wish to create a variable
width two-column layout, with header and footer, and one fixed-width column
on the left.
Previously, I...
|
by: Joey Martin |
last post by:
This is urgent, so any quick help is much appreciated!!!!
I have an ASP page that pulls data from a SQL table and puts it into a
basic html table. This is basic stuff.
I moved my pages from a...
|
by: Kamal Ahmed |
last post by:
Hi All,
I am using Asp.Net 1.1 inline coding with MS SQL Server as a backend for
developing a solution. My requirement is to generate HTML Table as a cross
tab to display columns an Rows and to...
|
by: rahul agarwal |
last post by:
Hi All,
I want to get data in an HTML table on an ASP.net page using C#.
Please tell me how this can be done
Thanx
|
by: nirmalsingh |
last post by:
hi everybody,
i want to enter some data in text box and load it in html table for viewing purpose. atlast i want read all the data from html table and save in database.help me to do this?
1.how to...
|
by: sandeep123456 |
last post by:
hi,
can we send data from html to excel sheet using java script
sandeep
|
by: pavani1 |
last post by:
Hi,
I have to move my data from one table to another table in database when some condition is true.
plz tell that how to start logic.
|
by: Ashish101 |
last post by:
Hi,
I have a html table with data.
Now when I select a particular row, I need the data of all the cells of that row
how would I do
Kindly help
Thanx in advance
|
by: abhishek1234321 |
last post by:
I have a form at http://www.vtuhub.com/w.html which shows results if a proper roll number is entered... the results are fetched from http://results.vtu.ac.in site and only the table is shown... now i...
|
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...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| | |