Jump to content

patsypoopa

New Members
  • Posts

    5
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

patsypoopa's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks Barand that worked perfect!
  2. I've just posted a problem and it was solved however now i've got another problem with displaying the solution Oh and i'm still a newbie! Right, i've got a loop which SHOULD display columns and records from a table. In a format like this for each record: Name: Blah Age: Bleh It does this fine for the first record but for the 2nd record it only has the cell so its showing like this: : Blah : Bleh Hope someone has the solution thanks either way $sql = "SELECT * FROM $chosencollection"; $result = mysql_query($sql); $result2 = mysql_query($sql); $cols_num = mysql_num_fields($result2); ?> <h1>View Collection</h1> <? echo "<p><h2>" . $collectionnametitle ."</h2></p>"; while($row = mysql_fetch_row($result)) { foreach($row as $cell) { $col = mysql_fetch_field($result2); $col->name = str_replace("_", " ", $col->name); echo "<b>{$col->name}</b>: $cell<br>"; } echo "<br>"; }
  3. Thanks, problems solved. I used the tutorial atl_andy sent and it worked perfect. Thanks anyway tho atravotum!
  4. Sorry I must of cut it when copying and pasting: $sql = "SELECT * FROM $chosencollection"; $result_rec = mysql_query($sql); $sql_col = "SHOW COLUMNS FROM $chosencollection"; $result_col = mysql_query($sql_col);
  5. Hi I'm a php newbie and am currently stuck with a problem on an assignment i've been given. The problem is that I am struggling to display columns and records from a table. The thing thats confusing is that due to the nature of my site every table is different so I cannot display columns just by saying their names and using col["bleh"] . I've managed to get the code so I can display 1 record from the table but I cat get it to display more than one. I'm convinced I've made a simple mistake but i've been staring at this all day and am now brain dead. Thanks either way <? $i = 0; $j = 0; do{ echo "<table>"; while ($row = mysql_fetch_array($result_rec, MYSQL_NUM)) { while ($i < mysql_num_rows($result_col)) { $col[$i] = mysql_tablename($result_col, $i); echo( "<tr><td><b>" . $col[$i] . ":</b></td><td>" . $row[$i] . "</td></tr>"); $i++; } } echo "</table>"; $j++; }while ($j < mysql_num_rows($result_rec));
×
×
  • 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.