xpack Posted July 21, 2010 Share Posted July 21, 2010 How do I do something like this $promotionalcode = $db->query("SELECT * FROM `<PRE>promotions` WHERE `amount` = '{$main->getvar['promo']}'"); I want it to check what the user typed in the box and look for that in the promotions table 'promo' and from there take the amount 'amount' and make that equal to $promotionalcode Quote Link to comment https://forums.phpfreaks.com/topic/208380-could-use-some-help/ Share on other sites More sharing options...
fenway Posted July 23, 2010 Share Posted July 23, 2010 What? Quote Link to comment https://forums.phpfreaks.com/topic/208380-could-use-some-help/#findComment-1090343 Share on other sites More sharing options...
awjudd Posted July 23, 2010 Share Posted July 23, 2010 What is the <PRE> in the field name? ~juddster Quote Link to comment https://forums.phpfreaks.com/topic/208380-could-use-some-help/#findComment-1090404 Share on other sites More sharing options...
xpack Posted July 23, 2010 Author Share Posted July 23, 2010 Well I have this $sql['pre'] = "tht_"; #The mySQL Prefix, usually default unless otherwise So that way I can set <PRE> to whatever the user wants their prefix to be for their tables in mysql, and use that throughout the whole script. And can you better explain. Quote Link to comment https://forums.phpfreaks.com/topic/208380-could-use-some-help/#findComment-1090423 Share on other sites More sharing options...
awjudd Posted July 23, 2010 Share Posted July 23, 2010 Then shouldn't the <PRE> be replaced before going into the query function? ... or does your query function handle it for you? ~juddster Quote Link to comment https://forums.phpfreaks.com/topic/208380-could-use-some-help/#findComment-1090429 Share on other sites More sharing options...
gizmola Posted July 23, 2010 Share Posted July 23, 2010 "SELECT * FROM `{$sql['pre']}promotions` WHERE `amount` = '{$main->getvar['promo']}'" Quote Link to comment https://forums.phpfreaks.com/topic/208380-could-use-some-help/#findComment-1090431 Share on other sites More sharing options...
gizmola Posted July 23, 2010 Share Posted July 23, 2010 It might be worthwhile setting up an array with the tablenames prepended in advance so that you could have this type of code instead: "SELECT * FROM `{$tbl['promotions']}` WHERE `amount` = '{$main->getvar['promo']}'" Quote Link to comment https://forums.phpfreaks.com/topic/208380-could-use-some-help/#findComment-1090433 Share on other sites More sharing options...
xpack Posted July 23, 2010 Author Share Posted July 23, 2010 Well the <PRE> works thats not a problem. But I tried this $sql = "SELECT `amount` FROM `<PRE>promotions` WHERE `promo` = '{$main->getvar['promo']}'"; echo $sql; // does this give the query that you are looking for?? $code = $db->query($sql); $amount = $amountinfo['monthly'] - $code But when Tried that and I got As you can see it echoed sql as a string and there is a value promo in the table and when I try that in phpmyadmin it shows the correct value Oh and btw I want it to find amount from promotions table where promo = what the user entered Quote Link to comment https://forums.phpfreaks.com/topic/208380-could-use-some-help/#findComment-1090438 Share on other sites More sharing options...
gizmola Posted July 23, 2010 Share Posted July 23, 2010 Well if the user filled out a form, values from the form will be available to you in the $_POST. Quote Link to comment https://forums.phpfreaks.com/topic/208380-could-use-some-help/#findComment-1090462 Share on other sites More sharing options...
xpack Posted July 24, 2010 Author Share Posted July 24, 2010 Yeah I just put texter because that one of the promo names and I just want to test if its actually reading right Quote Link to comment https://forums.phpfreaks.com/topic/208380-could-use-some-help/#findComment-1090474 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.