PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, February 2, 2022

[FIXED] Can I store query result of one field into different variables? if not then what should I do for that?

 February 02, 2022     mysql, php, phpmyadmin     No comments   

Issue

This code shows the output as subject1 subject2 subject3 subject4 but I want to store that values in different variables (like $s1=[1],$s2[2],$s3[3],$s4[4]) so I and use them in different functions what should I do? can any one help please...


Solution

$query = mysql_query("select `subject` from `markssub1` where `sname`='$user' AND `sid`='$id'");

$subjects = [];

while($row = mysql_fetch_array($query))
{
    $subjects[] = $row['subject'];  
}

foreach($subjects as $subject){
    echo $subject . '\n';
}


Answered By - noahnu
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing