Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3956546
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:22:38+00:00 2026-05-20T02:22:38+00:00

Hey guys, got some of this code written, just having trouble with the bit

  • 0

Hey guys,
got some of this code written, just having trouble with the bit of MySQl that returns the found value’s row and subsequently a value in a column in that row.
So heres what I have

<?php
//mysql deets
$user="x";
$password="x";
$database="x";
$host="db285.x";

//open our db for check
mysql_connect($host,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");

$searchterm = "Dex";
$dbsearchterm = mysql_real_escape_string($searchterm); 
$query = "SELECT * FROM contacts WHERE name='$dbsearchterm';"; 
$res = mysql_query($query); 

if (mysql_num_rows($res) > 0) { 
    echo "found ".$searchterm."and the row it is in is ".$rownum." and value of the number column in row is ".$number;

} 
else {

    echo 'no find';

} 
mysql_close();
?>

So I can find if the name ‘dex’ is in there, but how can I return and set the row id and value in the row’s ‘number’ column?

Thanks guys,
Dex

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T02:22:39+00:00Added an answer on May 20, 2026 at 2:22 am

    Question isn’t very clear but it seems like you want to display the values from the database. If that’s the case then this should work, if this is not what you were after please clarify your question a little better.

    while ($row = mysql_fetch_assoc($res)) {
    echo "found ".$searchterm."and the row it is in is ".$row['id']." and value of the number column in row is ".$row['number'];
    }
    

    You haven’t posted your database fields, so replace the keys, $row['id'] and $row['number'] with the fields from your database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey Guys i got this code in my Activity: public class MYAppActivity extends Activity{
hey there guys and girls i have this code that saves json as a
Hey guys, I got this JS code and want to add a slight fade
Hey guys, I've got this jQuery code which works in Chrome and Safari but
Hey guys, I'm having a bit of trouble with my ASP:RadioButtonList, searched Google and
Hey guys i want to execute my SQL statement but im having synatx trouble,
Hey Guys, here is my code for this, the only help i get from
Hey guys, I've got what I imagine is a simple question, but for some
Hey guys I got a weird issue.. I have a datalist that's only loaded
Hey guys I'm creating a quick mysql file to create a DB with some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.