PHP - Quicker/more Simpler Way Of Doing This?
$array = array();
for ($i = 97; $i < 123; $i++) { $array[] = chr($i); } for ($i = 65; $i < 91; $i++) { $array[] = chr($i); } Its quite time consuming looping, perhaps combine in 1 or? Similar TutorialsHi, I'm want to be able to change small site contents by using links like: site.com/?radio1, site.com/?radio2, but i want an easier way of making small bits of text change, for example, at the moment, i'm using: Autofresh is: <?php $link ='hits.php?on'; if (isset($_GET['on'])) echo "Enabled |<a href=\"?off\"> Disable?</a>" ?> <?php $link ='hits.php?on'; if (isset($_GET['off'])) echo "Disabled |<a href=\"?on\"> Enable?</a>" ?> Is it possible to do that with only one <?php $link ='hits.php?on'; if (isset($_GET['off'])) echo "Disabled |<a href=\"?on\"> Enable?</a>" ?> So i can have multiple echo's and assign which echo i want to use, for example: <?php $link ='hits.php?on'; if (isset($_GET['off'])) echo1 "Disabled |<a href=\"?on\"> Enable?</a>" echo2 "Enabled |<a href=\"?off\"> Disable?</a>" ?> <?php include echo2 ?> i know that wont work, but since im new to php, i need to explain what i mean. THANKS James I have this query that fully works the way it is, but I am wondering if I am overdoing some things in it. I know this may be hard to tell without knowing the full relationship between all the tables in the query. I'm basically running 3 subqueries mostly based on a timestamp value and other specific clauses per subquery. Where the main query is only gathering based on the timestamp.
Like I said it works perfect from what I can verify by cross referencing the tables manually and checking the results the query returned. I just want to know if there is a better way to do all this.
SELECT `products`.`id` AS `pid`, `products`.`prod_name`, (SELECT COUNT(*) FROM `products` INNER JOIN `quote_deposits` ON `quote_deposits`.`product_id` = `products`.`id` INNER JOIN `quote_responses` ON `quote_responses`.`id` = `quote_deposits`.`q_id` WHERE `quote_responses`.`purchased` = 0 AND `quote_deposits`.`dep_date` >= $committed_start ) AS `committed`, (SELECT COUNT(`products`.`id`) FROM `products` INNER JOIN `quote_deposits` ON `quote_deposits`.`product_id` = `products`.`id` INNER JOIN `quote_responses` ON `quote_responses`.`id` = `quote_deposits`.`q_id` WHERE `quote_responses`.`purchased` = 1 AND `products`.`id` = `pid` AND `quote_deposits`.`dep_date` >= $committed_start ) AS `total_per_item`, (SELECT COUNT(`products`.`id`) FROM `products` INNER JOIN `quote_deposits` ON `quote_deposits`.`product_id` = `products`.`id` INNER JOIN `quote_responses` ON `quote_responses`.`id` = `quote_deposits`.`q_id` INNER JOIN `schedule` ON `schedule`.`deposit_id` = `quote_deposits`.`id` WHERE `quote_responses`.`purchased` = 0 AND `schedule`.`cancelled` != '' AND `products`.`id` = `pid` AND `quote_deposits`.`dep_date` >= $committed_start ) AS `total_cancelled` FROM `products` INNER JOIN `quote_deposits` ON `quote_deposits`.`product_id` = `products`.`id` WHERE `quote_deposits`.`dep_date` >= $committed_start GROUP BY `products`.`prod_name` ORDER BY `products`.`prod_name` ASC |