Jump to content

rizzler

New Members
  • Posts

    7
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

rizzler's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have this loop on a shorturl website i own that selects domains from my website and lists them in a dropdown list where users can select one domain to use as url shortener. The problem is that when a users selects and entry from the dropdown list this created only the [[[main_url]]] entry from the database table bellow can be used. When someone selectes "coolartistname.site.com the submit button cannot be pressed. in other words it's not adding the SELECTED attribute other than the [[[main_url]]] domain. Can anyone see on the code bellow why this would happen? When i echo $shortUrlDomains it's just saying "Array" and $_REQUEST['shortUrlDomain'] shows nothing. **Index.php** // get base urls $shortUrlDomains = getShortUrlDomains(); <?php foreach ($shortUrlDomains AS $k => $shortUrlDomain) { // active domains only if (($shortUrlDomain['premium_only'] !== '1') && ($shortUrlDomain['premium_only'] !== $Auth->id)) { continue; } echo '<option value="' . (int)$k . '"'; if (isset($_REQUEST['shortUrlDomain'])) { if ($k == (int)$_REQUEST['shortUrlDomain']) { echo 'SELECTED'; } } echo '>'; echo $shortUrlDomain['domain']; if ($disabled == true) { echo ' (' . safeOutputToScreen(t('unavailable', 'unavailable')) . ')'; } '</option>'; } echo '</optgroup>'; ?> FUNCTIONS.PHP function getShortUrlDomains() { // if we already have it cached if(defined('_SETTINGS_SHORT_URL_DOMAINS')) { return unserialize(_SETTINGS_SHORT_URL_DOMAINS); } // get connection $db = Database::getDatabase(true); // load from database $domains = $db->getRows("SELECT id, domain, premium_only, status FROM url_domain ORDER BY premium_only ASC, id ASC"); // organise and replace site url $rs = array(); foreach($domains AS $domain) { if($domain['domain'] == '[[[main_url]]]') { $domain['domain'] = _CONFIG_SITE_FULL_URL; } $rs[$domain{'id'}] = $domain; } **MYSQL DATABASE** url_domain (id, domain, premium_only, status, date_created, owner) VALUES (1, '[[[main_url]]]', 0, 'enabled', '2019-03-02 08:13:00', 1) (14, 'coolartistname.site.com', 6, 'enabled', '2020-04-18 19:21:59', 6);
  2. i just noticed that, thanks for the quick reply guys =) the main problem however is the one i just changedm y post above to, this one.
  3. the "if" statement wont work, if($r[0] + $_POST[kviga] < $r2[0]). i can change the less value to either a "<" or a ">" and the result will still be "cant do that". in my database the sum of "$query2" is 200, and the sum of "$query" is 55.
  4. Hello I wonder if someone please can help me get this to work? :/ <? //räknar ihop bokade kviga biljetter $query = "SELECT sum( kviga ) FROM `bokning`"; //kollar limit på kviga billjetter $query2 = "SELECT sum( kvigamax ) FROM `admin`"; $result = mysql_query($query) or die(mysql_error()); $result2 = mysql_query($query2) or die(mysql_error()); // Print out result of kviga while($r = mysql_fetch_row($result)) { echo $r[0]; } // Print out result of kvigamax while($r2 = mysql_fetch_row($result2)) { echo $r2[0]; } if($r[0] + $_POST[kviga] < $r2[0]) { $sql="INSERT INTO bokning (lagnamn, lagledare, kviga, kalv, ko, deltagare, ovrigt) VALUES ('$_POST[lagnamn]','$_POST[lagledare]','$_POST[kviga]','$_POST[kalv]','$_POST[ko]','$_POST[deltagare]','$_POST[ovrigt]')"; if (!mysql_query($sql,$db)) { die('Error: ' . mysql_error()); } echo "Bokningen är nu genomförd"; mysql_close($db) } else { echo "cant do that"; } ?>
×
×
  • 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.