Jump to content

arrays with mysql


nezbo

Recommended Posts

Hi all

 

I have 2 arrays one form the my sql database and on from an array.

 

I have this code so far from the 'split'.

 

if ($_REQUEST['order'] == ""){//Check if there has been any items been added	
	$numberOfItems = 0;//Set the number of items to zero
}
else{//if items have been added
	$orderedItems = split(".:.", $_REQUEST['order']);//split item string in to an array
	$numberOfItems = count($orderedItems);//count the number of items

 

The following code is from the mySQL

 

$getOrderedItemsInfo = @mysql_query("SELECT * FROM ooh_drugs WHERE valid =0");

while($getOrderedItemsInfo = @mysql_fetch_array($getOrderedItemsInfo))

{

 

}

 

I am not to sure where to start, i was looking a foreach loop and i am not to sure how it works, or if it is the correct way to use it.

 

Neil

Link to comment
https://forums.phpfreaks.com/topic/136474-arrays-with-mysql/
Share on other sites

does this help hope so..

 

example only

<?php

//database connection

$getOrderedItemsInfo ="SELECT * FROM ooh_drugs WHERE order >0 AND valid='0' ";


$res=mysql_query($getOrderInfo)or die (mysql_error());


while($getOrderedItemsInfo = mysql_fetch_array($res)) {


echo "Name of item:  ".$getOrderedItemsInfo['name_of_item']." 
<br>
     Number of items: ".count($getOrderedItemsInfo['number_of_items'])." <br><br> ";

}
   ?>

Link to comment
https://forums.phpfreaks.com/topic/136474-arrays-with-mysql/#findComment-712343
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.