Tuesday 7 July 2020

Get single row from MYSQL | PHP

Get a single row for editing or another purpose from MySql using PHP.



$conn=mysqli_connect("localhost","root","","girfadb");
$sql="select   name, phone  FROM  stu where  id=101";
$row=$conn->query($sql)->fetch_assoc() or die("<h1>Error</h1>". mysqli_error($conn));
echo $row['name'];
echo $row['phone'];
mysqli_close($conn);

Monday 6 July 2020

Record input and search program structure | C Language

Q : Write a ‘C’ program to read following details of 50 students.
      Student Name, Student Roll No, Class 
 Display total number of students studying in class “BCA”.

Answer : 



#include<stdio.h>
#include<conio.h>
#include "mylib.h"
/*============================
     Girfa Student Help
     Structure entry & search count
==============================*/
struct data
{
     int roll;
     char name[20];
     char cls[50];
};

Sunday 5 July 2020

Change/return more than value from function | C Language

Q : Write down three different methods used for referencing multiple values from a function.


Answer : you can return only one value from function using return statement but you can change multiple values from a function using a pointer, array, and structure. The following program will show you a demo. 




#include<stdio.h>
#include<conio.h>
#include "mylib.h"
/*============================
     Girfa Student Help
     Multiple value set from function
==============================*/
struct data
{
     int roll;
     int marks;
};

Create your own header file | C language

create  a blank file and  add following code

int sum(int a, int b)
{
     return(a + b);
}

save this file named with myheader.h

create  a new file and call your function  as given below

#include<stdio.h>

#include<conio.h>

#include "mylib.h"

/*============================

     Girfa Student Help

     Substring wihout using library function

==============================*/

void main()

{

  clrscr();

  printf("\n\t%d",sum(1,2));

  getch();

}