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 8788709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:12:17+00:00 2026-06-13T22:12:17+00:00

i have selected some rows from mysql and i want put underscore between the

  • 0

i have selected some rows from mysql

and i want put underscore between the words

like this :

<?php
$query='SELECT * FROM subcates WHERE maincates_id=1';
$result=mysql_query($query);
while($row=mysql_fetch_array($result, MYSQL_ASSOC)){
    echo "<li><a href='".$row['name'].".php?c=".$row['id']."&gov=1&h=1'>".$row['name']."</a></li>";    
}
?>

i want when select the name give me this :

in database ==> first second

i want it when selected ==> first_second

thx

  • 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-06-13T22:12:18+00:00Added an answer on June 13, 2026 at 10:12 pm

    Try:

    //Considering its the $row['name'] that you want in first_second format
    while($row=mysql_fetch_array($result, MYSQL_ASSOC)){
      $row['name'] = str_replace(' ', '_', $row['name']);
      echo "<li><a href='".$row['name'].".php?c=".$row['id']."&gov=1&h=1'>".$row['name']."</a></li>";
    

    }

    Edit:

      $query='SELECT * FROM subcates WHERE maincates_id=1';
      $result = mysql_query($query); 
      while($row=mysql_fetch_array($result, MYSQL_ASSOC)){
      if( current($result) === 'First second' ) {
        $new_name = str_replace(' ', '_', $row['name']);
       echo "<li><a href='".$new_name.".php?c=".$row['id']."&gov=1&h=1'>".$new_name."  </a></li>";
     }
      else        
         echo "<li><a href='".$row['name'].".php?=".$row['id']."&gov=1&h=1'>".$row['name']."  </a></li>";    
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP server script that SELECTs some data from a MySQL database.
I have a edittext in which some text are selected . I want to
I have a table which show data from mysql database in HTML table like
I'm exporting some data from MySQL which can be selected through checkboxes on a
I have some php querying and printing the info of a mysql table on
I have this query: select distinct id,name from table1 For a given ID, the
I have a PHP page that displays the results of a mysql query. each
I have to show records in such a way that some selected records should
For some reason I am getting the error No database selected I have no
I have some activity were user goes through it and finally send the selected

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.