Jump to content

Could Use Some Help


xpack

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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']}'"

 

 

 

 

Link to comment
Share on other sites

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

 

78634558.png

 

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.