Jump to content

Help please.


tcorbeil

Recommended Posts

thanks fellas.

 

it would seem the variable $result returns something like "id #" ... i would like to get rid of the '#' symbol.. I used:

 

$query="SELECT 'submitid' FROM `subcategories` ORDER BY 'submitid' DESC LIMIT 1";

$result=mysql_query($query);

$result=str_replace("_", "#", $result);

 

but it's not working..

 

what I'm after is something $result = value of id_1_oilers...

 

any ideas?

Link to comment
https://forums.phpfreaks.com/topic/45007-help-please/#findComment-218486
Share on other sites

Can someone please clarify this code?

 

i keep getting the value Resource id#4 no matter what value submit id is..

 

what i need is to get the last value in the submitid column in my table.. problem is, i can't seem to get the value out of the array $result... any other suggestions?

 

T

Link to comment
https://forums.phpfreaks.com/topic/45007-help-please/#findComment-218509
Share on other sites

Basically, all I want to do is look into a table, grab the last index number so i can then use it to make a unique variable:

 

eg:

 

look into table hockey and get the last entry on the idex..

 

 

Tabel hockey:

submitid          NHL team

------------------------------------

1                Oilers

2                Flames

3                Flyers

 

So in the end, I want to be able to do something like:

 

/// code to get the last entry on of submitid...

 

$index_id now holds the value "3"

...now lets add one to the value..

$index_id = $index_id ++;

$some_var = "_Canucks";

$next_entry = $index_id.$some_var;

echo $next_entry;  /////  should be a value of "4_Canucks"

 

..I tried your code AndyB, but am not able to make it work.. 

 

T.

 

Link to comment
https://forums.phpfreaks.com/topic/45007-help-please/#findComment-218778
Share on other sites

...

 

tried it.. got this message:

Warning: mysql_insert_id(): supplied argument is not a valid MySQL-Link resource in /home/tcorbeil/public_html/Global/subpost.php on line 41

 

 

code is:

$query="SELECT submitid FROM subcategories ORDER BY submitid DESC LIMIT 1";

$result=mysql_insert_id($query);

$result=ereg_replace("[^[:alnum:]]", "", $result);

$result= str_replace("Resourceid", "ID", $result);

$mktbl = $result."_".$Subpage;

Link to comment
https://forums.phpfreaks.com/topic/45007-help-please/#findComment-218788
Share on other sites

thanks shocker.. i can't use the id idea as it requires me to submit into a table prior..  I need to be able to get the auto_increment id prior to any action..

 

AndyB, you'll have to forgive me.. I think where I get lost is here:

 

$some_var = $row['whatever_variable_you_want'];

// NOW you can run the str_replace

...{/code]

 

you lost me.. is it some_var that gets the value out of the array??  and I also don't understand what to put in for 'whatever_variable_you_want..

 

would it be like this?

 

$some_var = $row['test'];

 

...and then i would format the variable $test??  i just don't get it..  can you enlighten me?

 

T.

Link to comment
https://forums.phpfreaks.com/topic/45007-help-please/#findComment-218822
Share on other sites

What is the name of the specific field that you want to retrieve from the database record?

 

Suppose it was team_name. Then:

$query = " ... your query ..."; // use your real query here
$result = mysql_query($query) or die("error: ". mysql_error(). " with query ". $query);
$row = mysql_fetch_array($result); // get the array of values from the resource result
$team_name = $row['team_name']; // abstract a specific array element. do same for other vars

Link to comment
https://forums.phpfreaks.com/topic/45007-help-please/#findComment-218824
Share on other sites

I tried this..

 

$submitid = $row['submitid'];

echo $submitid;

 

in the effort to get the last entry value issued in my table (If I had 5 entries in the table listed under submitid, i would expect this to be a 5) but all i have echoed to the screen is submitid.. why would this not echo a value of 5?

 

T.

Link to comment
https://forums.phpfreaks.com/topic/45007-help-please/#findComment-218825
Share on other sites

sorry...  I just want to know if someone could kindly have another review of this...

 

Sure - but we need more than two lines of code.  Why not post your table structure along with the complete code you're using to retrieve data from the database.  And are you sure the table contains the information you think it contains? phpAdmin would verify what's really in the database.

Link to comment
https://forums.phpfreaks.com/topic/45007-help-please/#findComment-218931
Share on other sites

I would AndyB but i think i would confuse myself in trying to explain..  sheesh.. i didn't think this would be so difficult..

 

I just want to have a  variable be equal to the last entry of the submit Id (auto_increment) in my table..

 

i don't know what else to say but if post code, it will only raise more questions I'm sure..  the only thing I can think is to ask you this:

 

let say you have table with 5 entries in it where the primary colum is an incremtal counter which increases with every entry.. (who care what other colums are in it really...) how would you go about writing code to look at the table get the last counter value and throw that value into a variable??

 

T.

 

I just want a piece of code to look at the

Link to comment
https://forums.phpfreaks.com/topic/45007-help-please/#findComment-218938
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.