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

  • Home
  • SEARCH
  • 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 6695311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:12:25+00:00 2026-05-26T06:12:25+00:00

In mysql I use this code $somenumber=5; $result = mysql_query(SELECT * FROM some_table) while($row

  • 0

In mysql I use this code

$somenumber=5;
$result = mysql_query("SELECT * FROM some_table")
while($row = mysql_fetch_array($result)) {
echo $row['id'.$somenumber];
}

Please help me to do the same in the best way using mysqli, probably oop style I think cause everybody say best way to use oop way. Sorry I’m just studding 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-05-26T06:12:26+00:00Added an answer on May 26, 2026 at 6:12 am

    To do it with MySQLi OOP, you create an object, then call it’s query() method.

    $mysqli = new mysqli('hostname','user','password','databasename');
    if (!$mysqli) {
      // connect failure, check connect_error()
      echo $mysqli->connect_error();
    }
    else {
      // Call query() to execute your SQL
      $result = $mysqli->query("SELECT * FROM some_table");
      if ($result) {
        // $result is an object of type mysqli_result
        // Call fetch_assoc() on $result
        while ($row = $result->fetch_assoc())
          echo $row['id'];
      }
    }
    

    If you have input parameters which you’ll pass into your query, escape them with real_escape_string()

    $somevar = $mysqli->real_escape_string($somevar);
    $mysqli->query("SELECT * FROM sometable WHERE somecolumn='$somevar';");
    

    The principle benefits of MySQLi over the older mysql_* API are

    • The ability to use prepared statements instead of dynamic SQL strings
    • Object-oriented behavior which can be extended with your own classes.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

now i use this code: $welcome_text = mysql_query(SELECT * FROM `text` WHERE `name` =
I have this code for example : $b = ; while ($row = mysql_fetch_array($rows))
I want to use this to get data from row out of mysql database
<?php $sql1= mysql_query(SELCT * FROM adds ORDER BY adds_id DESC ); while($row=mysql_fetch_array($sql1)){?> <tr> <td
I use this code to get a Blob from a MySql database and it
I have stored 6 records in mysql db,when i use this code each of
I want to use this C code in my C++ project : mysql.c :
I'd like to use MySQL in this form: SELECT 1 AS one, one*2 AS
<?php include db.php; $username=$_POST['username']; $email=$_POST['email']; $query=SELECT * FROM members where username = '.mysql_real_escape_string($username).'; $result=mysql_query($query)or
I use this code: <?php $link = mysql_connect('nibiru.zarea.net/sqladmin', 'czoctopus','*******'); if (!$link) { die('<h1>Mysql error:

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.