Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,170 members, 7,815,091 topics. Date: Thursday, 02 May 2024 at 07:07 AM

Guru In Php - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Guru In Php (1262 Views)

When You Are A Computer Guru And Your Girlfriend Needs Your Assistance / Need A Guru In Internet Marketing For A Bussiness Deal Partnership / Any Html Guru In The House? (2) (3) (4)

(1) (Reply) (Go Down)

Guru In Php by ajaxphp7: 11:53am On Jun 25, 2010
SELECT *
FROM `populate`
WHERE `matricno` LIKE '0009'
AND `level` LIKE 'ND1'
AND `semester` LIKE 'FIRST SEMESTER'
LIMIT 0 , 3

Please guru's in php and mysql
How do I replace the '0009', 'ND1', 'FIRST SEMESTER'
with variables in php.
Re: Guru In Php by Afam4eva(m): 12:55pm On Jun 25, 2010
You'll have create a PHP variable for '0009', 'ND1', and 'FIRST SEMESTER'. Try something like this.

<?php

$matric_no=0009;
$level = "ND1";
$semester = "FIRST SEMESTER";

$host = "localhost";
$account = "" ## The name of your account goes here
$password = "" ## The password goes here
$database = "" ## The password goes here

$connect=mysql_connect($host, $account, $password);
mysql_select_db($database, $connect);

$sql="SELECT *
FROM populate
WHERE matricno LIKE '$matric_no'
AND level LIKE '$level'
AND semester LIKE '$semester'";

$result=mysql_query($sql, $connect);
$row=mysql_fetch_array($result);

mysql_close();


?>

I hopes this helps.
Re: Guru In Php by jeshurun07: 1:55pm On Jun 25, 2010
why not?

<?php

$matric_no=0009;
$level = "ND1";
$semester = "FIRST SEMESTER";

$host = "localhost";
$account = "" ## The name of your account goes here
$password = "" ## The password goes here
$database = "" ## The password goes here

$connect=mysqli_connect($host, $account, $password,$database);

$sql="SELECT *
FROM populate
WHERE matricno LIKE '$matric_no'
AND level LIKE '$level'
AND semester LIKE '$semester'";

$result=mysqli_query($connect,$sql);
$row=mysqli_fetch_array($result);

mysqli_close($connect);


?>

In my personal opinion, this is more secured.
Re: Guru In Php by ajaxphp7: 4:37pm On Jun 25, 2010
Thanks very much I really Appreciate I will try it now
Re: Guru In Php by ajaxphp7: 5:02pm On Jun 25, 2010
Thanks very 4 the contribution but I am still having problems with the coding.

This is a school website which I am supposed.
I have two pages the first page has the form that will do the search
with the following fields
matric no
Semester
level
and a check result button
which when users click on it, it will go to the database and search for matching row and fetch it out.
using echo. This is the result page which I have embeded your code in but still not working

<?php require_once('dj.php'); ?>
<?php
$matric_no=0009;
$level = "ND1";
$semester = "FIRST SEMESTER";

$host = "localhost";
$account = "root"
$password = " "
$database = "student affairs"
$connect=mysql_connect($host, $account, $password);
mysql_select_db($database, $connect);

$sql="SELECT *
FROM populate
WHERE matricno LIKE '$matric_no'
AND level LIKE '$level'
AND semester LIKE '$semester'";

$result=mysql_query($sql, $connect);
$row=mysql_fetch_array($result);

mysql_close();


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#apDiv1 {
position:absolute;
width:886px;
height:340px;
z-index:1;
}
-->
</style>
</head>

<body>
<div id="apDiv1">
<table border="1">
<tr>
<td>matricno</td>
<td>firstname</td>
<td>lastname</td>
<td>othername</td>
<td>level</td>
<td>course1</td>
<td>course2</td>
<td>course3</td>
<td>course4</td>
<td>course5</td>
<td>course6</td>
<td>course7</td>
<td>course8</td>
<td>course9</td>
<td>course10</td>
<td>grade1</td>
<td>grade2</td>
<td>grade3</td>
<td>grade4</td>
<td>grade5</td>
<td>grade6</td>
<td>grade7</td>
<td>grade8</td>
<td>grade9</td>
<td>grade10</td>
<td>code1</td>
<td>code2</td>
<td>code3</td>
<td>code4</td>
<td>code5</td>
<td>code6</td>
<td>code7</td>
<td>code8</td>
<td>code9</td>
<td>code10</td>
<td>cgpa</td>
<td>department</td>
<td>semester</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['matricno']; ?></td>
<td><?php echo $row_Recordset1['firstname']; ?></td>
<td><?php echo $row_Recordset1['lastname']; ?></td>
<td><?php echo $row_Recordset1['othername']; ?></td>
<td><?php echo $row_Recordset1['level']; ?></td>
<td><?php echo $row_Recordset1['course1']; ?></td>
<td><?php echo $row_Recordset1['course2']; ?></td>
<td><?php echo $row_Recordset1['course3']; ?></td>
<td><?php echo $row_Recordset1['course4']; ?></td>
<td><?php echo $row_Recordset1['course5']; ?></td>
<td><?php echo $row_Recordset1['course6']; ?></td>
<td><?php echo $row_Recordset1['course7']; ?></td>
<td><?php echo $row_Recordset1['course8']; ?></td>
<td><?php echo $row_Recordset1['course9']; ?></td>
<td><?php echo $row_Recordset1['course10']; ?></td>
<td><?php echo $row_Recordset1['grade1']; ?></td>
<td><?php echo $row_Recordset1['grade2']; ?></td>
<td><?php echo $row_Recordset1['grade3']; ?></td>
<td><?php echo $row_Recordset1['grade4']; ?></td>
<td><?php echo $row_Recordset1['grade5']; ?></td>
<td><?php echo $row_Recordset1['grade6']; ?></td>
<td><?php echo $row_Recordset1['grade7']; ?></td>
<td><?php echo $row_Recordset1['grade8']; ?></td>
<td><?php echo $row_Recordset1['grade9']; ?></td>
<td><?php echo $row_Recordset1['grade10']; ?></td>
<td><?php echo $row_Recordset1['code1']; ?></td>
<td><?php echo $row_Recordset1['code2']; ?></td>
<td><?php echo $row_Recordset1['code3']; ?></td>
<td><?php echo $row_Recordset1['code4']; ?></td>
<td><?php echo $row_Recordset1['code5']; ?></td>
<td><?php echo $row_Recordset1['code6']; ?></td>
<td><?php echo $row_Recordset1['code7']; ?></td>
<td><?php echo $row_Recordset1['code8']; ?></td>
<td><?php echo $row_Recordset1['code9']; ?></td>
<td><?php echo $row_Recordset1['code10']; ?></td>
<td><?php echo $row_Recordset1['cgpa']; ?></td>
<td><?php echo $row_Recordset1['department']; ?></td>
<td><?php echo $row_Recordset1['semester']; ?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
</div>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>


I need the form that does the search to display information from the database.
Thanks very much
Re: Guru In Php by ajaxphp7: 5:04pm On Jun 25, 2010
Any contribution is welcome
Re: Guru In Php by Nobody: 9:21pm On Jun 25, 2010
try changing the mysql_fetc_assoc to mysql_fetch_array,
Re: Guru In Php by onyengbu1(m): 10:50am On Jun 26, 2010
@ajax php,

You are muddling up  the hard coded script that people are giving you here with your Dreamweaver generated script.

From your line one, you included a DB connection by DW and also on the same script created a new connection posted here on NL.

Please choose one.

This is how I will do it, according to your explanation:

There are 2 pages: search.php and resultPage.php

for search.php

<form name="form1" method="post" action="resultPage.php">
Matric Number:
  <input name="matricno" type="text" id="matricno">

  Semester:
  <select name="semester" id="semester">
    <option selected>Select Semester</option>
    <option value="1">1st Semester</option>
    <option value="2">2nd Semester</option>
        </select>
  Level:
  <select name="level" id="level">
    <option selected>Select Level</option>
    <option value="100">100</option>
    <option value="200">200</option>
    <option value="300">300</option>
    <option value="400">400</option>
    <option value="500">500</option>
  </select>
 
  <input type="submit" name="Submit" value="Check Result">

</form>

Then for resultPage.php

Using edited jeshurun07's script and yours:


<?php

$matricno=  $_POST['matricno'];
$level = $_POST['level'];
$semester = $_POST['semester'];

$host = "localhost";
$account = "root"     ## The name of your account goes here
$password = " "     ## The password goes here
$database = "student affairs"    ///  did you seriously create a DB with space on the name?!!   shocked  shocked  shocked

$connect=mysqli_connect($host, $account, $password,$database);

$sql="SELECT *
FROM populate
WHERE matricno LIKE '$matricno'
AND level LIKE '$level'
AND semester LIKE '$semester'";

$result=mysqli_query($connect,$sql);
$row=mysqli_fetch_array($result);

mysqli_close($connect);


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#apDiv1 {
position:absolute;
width:886px;
height:340px;
z-index:1;
}
-->
</style>
</head>

<body>
<div id="apDiv1">
  <table border="1">
    <tr>
      <td>matricno</td>
      <td>firstname</td>
      <td>lastname</td>
      <td>othername</td>
      <td>level</td>
      <td>course1</td>
      <td>course2</td>
      <td>course3</td>
      <td>course4</td>
      <td>course5</td>
      <td>course6</td>
      <td>course7</td>
      <td>course8</td>
      <td>course9</td>
      <td>course10</td>
      <td>grade1</td>
      <td>grade2</td>
      <td>grade3</td>
      <td>grade4</td>
      <td>grade5</td>
      <td>grade6</td>
      <td>grade7</td>
      <td>grade8</td>
      <td>grade9</td>
      <td>grade10</td>
      <td>code1</td>
      <td>code2</td>
      <td>code3</td>
      <td>code4</td>
      <td>code5</td>
      <td>code6</td>
      <td>code7</td>
      <td>code8</td>
      <td>code9</td>
      <td>code10</td>
      <td>cgpa</td>
      <td>department</td>
      <td>semester</td>
    </tr>
    <?php do { ?>
      <tr>
        <td><?php echo $row['matricno']; ?></td>
        <td><?php echo $row['firstname']; ?></td>
        <td><?php echo $row['lastname']; ?></td>
        <td><?php echo $row['othername']; ?></td>
        <td><?php echo $row['level']; ?></td>
        <td><?php echo $row['course1']; ?></td>
        <td><?php echo $row['course2']; ?></td>
        <td><?php echo $row['course3']; ?></td>
        <td><?php echo $row['course4']; ?></td>
        <td><?php echo $row['course5']; ?></td>
        <td><?php echo $row['course6']; ?></td>
        <td><?php echo $row['course7']; ?></td>
        <td><?php echo $row['course8']; ?></td>
        <td><?php echo $row['course9']; ?></td>
        <td><?php echo $row['course10']; ?></td>
        <td><?php echo $row['grade1']; ?></td>
        <td><?php echo $row['grade2']; ?></td>
        <td><?php echo $row['grade3']; ?></td>
        <td><?php echo $row['grade4']; ?></td>
        <td><?php echo $row['grade5']; ?></td>
        <td><?php echo $row['grade6']; ?></td>
        <td><?php echo $row['grade7']; ?></td>
        <td><?php echo $row['grade8']; ?></td>
        <td><?php echo $row['grade9']; ?></td>
        <td><?php echo $row['grade10']; ?></td>
        <td><?php echo $row['code1']; ?></td>
        <td><?php echo $row['code2']; ?></td>
        <td><?php echo $row['code3']; ?></td>
        <td><?php echo $row['code4']; ?></td>
        <td><?php echo $row['code5']; ?></td>
        <td><?php echo $row['code6']; ?></td>
        <td><?php echo $row['code7']; ?></td>
        <td><?php echo $row1['code8']; ?></td>
        <td><?php echo $row['code9']; ?></td>
        <td><?php echo $row['code10']; ?></td>
        <td><?php echo $row['cgpa']; ?></td>
        <td><?php echo $row['department']; ?></td>
        <td><?php echo $row['semester']; ?></td>
      </tr>
      <?php } while ($row = mysql_fetch_assoc($result)); ?>
  </table>
</div>
</body>
</html>

What I did here was to use the variables from the form on the search.php and integrate it into  Jeshurun07's connection and then echo out your result with right variables from the connection and not the one you were echoing from your DW 'Recordset'.

### There are too many things you will still need to do to these scripts like checking the matricno field for sql injection, making sure that submit button from the search page is clicked before executing the script on resultPage.php and then . . . .

also, why are you using 'LIKE' in a query that is supposed to locate peoples result?  I would use '=' if it were mine since I know that students know their matric nos and wouldnt be guessing.
Re: Guru In Php by Nobody: 2:06pm On Jun 26, 2010
onye_ngbu:

why are you using 'LIKE' in a query that is supposed to locate peoples result?  I would use '=' if it were mine since I know that students know their matric nos and wouldnt be guessing.


Exactly,
Re: Guru In Php by ajaxphp7: 3:19pm On Jun 28, 2010
I am grateful 4 the contributions. I will try it now
Re: Guru In Php by ajaxphp7: 5:20pm On Jun 28, 2010
I new that u guys could be helpful not till i start this project. I want to still thank you a lot for the contribution so far
with the last script submited that is the error am having on my browser
Warning: mysql_query() expects parameter 1 to be string, resource given
Warning: mysql_fetch_row() expects parameter 1 to be resource
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, null given

pls i still need ur contribution
Re: Guru In Php by onyengbu1(m): 9:45am On Jun 30, 2010
im sorry im coming back late to your question

the line where u have:
<?php } while ($row = mysql_fetch_assoc($result)); ?>

Should be:
<?php } while ($row = mysqli_fetch_assoc($result)); ?>

'i' is missing there.

Do that and let me know how it went
Re: Guru In Php by ajaxphp7: 12:59pm On Jun 30, 2010
onye_ngbu thanks very much for your quick response. I just find out that I have to change my pattern of coding when I do it was successful as I am retrieving student information with just the matric no and in my sql database datatype for matricno was changed to int. When I did it that way it was successful, but when I decided to use varchar which is the datatype that matches what I need for matric no even if matric no is found it still display the if error mesage matric no is not found.
<?php 

//Student Matric Number
$matricno = $_GET["matric"];

//variable to hold Student info
$sInfo = "";

//database information
$sDBServer = "localhost";
$sDBName = "studentaffair";
$sDBUsername = "root";
$sDBPassword = "";

//create the SQL query string
$sQuery = "Select * from populate where matricno=$matricno";

//make the database connection
$oLink = mysql_connect($sDBServer,$sDBUsername,$sDBPassword);
@mysql_select_db($sDBName) or $sInfo = "Unable to open database";

if($sInfo == '') {
if($oResult = mysql_query($sQuery) and mysql_num_rows($oResult)>0) {
$aValues = mysql_fetch_array($oResult,MYSQL_ASSOC);
$sInfo = $aValues['matricno']."
".$aValues['firstname']."
".
$aValues['lastname']."
".$aValues['othername']."
".
$aValues['level']."
".$aValues['semester']."
".
$aValues['cgpa']."
".$aValues['course1']."
".
$aValues['course2']."
".$aValues['course3']."
".
$aValues['course4']."
".$aValues['course5']."
".
$aValues['course6']."
".$aValues['course7']."
".
$aValues['course8']."
".$aValues['course9']."
".
$aValues['course10']."
".$aValues['grade1']."
".
$aValues['grade2']."
".$aValues['grade3']."
".
$aValues['grade4']."
".$aValues['grade5']."
".
$aValues['grade6']."
".$aValues['grade7']."
".
$aValues['grade8']."
".$aValues['grade9']."
".
$aValues['grade10']."
".$aValues['code1']."
".
$aValues['code2']."
".$aValues['code3']."
".
$aValues['code4']."
".$aValues['code5']."
".
$aValues['code6']."
".$aValues['code7']."
".
$aValues['code8']."
".$aValues['code9']."
".
$aValues['code10'];
} else {
$sInfo = "Student with Matric Number $matricno doesn't exist.";
}
}

mysql_close($oLink);

?>

that code is working fine if matricno is set to int as datatype but if matricno is changed to varchar it displays matric no not found. Please help me debug it.
Re: Guru In Php by mininija: 10:56pm On Jun 30, 2010
[you know how it feels when you know a message was here but can't find it ?, yeah: me too]
Re: Guru In Php by kok(m): 7:22pm On Jul 03, 2010
mininija:

Do u still need help on this ?

wadja@wadja.cz.cc - my email sucks,

how does ur email has the answer to his dilemma Black sense!!
Re: Guru In Php by mininija: 9:31am On Jul 17, 2010
(deleted)
Re: Guru In Php by kok(m): 11:49am On Jul 23, 2010
mininija:


Kok - Moderator right ?

U dey completely senseless to insult someone on the forums. If u nor be fool u go know say even idiots get a reason for saying something.

The answer from me nor dey based on the question asked but for something else.

And if u dey so retard as to think say everybody dey as Dull as you then u dey mistaken.

Fool.

--

Imagine an INSANE calling the SANE INSANE.


Black sense confirmed!
Re: Guru In Php by OmniPotens(m): 2:23pm On Jul 23, 2010
@kok and @mininija I pray you not to turn this forum or section or thread into a fighting ground. Please stop any use of abusive words in here.

Resolve your issues now and be free! wink
Re: Guru In Php by kok(m): 6:27pm On Jul 23, 2010
all correct sir, no fighting!
Re: Guru In Php by DualCore1: 7:12pm On Jul 23, 2010
Just when I was about getting pop corn. angry
Re: Guru In Php by kok(m): 7:07pm On Jul 24, 2010
Dual Core:

Just when I was about getting pop corn. angry
lol, what happened?
Re: Guru In Php by DualCore1: 8:08pm On Jul 24, 2010
Omni came outta nowhere and pulled the damn plug (as usual). angry
Re: Guru In Php by Nobody: 4:26pm On Jul 25, 2010
surprised webmasters are ehm tryin to exchange *^&. i have been watching this thread from the start. . .it is quite interesting. Let me return to the backseat
Re: Guru In Php by kok(m): 5:41pm On Jul 26, 2010
apologies, just hate to see someone trying to make cheap publicity outa little prob a fellow webmaster got.
Re: Guru In Php by Nobody: 5:57pm On Jul 26, 2010
accepted. and i am sorry for not being able to help out
Re: Guru In Php by kok(m): 8:25pm On Jul 26, 2010
Hello guys, a client just forwarded this mail to me from an SMS provider coy "In order to connect to our service, you must have your own API via HTTP or SMPP. This means you must be able to connect to server over IP, and initiate the sending on your own. We do not provide a service in which you can simply login to a website and send SMS via tyntec. You have to make this on your own."

Does anyone have an idea of what it is about and how I can possibly go about it?

Plz!
Re: Guru In Php by DualCore1: 9:20pm On Jul 26, 2010
Create a page that you'd use to send sms. You send the form contents to their API using the POST method with the URL provided in their API documentation.

I have done this in the past for sending sms for my personal use.

What exactly are you trying to achieve?
Re: Guru In Php by ogbuson1(f): 2:18am On Jul 27, 2010
for 100% free hosting with no ADS

for 100% free WWW.YOUR-NAME.COM with no ADS

for 100% free HOW TO MAKE MONEY ONLINE WITH GOOGLE FROM NIGERIA

for 100% free BROWSING CODES THAT WORKS

!!!!!!!!!!!! VISIT WWWIEARNREALPAY.COM !!!!!!!!!!!!!!
Re: Guru In Php by kok(m): 10:40am On Jul 27, 2010
Dual Core:

Create a page that you'd use to send sms. You send the form contents to their API using the POST method with the URL provided in their API documentation.

I have done this in the past for sending sms for my personal use.

What exactly are you trying to achieve?

Thanks D'core. He wants a commercial sms portal like www(dot)mobishake(dot)com. and from the forwarded mail, the coy says
kok:

"In order to connect to our service, you must have your own API via HTTP or SMPP. This means you must be able to connect to our server over IP, and initiate the sending on your own. We do not provide a service in which you can simply login to a website and send SMS via tyntec. You have to make this on your own."

To me, this seem like writing an API to be able to connect to their server with just their access-log. How easy can this be?
Re: Guru In Php by Ltrust(m): 10:57pm On Jul 29, 2010
Anyone interested in Oracle 10g study Guide, Questions & Answer guide and its Interactive Video software to Pass your Local and international Oracle 10g exams. Sun compiled USA.

Study guide: 670 pages

Questions & answer Guide: 112 pages

Interactive video software requires you to have up to 500mb in your system

Reach me on: 07033097160.

(1) (Reply)

Bloggers Submit Your Blog For Review For Blogworld Awards 2012 / What Is The Best Tool For Webdesign? / How I Started Blogging- Muhammed Tosin Abdullahi

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 76
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.