Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,158,882 members, 7,838,167 topics. Date: Thursday, 23 May 2024 at 04:35 PM

Help With Html/php Form Preview - Webmasters (2) - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Help With Html/php Form Preview (4357 Views)

What Can One Do With Html / Introducing Textpad - A Software To Quickly Learn Web Development With HTML,CSS / How To: Create A Simple Hover Button With Html And Css (2) (3) (4)

(1) (2) (Reply) (Go Down)

Re: Help With Html/php Form Preview by Nobody: 7:39pm On Mar 28, 2011
Iyam happy that the posted has solved his problem. gracias senor donpuzo, i will give you one free chic!
Re: Help With Html/php Form Preview by Nobody: 7:50pm On Mar 28, 2011
*dhtml:

Iyam happy that the posted has solved his problem. gracias senor donpuzo, i will give you one free chic!

Only the Bolded interest me!
Re: Help With Html/php Form Preview by Nobody: 8:33pm On Mar 28, 2011
Not chinenye, i will give you a certain chinwe. . .
Re: Help With Html/php Form Preview by kok(m): 12:27pm On Mar 29, 2011
*dhtml:

Not chinenye, i will give you a certain chinwe. . .

LMAO, chinenye, chinwe, wetin be the difference? they both contain chi, @Donpuzo; are u safe
Re: Help With Html/php Form Preview by kok(m): 5:28pm On Apr 01, 2011
Hello all, am back again,

I am still on thesame project, practicing mode and am stucked again, My query would not refresh, as in, I created database for staffs so that staffs can be search using their staff number, but when I search with a particular staff number, and try with another, it still shows the first one, I need a clue plz! Thanks
Re: Help With Html/php Form Preview by yawatide(f): 6:11pm On Apr 01, 2011
If it is displaying the same number always, it means you are not narrowing your search well (as in, with a "WHERE" clause).

Paste your query for us to see please.
Re: Help With Html/php Form Preview by kok(m): 6:56pm On Apr 01, 2011
@yawa, thanks!

below is the codes;

if (($_POST['staffs'] == "staff_n0"wink) {
$queryMsg = "next staff";
}

$sql = mysql_query("SELECT id, s_n0, s_name, s_address, s_city, s_state, s_zip, s_country, s_email, s_phone, s_pay FROM staffs"wink or die (mysql_error());

$output = '';
while($row = mysql_fetch_array($sql)){

$id = $row["id"];
$s_n0 = $row["s_n0"];
$s_name = $row["s_name"];
$s_address = $row["s_address"];
$s_city = $row["s_city"];
$s_state = $row["s_state"];
$s_zip = $row["s_zip"];
$s_country = $row["s_country"];
$s_email = $row["s_email"];
$s_phone = $row["s_phone"];
$s_pay = $row["s_pay"];
}
Re: Help With Html/php Form Preview by yawatide(f): 9:46pm On Apr 01, 2011
Exactly. You are not specifying a number to search on so you are always getting the first number in your table.

Try something like:
SELECT * FROM staffs WHERE s_no = $_POST['staffs'];

ITKs, please note:
The code above is for demonstrative purposes, based on OP's code, only. In other words, yes, he is supposed to have assigned the post value to a variable and using "die()" is usually a bad practice, from a security point of view. Also, his code doesn't show where he is assigning the results of the query to $row, yet he is using $row. I am just too lazy to type any more than I have typed so far. To that effect, feel free to help out here smiley
Re: Help With Html/php Form Preview by Nobody: 10:12pm On Apr 01, 2011
ehm ehm

undecided

**zooms out before yawa catches me**
Re: Help With Html/php Form Preview by kok(m): 12:23pm On Apr 02, 2011
@yawa, thanks for your response, well appreciate. But I'm yet to move on cuz it doesnt seem to work. When I used this line of code;
$sql = mysql_query("SELECT * FROM staffs WHERE s_no = $_POST['staffs']"wink; I got a
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'.

You suggested "he is supposed to have assigned the post value to a variable". I will appreciate if you can explain this to me.

Thanks.
Re: Help With Html/php Form Preview by Nobody: 11:49pm On Apr 03, 2011
Mr KOK, i will recommend very "KONK" PHP training for you. . . . . . .
Re: Help With Html/php Form Preview by Onos55: 8:02am On Apr 04, 2011
@Kok, I think @Yawa's query is correct. You just need to perhaps concatenate like so:

$sql = mysql_query("SELECT * FROM staffs WHERE s_no = '".$_POST['staffs']."'"wink;

You might want to make things a tad bit 'neater' by assigning the value of $_POST['staffs'] to a new variable, e.g:

$staffNo=$_POST['staffs'];

Then you can use that variable in your query:

$sql = mysql_query("SELECT * FROM staffs WHERE s_no = '$staffNo'"wink;  // Note the single quotes!
Re: Help With Html/php Form Preview by kok(m): 3:20pm On Apr 04, 2011
@Onos55, I truly appreciate your effort and time, thanks!


But think I've just mixed up the query process. When I used
$staffN0=$_POST['staffs'];
$sql = mysql_query("SELECT * FROM staffs WHERE s_no = '$staffN0'"wink;

It still doesnt work, instead it shows a list of "undefined variable" with ",,," on the outputs. Plz is there any alternative to this, can I get a sample code plz?

@*dhtml, you are right about your suggestion I think I need a double KONK training.
Re: Help With Html/php Form Preview by TechPros(m): 9:53am On Apr 05, 2011
post full code

show screenchot of outcome. here
Re: Help With Html/php Form Preview by Eniga(m): 4:31pm On Apr 05, 2011
if (($_POST['staffs'] == "staff_n0"wink) {
$queryMsg = "next staff";
}

$sql = mysql_query("SELECT id, s_n0, s_name, s_address, s_city, s_state, s_zip, s_country, s_email, s_phone, s_pay FROM staffs"wink or die (mysql_error());

$output = '';
while($row = mysql_fetch_array($sql)){

$id = $row["id"];
$s_n0 = $row["s_n0"];
$s_name = $row["s_name"];
$s_address = $row["s_address"];
$s_city = $row["s_city"];
$s_state = $row["s_state"];
$s_zip = $row["s_zip"];
$s_country = $row["s_country"];
$s_email = $row["s_email"];
$s_phone = $row["s_phone"];
$s_pay = $row["s_pay"];
}

@poster, you made a mistake from the beginning of your code, you did not assign your variable but placed it in an IF statement, use this code below


if (($_POST['staffs'] == "staff_n0"wink) {
$queryMsg = "next staff";
}

$query = "SELECT id, s_n0, s_name, s_address, s_city, s_state, s_zip, s_country, s_email, s_phone, s_pay FROM staffs WHERE s_no = '$_POST[staffs]'";
$sql = mysql_query($query) or die (mysql_error());

$output = '';
while($row = mysql_fetch_array($sql)){

$id = $row["id"];
$s_n0 = $row["s_n0"];
$s_name = $row["s_name"];
$s_address = $row["s_address"];
$s_city = $row["s_city"];
$s_state = $row["s_state"];
$s_zip = $row["s_zip"];
$s_country = $row["s_country"];
$s_email = $row["s_email"];
$s_phone = $row["s_phone"];
$s_pay = $row["s_pay"];
}
Re: Help With Html/php Form Preview by yawatide(f): 5:49pm On Apr 05, 2011
OP, if it is still not working:

is it staffNO or staffN0 or staffNo?

Note: the first is capital "O", the 2nd is a zero adn the third is small "o"
Re: Help With Html/php Form Preview by Eniga(m): 6:51pm On Apr 05, 2011
@OP

If you're using version PHP 5 and above, use this code below

IF (($_POST[staffs] == "staff_no"wink)
{
$query = "Next Staff";
}

$query = "SELECT * FROM staffs WHERE s_no = $_POST[staffs]";
$sql = mysqli_query($query) or die(mysqli_error());

$output = '';

while ($row = mysqli_fetch_array($sql)) {
extract ($row);

// Note $id = $row[id], that is all values are converted to variables
}

if u need a hand email me ur php file and tell me wat u want to do and i'll have the code back to you in a few minutes
eniga@ovi.com
Re: Help With Html/php Form Preview by kok(m): 2:46pm On Apr 06, 2011
@Eniga;  with a bow, Thanks, it works now. The 1st one actually solved the problem and I tried the 2nd to and it works fine as well. I truly appreciate your time and effort. Thanks!

@Yawa thanks for thy care, I appreciate!
Re: Help With Html/php Form Preview by kok(m): 7:41pm On Apr 28, 2011
Hello all, I am back again.

I need to echo/print current date/time from a database in the readable form like 7:40pm; Thurs, April 28, 2011. Current date; I mean the time/date the person is view the query.

Thanks in anticipation.

(1) (2) (Reply)

How Do I Claim My Google Adsense In Nigeria / Free Credit Card Generator And Script Rush In / Plugins For Bulk Sms On Wordpress

(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. 25
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.