Jump to content

MYSQL&PHP help, how to?


dcgamers

Recommended Posts

try this :
[code]
$query = "SELECT * from $db_table ORDER by $some_field DESC"; // don't have a LIMIT in it
$select_query = mysql_query($query, $link)
   or die("Couldn't select from $db_table ".mysql_error() );
$num_rows = mysql_num_rows($select_query); // gets number of rows
[/code]
Link to comment
Share on other sites

Thanks it worked.
Hey I'm a c++ guy not a php guy :).
I have one more question and it is about Mysql_query and displaying in a loop, the contents of a database table. I need to know how to be able to click on a link in the loop (per looped item that is) and make it take me to a page where there will be more data for that specific item. Sorry this may be confusing, I don't know the right term names.
Link to comment
Share on other sites

[!--quoteo(post=364269:date=Apr 13 2006, 02:39 PM:name=dcgamers)--][div class=\'quotetop\']QUOTE(dcgamers @ Apr 13 2006, 02:39 PM) [snapback]364269[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Thanks it worked.
Hey I'm a c++ guy not a php guy :).
I have one more question and it is about Mysql_query and displaying in a loop, the contents of a database table. I need to know how to be able to click on a link in the loop (per looped item that is) and make it take me to a page where there will be more data for that specific item. Sorry this may be confusing, I don't know the right term names.
[/quote]

Just use a one row table and echo the values from your query you want, but before the able put this line of code:

[code]<?php do { ?>[/code]

And after the table put the code:

[code]<?php } while ($row_NAME-OF-QUERY = mysql_fetch_assoc($NAME-OF-QUERY )); ?>[/code]

In the table put a link to another page something like this:

[code]<a href="otherpage.php?ID=<?php echo $row_NAME-OF-QUERY['IDFEILD'];?>">More Info</a>[/code]

On your second page make a query that is filtered by the URL Paramater ID and use the ID feild

Hope that all makes sense, not good at explaining
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.