Jump to content

sinisnap

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

sinisnap's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. ah thank you! how could i have been so blind..
  2. hi i'm using the code below to extract data from a mysql db and first show it in a table in the browser and also update/write to a text file on the server. the first part is working fine. the second part..although it doesn't give me an error, the orders.txt file remains completely blank. so i'm assuming there's some problem with the fopen/fwrite part of the script? can anyone help? thank you!! <?php require("../elements/global-vars.inc.php"); require("../elements/database-connection.inc.php"); /* Build your SQL statement however you need. */ $sql = "SELECT * FROM orders, users WHERE filled = 'false' AND orders.userID = users.userID ORDER BY date"; /* Execute the query. */ if (!$res = @mysql_query($sql)) { die(mysql_error()); return false; } /* Create an array of arrays out of the recordset. */ while ($row = mysql_fetch_array($res, MYSQL_ASSOC)) { $data[] = $row; } /* Now iterate through the recordset creating a simple table. */ echo "<style>table.dump { font-family:Arial; font-size:10pt; }</style>"; echo "<table class=\"dump\" border=\"1\" cellpadding=\"1\" cellspacing=\"0\">\n"; echo "<tr>"; echo "<th>#</th>"; foreach($data[0] as $key=>$val) { echo "<th><b>"; echo $key; echo "</b></th>"; } echo "</tr>\n"; $row_cnt = 0; foreach($data as $row) { $row_cnt++; echo "<tr align='center'>"; echo "<td>".$row_cnt."</td>"; foreach($row as $val) { echo "<td>"; echo $val; echo "</td>"; } echo"</tr>\n"; } echo "</table>\n"; /*Next, you need to know how to save the recordset back into a TAB delimited file. This example uses the $data value from the code example above. */ $fp = fopen('orders/orders.txt', 'w') or die("ERROR: can't open file for writing");; foreach($data as $row) { $line = ""; foreach($row as $val) { $line .= "\t\"".$val."\""; } /* Strip off the first TAB and add a carriage return. */ $line = substr($line, 1)."\n"; $fwrite($fp, $line); } fclose($fp); ?>
  3. Hi This is my first post, so please be kind... I'm trying to build a sub-nav that lists all volumes in one table but they need to be grouped according to their publishing date id's with a header for each group stating the respective publishing date. in the end it should look like this: [img]http://www.sinisnap.com/subnav.gif[/img] i got the basic mysql query right, i believe and it goes like this: [code]  $result = @mysql_query(       "SELECT title, date FROM volume, pubdate WHERE volume.pdid = pubdate.id ORDER BY pubdate.id");   if (!$result) {     exit('<p>Error fetching volume details: ' .         mysql_error() . '</p>');   }[/code] however, i'm not sure how to proceed from there..anyone able to/care to give me some pointers on how to approach this? thank you! jarin
×
×
  • 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.