₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,331,155 members, 8,448,898 topics. Date: Tuesday, 21 July 2026 at 03:35 AM

Toggle theme

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

Nairaland ForumScience/TechnologyWebmastersHelp With Html/php Form Preview (4558 Views)

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
[quote author=*dhtml link=topic=628129.msg8005030#msg8005030 date=1301337545]Iyam happy that the posted has solved his problem. gracias senor donpuzo, i will give you one free chic![/quote]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(op): 12:27pm On Mar 29, 2011
[quote author=*dhtml link=topic=628129.msg8005455#msg8005455 date=1301340819]Not chinenye, i will give you a certain chinwe. . .[/quote]LMAO, chinenye, chinwe, wetin be the difference? they both contain chi, @Donpuzo; are u safehuh
Re: Help With Html/php Form Preview by kok(op): 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(op): 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(op): 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(op): 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(op): 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(op): 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

What Can One Do With HtmlIntroducing Textpad - A Software To Quickly Learn Web Development With HTML,CSSHow To: Create A Simple Hover Button With Html And Css234

Help, My Tecno Android Phone Keeps Downloading Apps By ItselfHow To Install Joomla 2.5 Quickstart Template Pack(Step By Step Tutorial Guide)Top 10 Digital Marketing Trends In Nigeria For 2026 – Is Your Business Ready?