[Solved] mysql_fetch_row???
Posted: Fri Mar 11, 2005 1:03 pm
I was wondering if someone could help me with a way of working around mysql_fetch_row. I wrote a program that is suppose to display data from a mysql database, the database has 3 columns, (company,testimonial, and date). I am trying to display this database in a html format. I can get the program to display 1 entry from the database, but not display the whole database. I was wondering if I should just write a function for it or try this method.
Thanks for the input in advance.
feyd | Please use
Code: Select all
/* I like to decalare my variables early */
$company = mysql_query("select company from testimonials");
$testimonial = mysql_query("select testimonial from testimonials");
$date = mysql_query("select date from testimonials");
/*
$companyrow = mysql_fetch_row($company);
$testimonialrow = mysql_fetch_row($testimonial);
$daterow = mysql_fetch_row($date);
*/
//End declares
?>
<table border="0" width=100%>
<tr>
<?
/* Just in case I need it later.
while ($field=mysql_fetch_field($company)) {
echo "<th align=left width=30%>";
echo "$field->name";
echo "</th>";
}
echo "</tr>";
*/
while ($row = mysql_fetch_row($company)) {
for ($i=0; $i<mysql_num_fields($company); $i++) {
echo "<tr>";
echo "<td width=30%>";
echo "<b>$row[$i]</b>";
/* echo "<br>";
echo "$testimonialrow[$i]";
echo "<br>";
echo "<b>$daterow[$i]</b>";
*/
echo "</td>";
}
}
echo "</tr>";
echo "</table>";
?>feyd | Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]