Forums

PHP

This topic is locked

mysql

Posted 10 Nov 2006 12:30:31
1
has voted
10 Nov 2006 12:30:31 alex webb posted:
Hi there

I have a table in mysql database with fields like this

username-------------password---------------custorsupp

alex-------------------sdjjdjiaislei--------------C

bloggs----------------djdjjsaowe---------------S




How would i get the value of custorsupp field from the database using php?


And also how would i redirect a user according to this value?


Thanks
Alex

Edited by - mracw on 10 Nov 2006 12:31:50

Edited by - mracw on 10 Nov 2006 12:44:07

Replies

Replied 10 Nov 2006 16:15:31
10 Nov 2006 16:15:31 alex webb replied:
i take it this is abit to much for everyone
Replied 11 Nov 2006 02:26:18
11 Nov 2006 02:26:18 LorD ExoskeletoN replied:
here's the sql statement for that:

assuming that we will get all value of the field custorsupp from the database without any condition

<pre id=code><font face=courier size=2 id=code>

// database connection here

// without condition

$SQL="SELECT * FROM tbl_name";
$Execute = @mysql_query($SQL) or die(@mysql_error());

while ($field = @mysql_fetch_array($Execute)) {

$custorsupp= $field['custorsupp'];

// display the result
echo "$custorsupp&lt;br /&gt;";

}

// here with condition and redirect to the respective page

$SQL="SELECT * FROM tbl_name Where username ='alex' and password = 'sdjjdjiaislei'";
$Execute = @mysql_query($SQL) or die(@mysql_error());

$field = @mysql_fetch_array($Execute);

$username= $field['username'];
$password= $field['password'];
$custorsupp= $field['custorsupp'];

// display field custorsupp just for testing
echo "$custorsupp&lt;br /&gt;";

if ($custorsupp == 'C') {

header("Location: customer.php";

} else {

header("Location: supplier.php";

}

</font id=code></pre id=code>

hope this will help...GOod Luck!

More power...






<div align=right>
afraid NOT to FAIL for you learn NOTHING

www.nasbikesphilippines.bravehost.com
<img src="www.motorcyclephilippines.com/forums/signaturepics/sigpic14460_2.gif" border=0></div id=right>

Edited by - exoskeleton on 11 Nov 2006 02:30:02

Edited by - exoskeleton on 11 Nov 2006 02:32:29

Reply to this topic