Jump to content

Search the Community

Showing results for tags 'query; multi variables'.

  • 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. Hello friends, I am working on php to improve my web development skills. I have created a web based university system using php and mysql. However, I got stuck in coding multi variables to query mysql using php. The multi variables are placed in mysql_query() with AND operator as shown below. $query3= mysql_query("SELECT * FROM Student WHERE Student_Name='$xstudent' AND Intake='$xmenu'"); I could be able to query single variable however, face problems with multiple variables. The codes below works but when I query $xboth the output displays three tables showing $query, $query2 and $query3. I WANT TO DISPLAY ONLY $QUERY3 when passing $xboth. <?php include 'Lecture/connection.php'; $xstudent=$_POST['stuname']; $xmenu=$_POST['drop']; $xboth= $_POST['stuname'] AND $_POST['drop']; $query= mysql_query("SELECT * FROM Student WHERE Student_Name='$xstudent'"); $query2= mysql_query("SELECT * FROM Student WHERE Intake='$xmenu'"); $query3= mysql_query("SELECT * FROM Student WHERE Student_Name='$xstudent' AND Intake='$xmenu'"); if($xstudent) { $fields_num = mysql_num_fields($query); // Display table echo "<table border='1'><tr>"; for($i=0; $i<$fields_num; $i++) { $field = mysql_fetch_field($query); echo "<td>{$field->name}</td>"; } echo "</tr>\n"; while($row = mysql_fetch_row($query)) { echo "<tr >"; // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach($row as $cell) echo "<td width= '30' >$cell</td>"; echo "</tr>\n"; } } if($xmenu) { $fields_num2 = mysql_num_fields($query2); // Display table echo "<table border='1'><tr>"; for($i=0; $i<$fields_num2; $i++) { $field2 = mysql_fetch_field($query2); echo "<td>{$field2->name}</td>"; } echo "</tr>\n"; while($row2 = mysql_fetch_row($query2)) { echo "<tr >"; // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach($row2 as $cell2) echo "<td width= '30' >$cell2</td>"; echo "</tr>\n"; } } if($xboth ) { $fields_num3 = mysql_num_fields($query3); // Display table echo "<table border='1'><tr>"; for($i=0; $i<$fields_num3; $i++) { $field3 = mysql_fetch_field($query3); echo "<td>{$field3->name}</td>"; } echo "</tr>\n"; while($row3 = mysql_fetch_row($query3)) { echo "<tr >"; // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach($row3 as $cell3) echo "<td width= '30' >$cell3</td>"; echo "</tr>\n"; } } Please click below to check the screenshot of the output. http://farazi14.webs.com/query.jpg http://farazi14.webs.com/query2.jpg http://farazi14.webs.com/query3.jpg THANKS GUYS
×
×
  • 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.