Jump to content

Search the Community

Showing results for tags 'mysqli php array'.

  • 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 2 results

  1. I have a foreach statement that contains 20 values. with each value I run a query on tables to return results. I can get it to create an array but it only shows last foreach values returned results. How do I get all 20 results to be in $all_data array. my code so far is $all_data = array(); foreach($id as $idkey => $iduse){ global $all_data, $all_player_data, $temparr, $data; $all_player_data = array(); $temparr = array(); $result_time = $conn->query("SELECT * FROM ".$iduse." order by timedate Asc"); $temptdarray = array(); while ($rowtime = $result_time->fetch_row()) { $timedate = $rowtime[0]; // row 0 $numplayers = $rowtime[1]; // row 1 $maxplayers = $rowtime[2]; // row 2 $status = $rowtime[3]; // row 3 $players = $rowtime[4]; // row 4 $mapname = $rowtime[5]; // row 5 $maptype = $rowtime[6]; // row 6 $data = array("timedate" => $timedate, "numplayers" => $numplayers, "maxplayers" => $maxplayers, "status" => $status, "players" => $players, "mapname" => $mapname, "maptype" => $maptype); array_push($temparr, $data); } $all_player_data[] = array("id" => $idonly[$idkey], "comment" => $comment[$idkey], "data" => $temparr); array_push($all_data[], array($all_player_data)); } if I print_r($all_data) I get all_data Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => [11] => [12] => [13] => [14] => [15] => [16] => [17] => [18] => [19] => ) if I print_r($all_player_data) I get all_player_data Array ( [0] => Array ( [id] => 80 [comment] => FooFire Attack Team [data] => Array ( [0] => Array ( [timedate] => 2021-03-17 16:34 [numplayers] => 0 [maxplayers] => 10 [status] => 1 [players] => [mapname] => SF Village Coop [maptype] => COOP ) [1] => Array ( [timedate] => 2021-03-20 07:12 [numplayers] => 1 [maxplayers] => 10 [status] => 1 [players] => --=P-51=-- [mapname] => SF Village Coop [maptype] => COOP ) [2] => Array ( [timedate] => 2021-03-20 07:26 [numplayers] => 2 [maxplayers] => 10 [status] => 1 [players] => --=P-51=--, [FFAT]herbstfuerst [mapname] => SF Village Coop [maptype] => COOP ) [3] => Array ( [timedate] => 2021-03-20 07:28 [numplayers] => 3 [maxplayers] => 10 [status] => 1 [players] => --=P-51=--, [FFAT]herbstfuerst, YAKIR [mapname] => SF Village Coop [maptype] => COOP ) .................blah blah blah [7223] => Array ( [timedate] => 2021-12-05 06:26 [numplayers] => 0 [maxplayers] => 10 [status] => 1 [players] => [mapname] => SF Village Coop [maptype] => COOP ) [7224] => Array ( [timedate] => 2021-12-05 07:26 [numplayers] => 0 [maxplayers] => 10 [status] => 1 [players] => [mapname] => SF Village Coop [maptype] => COOP ) [7225] => Array ( [timedate] => 2021-12-05 08:26 [numplayers] => 0 [maxplayers] => 10 [status] => 1 [players] => [mapname] => SF Village Coop [maptype] => COOP ) ) ) How do I get all 20 result sets into $all_data?
  2. Hello every one so, I've been using mysql for almost 2years and I've heard that using MySQLi is more secure and I m still new in the prepared statement thing that's why I was wandering how to do this prepared statement with arrays ?? in an example I have this code, how can I execute it with prepared statement ? $sql = mysqli_query($con, "SELECT users.regdate, topics.topic_body FROM `users` LEFT JOIN topics ON topics.topic_author = users.id WHERE topics.id=1 order by topic_edit_time ASC"); if( mysqli_num_rows($sql)>0 ) { while($row = mysqli_fetch_array($sql)) { echo htmlentities($row['regdate']) . "<br>" ; echo htmlentities($row['topic_body']); } } else { echo 'not found'; } Thanks
×
×
  • 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.