Jump to content

Search the Community

Showing results for tags 'return variable php echo'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. I'm trying to make it so that my code takes an id given at the beginning and uses this to return a set of arrays. Can anyone explain why my code might work (meaning echo the desired arrays ) like this: 1Array ( [0] => The ‘Sea Swallow’ is an alternative name for which bird? [1] => In which sport would you see a ‘Western Roll’? [2] => Who is better known as ‘Herbert Khaury’? [3] => 'Diet' is the parliament of which country? [4] => What is the real first name of Coco Chanel? [5] => 'The Aztecs' were natives of which country? [6] => What was invented by‘O.A. North’ in 1869? [7] => King Zog was the ruler of which country? ) Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 ) when I echo the variable id and not when I use the return function? when the return function is used I recieve no errors but nothing is printed either. Ideally I'd like the id variable to be returned as I don't really want to see it echoed. I know its probably something really simple but I just can't work it out, any help would be much appreciated, code below: <?php error_reporting(-1); function getquestions($id) { $sql =mysql_query("select text FROM questions WHERE quiz_ID =$id "); $questions = array(); while($row = mysql_fetch_row($sql)) { $questions[] = $row[0]; } return $questions; } function getquesid($id) { $sql =mysql_query("select ID FROM questions WHERE quiz_ID =$id "); $questions = array(); while($row = mysql_fetch_row($sql)) { $questions[] = $row[0]; } return $questions; } //Connect to Database $con = mysql_connect("localhost","dinita", "3nd3m0luk"); if(!$con) { die('Could not connect: '.mysql_error()); } else { // SELECT DATABASE mysql_select_db("quizCreation", $con); } //GET NAME $name ="my quiz"; //get quiz id $sql = mysql_query("SELECT ID FROM quizName WHERE Name= '$name'"); while ($row = mysql_fetch_array($sql)) { $id = $row['ID']; } echo $id; $quizid =$id; $question = getquestions($quizid); $quesid =getquesid($quizid); print_r ($question); print_r($quesid); //use quiz id to output array of question ID's and text // use question ID's to output 4 arrays mysql_close($con);
×
×
  • 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.