Jump to content

stratusdodge

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

stratusdodge's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Oh, and I almost forgot---Thanks for your help lemmin and ChristianF!!
  2. OK, so I fixed it myself by changing the tables: $result = mysql_query("SELECT concat(first_name, ' ', last_name), email, country, TimeStamp FROM {$table} order by {$sortkey} LIMIT $id, {$records_per_page}") or die(mysql_error()); $result_id = mysql_query("SELECT concat(first_name, ' ', last_name), email, country, TimeStamp, id FROM {$table} order by {$sortkey} desc LIMIT $id, {$records_per_page}") or die(mysql_error()); if (!$result) { die("Query to show fields from table failed"); } $fields_num = mysql_num_fields($result); echo "<table id='tabledata' cellpadding='5'><tr>"; //Insert table headers echo '<td><b><a href="'.$_SERVER['PHP_SELF'].'?sortkey='.(first_name).'">Name</a></b></td>'; echo '<td><b><a href="'.$_SERVER['PHP_SELF'].'?sortkey='.(email).'">E-Mail</a></b></td>'; echo '<td><b><a href="'.$_SERVER['PHP_SELF'].'?sortkey='.(country).'">Country</a></b></td>'; echo '<td><b><a href="'.$_SERVER['PHP_SELF'].'?sortkey='.(id).'">Date Created</a></b></td>'; echo "<tr>\n"; // Display the table rows while($row = mysql_fetch_row($result)) while($row_id = mysql_fetch_row($result_id)) foreach($row as $cell) echo "<td><a href=../ui/edit_customer.php&id=$row_id[4]>$cell</a></td>"; echo "</tr>\n"; } mysql_free_result($result);
  3. Anyone? Any help at all would be appreciated.
  4. OK. Let's start over. The following code displays a table on my page: $result = mysql_query("SELECT concat(first_name, ' ', last_name), email, country, TimeStamp FROM {$table} order by {$sortkey} LIMIT $id, {$records_per_page}") or die(mysql_error()); $fields_num = mysql_num_fields($result); echo "<table id='tabledata' cellpadding='5'><tr>"; //Table Headers echo '<td><b><a href="'.$_SERVER['PHP_SELF'].'?sortkey='.(first_name).'">Name</a></b></td>'; echo '<td><b><a href="'.$_SERVER['PHP_SELF'].'?sortkey='.(email).'">E-Mail</a></b></td>'; echo '<td><b><a href="'.$_SERVER['PHP_SELF'].'?sortkey='.(country).'">Country</a></b></td>'; echo '<td><b><a href="'.$_SERVER['PHP_SELF'].'?sortkey='.(id).'">Date Created</a></b></td>'; echo "<tr>\n"; while($row = mysql_fetch_row($result)) { if ($c&1) { echo "<tr class=odd>"; } else { echo "<tr class=even>"; } // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach($row as $cell) echo "<td><a href=../ui/edit_customer.php&id=[???????]>$cell</a></td>"; echo "</tr>\n"; $c++; } The "ID" is a column in my MySQL database but I haven't selected it. I want each value in the table to link (example http://www.google.ca/ref=[iNSERT ID HERE]). If I select the ID, it gets displayed in the table. So the question is, how do I extract the ID and assign it as a link to each row?
  5. The first query gets the rows that are being displayed on the table. The second query gets the ID (i've since cleaned this up to only get the ID). If I use just the first query then the ID is being displayed in the table. I don't want this.
  6. Hello all, I have a PHP table that populates from a MySQL database. I want to link each result in the table to their respective unique ID. The code below links each result to a unique ID, however the table now repeats the same name on every row. Any ideas? $result = mysql_query("SELECT concat(first_name, ' ', last_name), email, country, TimeStamp FROM {$table} order by {$sortkey} LIMIT $id, {$records_per_page}") or die(mysql_error()); $result_id = mysql_query("SELECT concat(first_name, ' ', last_name), email, country, TimeStamp, id FROM {$table} order by {$sortkey} desc LIMIT $id, {$records_per_page}") or die(mysql_error()); if (!$result) { die("Query to show fields from table failed"); } $fields_num = mysql_num_fields($result); echo "<table id='tabledata' cellpadding='5'><tr>"; //Insert table headers echo '<td><b><a href="'.$_SERVER['PHP_SELF'].'?sortkey='.(first_name).'">Name</a></b></td>'; echo '<td><b><a href="'.$_SERVER['PHP_SELF'].'?sortkey='.(email).'">E-Mail</a></b></td>'; echo '<td><b><a href="'.$_SERVER['PHP_SELF'].'?sortkey='.(country).'">Country</a></b></td>'; echo '<td><b><a href="'.$_SERVER['PHP_SELF'].'?sortkey='.(id).'">Date Created</a></b></td>'; echo "<tr>\n"; // Display the table rows while($row = mysql_fetch_row($result)) while($row_id = mysql_fetch_row($result_id)) foreach($row as $cell) echo "<td><a href=../ui/edit_customer.php&id=$row_id[4]>$cell</a></td>"; echo "</tr>\n"; } mysql_free_result($result);
×
×
  • 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.