FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Manually create array that matches mysql_fetch_array
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Manually create array that matches mysql_fetch_array [message #179730 is a reply to message #179729] Thu, 29 November 2012 10:07 Go to previous messageGo to previous message
Captain Paralytic is currently offline  Captain Paralytic
Messages: 204
Registered: September 2010
Karma:
Senior Member
On Nov 29, 8:51 am, Jason C <jwcarl...@gmail.com> wrote:
> In my script, I'm potentially creating information to insert in to MySQL (based on a few variables), then later in the script I'm SELECTing the same data back out of MySQL. Like this:
>
> if ($_GET['whatever']) {
>   $query = "REPLACE INTO...";
>   mysql_query($query);
>
> }
>
> $s_query = "SELECT ...";
> $sql = mysql_query($s_query);
>
> while (list(...) = mysql_fetch_array($sql)) {
>   // show data
>
> }
>
> This is obviously redundant, though, so I'm trying to find a way to create $sql in the first if() statement, so that the SELECT statement isn't necessary if it already exists.
>
> Like:
>
> if ($_GET['whatever']) {
>   $query = "REPLACE INTO...";
>   mysql_query($query);
>
>   $sql = ???;
>
> }
>
> if (!$sql) {
>   $s_query = "SELECT ...";
>   $sql = mysql_query($s_query);
>
> }
>
> while (list(...) = mysql_fetch_array($sql)) {
>   // show data
>
> }
>
> I know that I could create a regular array, then after the conditional SELECT statement use a loop to push the data in to the array. But what I'm curious about is if it's possible to just manually create the same type of array as mysql_query()?

Have you read the manual?
mysql_query() doesn't return an array.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Query a Array Field in MySQL
Next Topic: Experience Web and Smartphone designer required
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 11:15:56 GMT 2024

Total time taken to generate the page: 0.04964 seconds