Click here to Skip to main content
15,792,959 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
The following PHP code needs to be converted to C#.
Is there anyone who can provide me with a response in the form of output?
Click here to see my codes

What I have tried:

I've made no attempt at all
Updated 1-Apr-22 23:35pm
Richard MacCutchan 2-Apr-22 4:16am    
There is no simple conversion. You will need to start from scratch with C#, based on whatever design requirements you have.

Accordingly to the documentation: PHP: mysqli_result::fetch_row[^]
Fetches one row of data from the result set and returns it as an enumerated array, where each column is stored in an array offset starting from 0 (zero). Each subsequent call to this function will return the next row within the result set, or null if there are no more rows.

So, when you've got a set of records, you need to loop through the collection of rows/data of SqlDataReader[^]/DataTable[^] object. You can use while or foreach.
Share this answer
I've made no attempt at all

While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]

And this is not a code conversion service anyway: we are not here to translate code for you.
Even if we did, what you would end up with would not be "good code" in the target language – they are based on very different frameworks, and what makes something work in one language does not always "translate" directly into another.
So what you end up with is very poor code, that is difficult if not impossible to maintain, that can’t be upgraded nicely, and that will cause you immense headaches if the original is changed. And it'll be a nightmare to debug if it doesn’t work "straight out of the box".
Instead, use the source code as a specification for a new app written in and for the target language / framework and write it from scratch using the original as a "template". You will get a much, much better result that will save you a lot of time in the long run.
Share this answer
Reza jafery 3-Apr-22 12:00pm    
I'm not a beginner in C # and I do not want to learn PHP.
OriginalGriff 3-Apr-22 12:24pm    
So don't use PHP code ...
Reza jafery 5-Apr-22 12:28pm    
I have to do this for my university

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900