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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:49:26+00:00 2026-06-13T02:49:26+00:00

I have a database called forms1 and a table named demo The fields in

  • 0

I have a database called forms1 and a table named demo
The fields in the table are ID, Autore, Titolo, cit

I wish I had a first line that gives me the ability to sort alphanumeric values ​​that are retrieved by the query, such as
enter image description here

How can i modify my code?
This is cerca2.php:

<style>
br {margin-bottom:-10px;}
</style>

<form action="cerca2.php" method="post">
<b>Nome</b>&nbsp;<input type="text" name="Nome">&nbsp;&nbsp;
<b>Numero&nbsp;</b><input type="text" name="Numero">&nbsp;&nbsp;
<b>city&nbsp;</b><input type="text" name="city">&nbsp;&nbsp;
<input type="Submit">
</form>

<style>
tr:nth-of-type(odd) { background-color: AZURE; }
tr:nth-of-type(even) { background-color: CYAN; }
</style>
<style>
tr:hover{background-color<img src="images/smilies/biggrin.gif" border="0" alt="">EEPSKYBLUE;}
</style>

<?php

echo "<table border='1' style='border-collapse: collapse;border-color: silver;'>";  
echo "<tr style='font-weight: bold;'>";  
echo "<td width='auto' bgcolor=”#7FFFD4&#8243;>&nbsp;<i>ID<i/></td>";  
echo "<td width='auto' >&nbsp;<i>Nome<i/></td>";
echo "<td width='auto' ></td>";
echo "<td ></td>";
echo "</tr>";

define('DB_NAME', 'forms1');
define('DB_USER', 'root');
define('DB_PASSWORD', '');
define('DB_HOST', 'localhost');

$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$link) {
    die('Could not connect: ' . mysql_error());
}

$db_selected = mysql_select_db(DB_NAME, $link);

if (!$db_selected) {
    die('Can't use ' . DB_NAME . ': ' . mysql_error());
}

$Nome = str_replace(' ', '%', $_POST['Nome']);
$Numero = str_replace(' ', '%', $_POST['Numero']); 
$city = str_replace(' ', '%', $_POST['city']); 

$arNome = str_split($Nome);
$arNumero = str_split($Numero);
$arcity = str_split($city);

$Nome='';
foreach ($arNome as $value) 
{
   if ($value=='%') continue;
   $Nome.=$value.'%';

}

$Numero='';
foreach ($arNumero as $value) 
{
   if ($value=='%') continue;
   $Numero.=$value.'%';

}

$city='';
foreach ($arcity as $value) 
{
   if ($value=='%') continue;
   $city.=$value.'%';

}

$sql = mysql_query("SELECT * FROM demo WHERE Autore LIKE '%$Nome%' AND Titolo LIKE '%$Numero%' AND cit LIKE '%$city%' ORDER BY Autore") or die(mysql_error());

while($row=mysql_fetch_array($sql)){

    echo "<tr>";
    echo "<td width='auto' bgcolor=”#FF0000 &#8243;>" . "&nbsp;". "<b>"  . $row[0] . "&nbsp;". "<b/>". "</td>";
    echo "<td width='auto'>" . "&nbsp;" . $row[1] . "&nbsp;" . "</td>";
    echo "<td width='auto'>". "</td>";
    echo "<td width='auto'>" . "&nbsp;". "<i>" . $row[2] . "<i/>". "&nbsp;" . "</td>";     
    echo "<td width='auto'>" . "&nbsp;". "<i>" . $row[3] . "<i/>". "&nbsp;" . "</td>";
    echo "</tr>";
    
}
mysql_close();
?> 

I would click on Nome and other th (except ID) to reorder the values ​​alphanumeric AZ or ZA viceversa when i click. At the moment this is my result page (look code above) when i call a query:
enter image description here

I would, too – but I do not know how to do – that the ID value always start from 1 and continue in numerical order according to the number of x values ​​retrieved every time I make a query or sort from th tag.
In my case, instead, is always dependent on the value it represents.
You see it from the picture that the numbers appear in random order.
Here, I do not want this.

  • 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-13T02:49:28+00:00Added an answer on June 13, 2026 at 2:49 am

    Try this code-part:

        $i = 0; while($row=mysql_fetch_array($sql)){
            $i++;
            echo "<tr>";
            echo "<td width='auto' bgcolor=”#FF0000 &#8243;>" . "&nbsp;". "<b>"  . $i . "&nbsp;". "<b/>". "</td>";
            echo "<td width='auto'>" . "&nbsp;" . $row[1] . "&nbsp;" . "</td>";
            echo "<td width='auto'>". "</td>";
            echo "<td width='auto'>" . "&nbsp;". "<i>" . $row[2] . "<i/>". "&nbsp;" . "</td>";     
            echo "<td width='auto'>" . "&nbsp;". "<i>" . $row[3] . "<i/>". "&nbsp;" . "</td>";
            echo "</tr>";
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Have a database called 'lms' with two tables loan and value, table loan
Say I have a database called Poll and have these two table structures. poll
I have a MySQL database table called Participant that looks something like this: (idParticipant)
I have an ms-access database called db.mdb and it contains various table. I;m creating
I have a table on my database called 'Log'. This Log table contains ID,
I have a MYSQL database table called 'wp_quotes' with a field that contains a
I have a table in my database called agendas which is linked with another
I have 3 fieldnames called ID , Autore , Titolo in Mysql. The tablename
I have a database called ADB. When I create a new user/role, that user
I have a MySQL database called csftdb and in that database there exists 1

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.