Jump to content

wildkatana

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

wildkatana's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. For some reason, this code is running the foreach loop twice for each cell. It is driving me crazy! You can see an example here: http://lwhitin.is2.byuh.edu/test/tv.php It is supposed to take the q argument which is the table name and then return the contents of that table. But somethings going wrong.... Please help if you can. Thanks! <?php $q=$_GET["q"]; $con = mysql_connect('localhost', 'username', 'password'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database", $con); $sql="SELECT * FROM $q"; $result = mysql_query($sql); echo "<table border='1'>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; foreach ($row as $cell) {echo "<td>$cell</td>";} echo "</tr>\n"; } echo "</table>"; mysql_close($con); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.