jodha
02-05-2009, 11:58 AM
Hi All,
Hope you are good. I need a little advice if poss, more so in the form of "ah your code line should be" instead of references to manuals. I find manuals, although helpful in cases, take up lots of time and dont often give a good enough example where I have specific probs (partly my ignorence I am sure, but I am learning to this will become less an issue in time). Manuals so far have given me a very good general understanding though, so not dissing them per say. Anyway, 'nuf of ramble ;)
If have a need to acquire the largest value from a column in a table and turn it into a PHP variable. I have:
___________________________________________________
$connent = connect to db
$query = "SELECT MAX(column name) FROM table";
$result = mysqli_query($connect,$query) or die ("die statement");
$row = mysqli_fetch_row($result);
echo = $row;
___________________________________________________
$connent = works
$query; when typing the same query straight into phpMyAdmin I receive my desired result, number 'X'
I use "echo $row" as I am expecting it to provide the same result as my SQL query in myPHPAdmin.
It doesn't, it displays "Array".
I have tried:
mysqli+fetch_row
mysqli+fetch_assoc
mysqli+fetch_array
No change in output.
I am under the impression this 'should' make $row = 'number X', therefore when I echo $row I should see number 'X'. If I can see the page display 'number X' I knowt I can then turn $row into a better named variable for the rest of my script.
Does anybody have any suggestions?
Many thanks :D
Hope you are good. I need a little advice if poss, more so in the form of "ah your code line should be" instead of references to manuals. I find manuals, although helpful in cases, take up lots of time and dont often give a good enough example where I have specific probs (partly my ignorence I am sure, but I am learning to this will become less an issue in time). Manuals so far have given me a very good general understanding though, so not dissing them per say. Anyway, 'nuf of ramble ;)
If have a need to acquire the largest value from a column in a table and turn it into a PHP variable. I have:
___________________________________________________
$connent = connect to db
$query = "SELECT MAX(column name) FROM table";
$result = mysqli_query($connect,$query) or die ("die statement");
$row = mysqli_fetch_row($result);
echo = $row;
___________________________________________________
$connent = works
$query; when typing the same query straight into phpMyAdmin I receive my desired result, number 'X'
I use "echo $row" as I am expecting it to provide the same result as my SQL query in myPHPAdmin.
It doesn't, it displays "Array".
I have tried:
mysqli+fetch_row
mysqli+fetch_assoc
mysqli+fetch_array
No change in output.
I am under the impression this 'should' make $row = 'number X', therefore when I echo $row I should see number 'X'. If I can see the page display 'number X' I knowt I can then turn $row into a better named variable for the rest of my script.
Does anybody have any suggestions?
Many thanks :D