Jump to content


Photo

display id rather than row


  • Please log in to reply
10 replies to this topic

#1 bkthomas18

bkthomas18
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 15 September 2006 - 05:06 PM

I am a newbie to PHP/ MySQL and I have written this script to grab rows from a database table and display them on a web page.  I need the links to link to the id number rather than the row number.  Can someone please take a look at the code below and let me know what I need to do to change it.  I'm sure it is something fairly simple that I don't know how to do .  Thanks.

<?php

// Database Connection
mysql_connect('localhost','user','pass');
mysql_select_db('db');


// If current page number, use it
// if not, set one!

if(!isset($_GET['page'])){
    $page = 1;
} else {
    $page = $_GET['page'];
}

// Define the number of results per page
$max_results = 25;

// Figure out the limit for the query based
// on the current page number.
$from = (($page * $max_results) - $max_results); 

// Perform MySQL query on only the current page number's results

$sql = mysql_query("SELECT id, name FROM gentleman ORDER BY name");

while($row = mysql_fetch_array($sql)){
    // Build your formatted results here.
   echo ('<a href="1.php?page=' . $row['id'] . ' ">' . $row['name'] . ' </a><br />');
}

// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query("SELECT COUNT(id) as Num FROM gentleman"),0);

// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);

// Build Page Number Hyperlinks
echo "<center>Select a Page<br />";

// Build Previous Link
if($page > 1){
    $prev = ($page - 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> ";
}

for($i = 1; $i <= $total_pages; $i++){
    if(($page) == $i){
        echo "$i ";
        } else {
            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
    }
}

// Build Next Link
if($page < $total_pages){
    $next = ($page + 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>";
}
echo "</center>";
?>


#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 15 September 2006 - 05:11 PM

If I'm not overlooking anything, by id number you mean page number?. Then prehaps you want to use this:
echo ('<a href="1.php?page=' . $page . ' ">' . $row['name'] . ' </a><br />');

Rather than
echo ('<a href="1.php?page=' . $row['id'] . ' ">' . $row['name'] . ' </a><br />');


#3 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 15 September 2006 - 05:11 PM

I imagine this line is your link
echo ('<a href="1.php?page=' . $row['id'] . ' ">' . $row['name'] . ' </a><br />');

it actually looks fine. all you have to do is call on it on the 1.php page

<?php
$id = $_GET['id'];

$sql = "SELECT * FROM gentleman WHERE id = '$id'";
?>

Ray


#4 bkthomas18

bkthomas18
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 15 September 2006 - 05:34 PM

If I'm not overlooking anything, by id number you mean page number?. Then prehaps you want to use this:

echo ('<a href="1.php?page=' . $page . ' ">' . $row['name'] . ' </a><br />');

Rather than
echo ('<a href="1.php?page=' . $row['id'] . ' ">' . $row['name'] . ' </a><br />');


By ID number i mean the id number of the actual row, not the row number.  Once a row is deleted the next one is moved up but the id number stays the same so i need to actually get to the row based on the id number.

#5 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 15 September 2006 - 05:41 PM

By ID number i mean the id number of the actual row, not the row number.


Then your original code should be fine:
echo ('<a href="1.php?page=' . $row['id'] . ' ">' . $row['name'] . ' </a><br />');

$row['id'] holds the id number of the row in the database, thats is asociated with the name ($row['name']).

I'm a little confused at what you are trying to do.

#6 bkthomas18

bkthomas18
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 15 September 2006 - 05:44 PM

By ID number i mean the id number of the actual row, not the row number.


Then your original code should be fine:
echo ('<a href="1.php?page=' . $row['id'] . ' ">' . $row['name'] . ' </a><br />');

$row['id'] holds the id number of the row in the database, thats is asociated with the name ($row['name']).

I'm a little confused at what you are trying to do.

Thats what i thought but its not working.  Here is an example:

1.php?page=6  shows ID 10.  Do you see what I mean?

#7 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 15 September 2006 - 05:50 PM

Could you explain what this code is supposed to and what your aim is. As looking at your code you have implemented pagination to pagenate your results. However you use $page ($_GET['page']) to do something else. Which is where I'm getting confused.

Do you want to use $_GET['page'] to fetch more information based on the Name you click?

#8 bkthomas18

bkthomas18
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 15 September 2006 - 05:53 PM

Could you example what this code is supposed to and what your aim is. As looking at your code you ahve implemented pagination to pagenate your results. However you are use page ($_GET['page'] to do something else. Which where I'm getting confused.

Do you want to use $_GET['page'] to fetch more information based on the Name you click?

Yes I want to use $_GET['page'] to fetch information from the id specified and display it in 1.php.  Here is the code for 1.php:
<?php

// Database Connection
mysql_connect('localhost','user','pass');
mysql_select_db('db');


// If current page number, use it
// if not, set one!

if(!isset($_GET['page'])){
    $page = 1;
} else {
    $page = $_GET['page'];
}

// Define the number of results per page
$max_results = 1;

// Figure out the limit for the query based
// on the current page number.
$from = (($page * $max_results) - $max_results); 

// Perform MySQL query on only the current page number's results

$sql = mysql_query("SELECT id, name, city, state, phone, age, height, weight, hairc, eyec, occupation, income, networth, benefactor, benyn, other, datingsit, common, companion, traveler, perfectwoman, heighta, heightb, weighta, weightb, agea, ageb, haircolor, race, bodytype, specific, hour34, investa, investb FROM gentleman LIMIT $from, $max_results");

while($row = mysql_fetch_array($sql)){
    // Build your formatted results here.
   echo ('<table border="1" cellspacing="1" style="border-collapse: collapse" bordercolor="#000066" width="650" cellpadding="5">
  <tr><td colspan="3" bgcolor="#D6DFEF" height="16" bordercolor="#FFFFFF">&nbsp;</td></tr>
  <tr>
    <td height="30" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
    <td height="30" bgcolor="#EFF3F7" bordercolor="#FFFFFF">ID</td>
    <td height="30" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['id'] . ' </td>
  </tr>
  <tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Full Name </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['name'] . '</td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF"></td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">City</font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF"><p>' . $row['city'] . ' </p>
  </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF"></td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">State</font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['state'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF"></td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Phone</font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['phone'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Age</font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['age'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Height</font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['height'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Weight</font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['weight'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Hair Color </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['hairc'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Eye Color </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['eyec'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Occupation/ Business </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['occupation'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Income</font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">$ ' . $row['income'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Net Worth </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">$ ' . $row['networth'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Benefactor Situation? </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['benyn'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF"> Type of date match preferred
<font face="Verdana" size="2">&nbsp; </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['benefactor'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF"><font size="2" face="Verdana">If other, specified </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['other'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Dating Situation </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['datingsit'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">favorite activities/ hobbies and those you would like your date to have in common</td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['common'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
<td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">When, how often, and where would you plan or expect to spend quality time with your companion?</td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['companion'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
<td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">Would you like your dating match to be available for travel or do you prefer to meet new girls to date in each city?</td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['traveler'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
<td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">Describe your idea of the perfect woman for you. Include hobbies, interests, etc.</td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['perfectwoman'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Height Range </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['heighta'] . ' To ' . $row['heightb'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Weight Range </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['weighta'] . ' To ' . $row['weightb'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Age Range </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['agea'] . ' To ' . $row['ageb'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Hair color preference </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['haircolor'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Race</font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['race'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF"><font size="2" face="Verdana">Body Type </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['bodytype'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Bra Size </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['brasize'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
<td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">bodytype</font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF"><font size="2" face="Verdana">Specific Preferences </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['specific'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Commit to 3 or 4 hour lunch/ dinner date </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['hour34'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Monthly amount to invest on date, if benefactor. </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">$ ' . $row['investa'] . ' To $ ' . $row['investb'] . ' </td>
</tr>
</table>');
}

// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query("SELECT COUNT(id) as Num FROM gentleman"),0);

// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);

// Build Page Number Hyperlinks
echo "<center>Select a Page<br />";

// Build Previous Link
if($page > 1){
    $prev = ($page - 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> ";
}

for($i = 1; $i <= $total_pages; $i++){
    if(($page) == $i){
        echo "$i ";
        } else {
            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
    }
}

// Build Next Link
if($page < $total_pages){
    $next = ($page + 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>";
}
echo "</center>";
?>


#9 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 15 September 2006 - 06:13 PM

well you can't use page because your pagination is using it and why would you use pagination when you are only calling information on 1 row. It is also not going to work because you are not telling the page to look for the id as being set.

<?php
// Database Connection
mysql_connect('localhost','user','pass');
mysql_select_db('db');
if(isset($_GET['id'])){
// put query here to pull the record
$id = $_GET['id'];
$sql = "SELECT * FROM gentleman WHERE id = '$id'";

} else {
// If current page number, use it
// if not, set one!
if(!isset($_GET['page'])){
    $page = 1;
} else {
    $page = $_GET['page'];
}

// Define the number of results per page
$max_results = 1;

// Figure out the limit for the query based
// on the current page number.
$from = (($page * $max_results) - $max_results); 

// Perform MySQL query on only the current page number's results

$sql = mysql_query("SELECT id, name, city, state, phone, age, height, weight, hairc, eyec, occupation, income, networth, benefactor, benyn, other, datingsit, common, companion, traveler, perfectwoman, heighta, heightb, weighta, weightb, agea, ageb, haircolor, race, bodytype, specific, hour34, investa, investb FROM gentleman LIMIT $from, $max_results");

while($row = mysql_fetch_array($sql)){
    // Build your formatted results here.
   echo ('<table border="1" cellspacing="1" style="border-collapse: collapse" bordercolor="#000066" width="650" cellpadding="5">
  <tr><td colspan="3" bgcolor="#D6DFEF" height="16" bordercolor="#FFFFFF">&nbsp;</td></tr>
  <tr>
    <td height="30" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
    <td height="30" bgcolor="#EFF3F7" bordercolor="#FFFFFF">ID</td>
    <td height="30" bgcolor="#EFF3F7" bordercolor="#FFFFFF"><a href="'.$_SERVER['PHP_SELF'].'?id='.$row['id'].'">'.$row['id'].'</td>
  </tr>
  <tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Full Name </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['name'] . '</td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF"></td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">City</font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF"><p>' . $row['city'] . ' </p>
  </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF"></td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">State</font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['state'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF"></td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Phone</font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['phone'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Age</font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['age'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Height</font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['height'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Weight</font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['weight'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Hair Color </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['hairc'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Eye Color </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['eyec'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Occupation/ Business </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['occupation'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Income</font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">$ ' . $row['income'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Net Worth </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">$ ' . $row['networth'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Benefactor Situation? </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['benyn'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF"> Type of date match preferred
<font face="Verdana" size="2">&nbsp; </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['benefactor'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF"><font size="2" face="Verdana">If other, specified </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['other'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Dating Situation </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['datingsit'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">favorite activities/ hobbies and those you would like your date to have in common</td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['common'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
<td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">When, how often, and where would you plan or expect to spend quality time with your companion?</td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['companion'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
<td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">Would you like your dating match to be available for travel or do you prefer to meet new girls to date in each city?</td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['traveler'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
<td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">Describe your idea of the perfect woman for you. Include hobbies, interests, etc.</td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['perfectwoman'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Height Range </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['heighta'] . ' To ' . $row['heightb'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Weight Range </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['weighta'] . ' To ' . $row['weightb'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Age Range </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['agea'] . ' To ' . $row['ageb'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Hair color preference </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['haircolor'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Race</font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['race'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF"><font size="2" face="Verdana">Body Type </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['bodytype'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Bra Size </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['brasize'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
<td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">bodytype</font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF"><font size="2" face="Verdana">Specific Preferences </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['specific'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Commit to 3 or 4 hour lunch/ dinner date </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">' . $row['hour34'] . ' </td>
</tr><tr><td height="30" width="4" bgcolor="#EFF3F7" bordercolor="#FFFFFF">&nbsp;</td>
  <td height="30" width="295" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">Monthly amount to invest on date, if benefactor. </font></td>
<td height="30" width="812" bgcolor="#EFF3F7" bordercolor="#FFFFFF">$ ' . $row['investa'] . ' To $ ' . $row['investb'] . ' </td>
</tr>
</table>');
}

// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query("SELECT COUNT(id) as Num FROM gentleman"),0);

// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);

// Build Page Number Hyperlinks
echo "<center>Select a Page<br />";

// Build Previous Link
if($page > 1){
    $prev = ($page - 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> ";
}

for($i = 1; $i <= $total_pages; $i++){
    if(($page) == $i){
        echo "$i ";
        } else {
            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
    }
}

// Build Next Link
if($page < $total_pages){
    $next = ($page + 1);
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>";
}
echo "</center>";
}
?>






#10 bkthomas18

bkthomas18
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 15 September 2006 - 06:16 PM

well you can't use page because your pagination is using it and why would you use pagination when you are only calling information on 1 row. It is also not going to work because you are not telling the page to look for the id as being set.


What would be the correct way to call the rows by id?  I'm new to this and very confused.  All help is greatly appreciated.

#11 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 15 September 2006 - 06:26 PM

I changed your code and put it above, just copy and paste it. I did not finish the sql and output of the data for the specific row. Insert that after.
// put query here to pull the record
$id = $_GET['id'];
$sql = "SELECT * FROM gentleman WHERE id = '$id'";

Ray





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users